Merge
authorduke
Wed, 05 Jul 2017 23:09:40 +0200
changeset 44507 c61cc8a34456
parent 44506 18569c523d38 (current diff)
parent 44502 fb08f550b0c7 (diff)
child 44508 b3c5addc14c1
Merge
common/bin/shell-tracer.sh
jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml
jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml
jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml
jdk/src/java.base/share/classes/java/lang/StackFramePermission.java
jdk/src/java.base/share/classes/jdk/internal/loader/ResourceHelper.java
--- a/.hgtags-top-repo	Sat Apr 08 03:25:14 2017 +0000
+++ b/.hgtags-top-repo	Wed Jul 05 23:09:40 2017 +0200
@@ -405,3 +405,6 @@
 fe8466adaef8178dba94be53c789a0aaa87d13bb jdk-9+159
 4d29ee32d926ebc960072d51a3bc558f95c1cbad jdk-9+160
 cda60babd152d889aba4d8f20a8f643ab151d3de jdk-9+161
+21b063d75b3edbffb9bebc8872d990920c4ae1e5 jdk-9+162
+c38c6b270ccc8e2b86d1631bcf42248241b54d2c jdk-9+163
+7810f75d016a52e32295c4233009de5ca90e31af jdk-9+164
--- a/common/autoconf/basics.m4	Sat Apr 08 03:25:14 2017 +0000
+++ b/common/autoconf/basics.m4	Wed Jul 05 23:09:40 2017 +0200
@@ -1098,6 +1098,7 @@
   BASIC_PATH_PROGS(HG, hg)
   BASIC_PATH_PROGS(STAT, stat)
   BASIC_PATH_PROGS(TIME, time)
+  BASIC_PATH_PROGS(FLOCK, flock)
   # Dtrace is usually found in /usr/sbin on Solaris, but that directory may not
   # be in the user path.
   BASIC_PATH_PROGS(DTRACE, dtrace, $PATH:/usr/sbin)
--- a/common/autoconf/flags.m4	Sat Apr 08 03:25:14 2017 +0000
+++ b/common/autoconf/flags.m4	Wed Jul 05 23:09:40 2017 +0200
@@ -355,7 +355,7 @@
         SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
         JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
       fi
-      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path[$]1'
+      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
@@ -375,7 +375,7 @@
       # Linking is different on MacOSX
       PICFLAG=''
       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
-      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path[$]1'
+      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
--- a/common/autoconf/generated-configure.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/common/autoconf/generated-configure.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -932,6 +932,7 @@
 IS_GNU_TIME
 PATCH
 DTRACE
+FLOCK
 TIME
 STAT
 HG
@@ -994,6 +995,7 @@
 OPENJDK_TARGET_CPU_LEGACY_LIB
 OPENJDK_TARGET_CPU_LEGACY
 REQUIRED_OS_VERSION
+REQUIRED_OS_ARCH
 REQUIRED_OS_NAME
 COMPILE_TYPE
 OPENJDK_TARGET_CPU_ENDIAN
@@ -1292,6 +1294,7 @@
 HG
 STAT
 TIME
+FLOCK
 DTRACE
 PATCH
 DSYMUTIL
@@ -2256,6 +2259,7 @@
   HG          Override default value for HG
   STAT        Override default value for STAT
   TIME        Override default value for TIME
+  FLOCK       Override default value for FLOCK
   DTRACE      Override default value for DTRACE
   PATCH       Override default value for PATCH
   DSYMUTIL    Override default value for DSYMUTIL
@@ -5173,7 +5177,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1489410066
+DATE_WHEN_GENERATED=1490900744
 
 ###############################################################################
 #
@@ -16038,13 +16042,15 @@
     fi
   fi
   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
-    REQUIRED_OS_NAME=Darwin
+    REQUIRED_OS_NAME="Mac OS X"
     REQUIRED_OS_VERSION=11.2
   fi
   if test "x$OPENJDK_TARGET_OS" = "xaix"; then
     REQUIRED_OS_NAME=AIX
     REQUIRED_OS_VERSION=7.1
   fi
+  REQUIRED_OS_ARCH=${OPENJDK_TARGET_CPU}
+
 
 
 
@@ -23056,6 +23062,203 @@
   fi
 
 
+
+
+  # Publish this variable in the help.
+
+
+  if [ -z "${FLOCK+x}" ]; then
+    # The variable is not set by user, try to locate tool using the code snippet
+    for ac_prog in flock
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FLOCK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FLOCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FLOCK="$FLOCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_FLOCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FLOCK=$ac_cv_path_FLOCK
+if test -n "$FLOCK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLOCK" >&5
+$as_echo "$FLOCK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$FLOCK" && break
+done
+
+  else
+    # The variable is set, but is it from the command line or the environment?
+
+    # Try to remove the string !FLOCK! from our list.
+    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!FLOCK!/}
+    if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
+      # If it failed, the variable was not from the command line. Ignore it,
+      # but warn the user (except for BASH, which is always set by the calling BASH).
+      if test "xFLOCK" != xBASH; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of FLOCK from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of FLOCK from the environment. Use command line variables instead." >&2;}
+      fi
+      # Try to locate tool using the code snippet
+      for ac_prog in flock
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FLOCK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FLOCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FLOCK="$FLOCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_FLOCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FLOCK=$ac_cv_path_FLOCK
+if test -n "$FLOCK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLOCK" >&5
+$as_echo "$FLOCK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$FLOCK" && break
+done
+
+    else
+      # If it succeeded, then it was overridden by the user. We will use it
+      # for the tool.
+
+      # First remove it from the list of overridden variables, so we can test
+      # for unknown variables in the end.
+      CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
+
+      # Check if we try to supply an empty value
+      if test "x$FLOCK" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool FLOCK= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool FLOCK= (no value)" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLOCK" >&5
+$as_echo_n "checking for FLOCK... " >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; }
+      else
+        # Check if the provided tool contains a complete path.
+        tool_specified="$FLOCK"
+        tool_basename="${tool_specified##*/}"
+        if test "x$tool_basename" = "x$tool_specified"; then
+          # A command without a complete path is provided, search $PATH.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool FLOCK=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool FLOCK=$tool_basename" >&6;}
+          # Extract the first word of "$tool_basename", so it can be a program name with args.
+set dummy $tool_basename; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FLOCK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FLOCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FLOCK="$FLOCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_FLOCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FLOCK=$ac_cv_path_FLOCK
+if test -n "$FLOCK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLOCK" >&5
+$as_echo "$FLOCK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+          if test "x$FLOCK" = x; then
+            as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
+          fi
+        else
+          # Otherwise we believe it is a complete path. Use it as it is.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool FLOCK=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool FLOCK=$tool_specified" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLOCK" >&5
+$as_echo_n "checking for FLOCK... " >&6; }
+          if test ! -x "$tool_specified"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+            as_fn_error $? "User supplied tool FLOCK=$tool_specified does not exist or is not executable" "$LINENO" 5
+          fi
+          { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
+$as_echo "$tool_specified" >&6; }
+        fi
+      fi
+    fi
+
+  fi
+
+
   # Dtrace is usually found in /usr/sbin on Solaris, but that directory may not
   # be in the user path.
 
@@ -49486,7 +49689,7 @@
         SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
         JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
       fi
-      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$1'
+      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or $1,/.)'
       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/$1'
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,$1'
@@ -49506,7 +49709,7 @@
       # Linking is different on MacOSX
       PICFLAG=''
       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
-      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$1'
+      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or $1,/.)'
       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/$1'
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,$1'
--- a/common/autoconf/platform.m4	Sat Apr 08 03:25:14 2017 +0000
+++ b/common/autoconf/platform.m4	Wed Jul 05 23:09:40 2017 +0200
@@ -452,15 +452,17 @@
     fi
   fi
   if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
-    REQUIRED_OS_NAME=Darwin
+    REQUIRED_OS_NAME="Mac OS X"
     REQUIRED_OS_VERSION=11.2
   fi
   if test "x$OPENJDK_TARGET_OS" = "xaix"; then
     REQUIRED_OS_NAME=AIX
     REQUIRED_OS_VERSION=7.1
   fi
+  REQUIRED_OS_ARCH=${OPENJDK_TARGET_CPU}
 
   AC_SUBST(REQUIRED_OS_NAME)
+  AC_SUBST(REQUIRED_OS_ARCH)
   AC_SUBST(REQUIRED_OS_VERSION)
 ])
 
--- a/common/autoconf/spec.gmk.in	Sat Apr 08 03:25:14 2017 +0000
+++ b/common/autoconf/spec.gmk.in	Wed Jul 05 23:09:40 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@
@@ -101,8 +101,9 @@
 OPENJDK_BUILD_CPU_BITS:=@OPENJDK_BUILD_CPU_BITS@
 OPENJDK_BUILD_CPU_ENDIAN:=@OPENJDK_BUILD_CPU_ENDIAN@
 
-# Legacy OS values for use in release file.
+# OS values for use in release file.
 REQUIRED_OS_NAME:=@REQUIRED_OS_NAME@
+REQUIRED_OS_ARCH:=@REQUIRED_OS_ARCH@
 REQUIRED_OS_VERSION:=@REQUIRED_OS_VERSION@
 
 LIBM:=@LIBM@
@@ -636,6 +637,7 @@
 DSYMUTIL:=@DSYMUTIL@
 FIND:=@FIND@
 FIND_DELETE:=@FIND_DELETE@
+FLOCK:=@FLOCK@
 ECHO:=@ECHO@
 EGREP:=@EGREP@
 FGREP:=@FGREP@
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/bin/shell-profiler.sh	Wed Jul 05 23:09:40 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	Sat Apr 08 03:25:14 2017 +0000
+++ /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/conf/jib-profiles.js	Sat Apr 08 03:25:14 2017 +0000
+++ b/common/conf/jib-profiles.js	Wed Jul 05 23:09:40 2017 +0200
@@ -910,7 +910,7 @@
         freetype: {
             organization: common.organization,
             ext: "tar.gz",
-            revision: "2.3.4+1.0",
+            revision: "2.7.1-v120+1.0",
             module: "freetype-" + input.target_platform
         }
     };
--- a/corba/.hgtags	Sat Apr 08 03:25:14 2017 +0000
+++ b/corba/.hgtags	Wed Jul 05 23:09:40 2017 +0200
@@ -405,3 +405,6 @@
 6feea77d2083c99e44aa3e272d07b7fb3b801683 jdk-9+159
 c7688f2fa07936b089ca0e9a0a0eff68ff37a542 jdk-9+160
 18f02bc43fe96aef36791d0df7aca748485210cc jdk-9+161
+18ffcf99a3b4a10457853d94190e825bdf07e39b jdk-9+162
+493011dee80e51c2a2b064d049183c047df36d80 jdk-9+163
+965bbae3072702f7c0d95c240523b65e6bb19261 jdk-9+164
--- a/corba/src/java.corba/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/corba/src/java.corba/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the Java binding of the OMG CORBA APIs, and the RMI-IIOP API.
  *
+ * @moduleGraph
  * @since 9
  */
 @Deprecated(since="9", forRemoval=true)
--- a/corba/src/java.corba/share/classes/sun/corba/Bridge.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/corba/src/java.corba/share/classes/sun/corba/Bridge.java	Wed Jul 05 23:09:40 2017 +0200
@@ -59,10 +59,10 @@
  * </ul>
  * The code that calls Bridge.get() must have the following Permissions:
  * <ul>
- * <li>RuntimePermission "reflectionFactoryAccess"</li>
  * <li>BridgePermission "getBridge"</li>
  * <li>ReflectPermission "suppressAccessChecks"</li>
- * <li>StackFramePermission "retainClassReference"</li>
+ * <li>RuntimePermission "getStackWalkerWithClassReference"</li>
+ * <li>RuntimePermission "reflectionFactoryAccess"</li>
  * </ul>
  * <p>
  * All of these permissions are required to obtain and correctly initialize
@@ -105,10 +105,10 @@
     /** Fetch the Bridge singleton.  This requires the following
      * permissions:
      * <ul>
-     * <li>RuntimePermission "reflectionFactoryAccess"</li>
      * <li>BridgePermission "getBridge"</li>
      * <li>ReflectPermission "suppressAccessChecks"</li>
-     * <li>StackFramePermission "retainClassReference"</li>
+     * <li>RuntimePermission "getStackWalkerWithClassReference"</li>
+     * <li>RuntimePermission "reflectionFactoryAccess"</li>
      * </ul>
      * @return The singleton instance of the Bridge class
      * @throws SecurityException if the caller does not have the
--- a/hotspot/.hgtags	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/.hgtags	Wed Jul 05 23:09:40 2017 +0200
@@ -565,3 +565,6 @@
 9211c2e89c1cd11ec2d5752b0f97131a7d7525c7 jdk-9+159
 94b4e2e5331d38eab6a3639c3511b2e0715df0e9 jdk-9+160
 191ffbdb3d7b734288daa7fb76b37a0a85dfe7eb jdk-9+161
+b01c519b715ef6f785d0631adee0a6537cf6c12e jdk-9+162
+983fe207555724d98f4876991e1cbafbcf2733e8 jdk-9+163
+0af429be8bbaeaaf0cb838e9af28c953dda6a9c8 jdk-9+164
--- a/hotspot/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Wed Jul 05 23:09:40 2017 +0200
@@ -81,6 +81,7 @@
 PROCESSOR_PATH := $(call PathList, $(PROCESSOR_JARS))
 
 ADD_EXPORTS := \
+    --add-modules jdk.internal.vm.ci \
     --add-exports jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED \
     --add-exports jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED \
     --add-exports jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED \
--- a/hotspot/make/lib/CompileJvm.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/make/lib/CompileJvm.gmk	Wed Jul 05 23:09:40 2017 +0200
@@ -118,6 +118,12 @@
   OPENJDK_TARGET_CPU_VM_VERSION := amd64
 else ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
   OPENJDK_TARGET_CPU_VM_VERSION := sparc
+else ifeq ($(HOTSPOT_TARGET_CPU_ARCH), arm)
+  ifeq ($(OPENJDK_TARGET_CPU), aarch64)
+    # This sets the Oracle Aarch64 port to use arm64
+    # while the original Aarch64 port uses aarch64
+    OPENJDK_TARGET_CPU_VM_VERSION := arm64
+  endif
 else
   OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU)
 endif
--- a/hotspot/make/test/JtregNative.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/make/test/JtregNative.gmk	Wed Jul 05 23:09:40 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
@@ -48,6 +48,8 @@
     $(HOTSPOT_TOPDIR)/test/runtime/jni/PrivateInterfaceMethods \
     $(HOTSPOT_TOPDIR)/test/runtime/jni/ToStringInInterfaceTest \
     $(HOTSPOT_TOPDIR)/test/runtime/jni/CalleeSavedRegisters \
+    $(HOTSPOT_TOPDIR)/test/runtime/jni/CallWithJNIWeak \
+    $(HOTSPOT_TOPDIR)/test/runtime/jni/ReturnJNIWeak \
     $(HOTSPOT_TOPDIR)/test/runtime/modules/getModuleJNI \
     $(HOTSPOT_TOPDIR)/test/runtime/SameObject \
     $(HOTSPOT_TOPDIR)/test/runtime/BoolReturn \
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad	Wed Jul 05 23:09:40 2017 +0200
@@ -15501,7 +15501,7 @@
 %}
 
 instruct string_indexofUU(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2, iRegI_R2 cnt2,
-       iRegI_R0 result, iRegI tmp1, iRegI tmp2, iRegI tmp3, iRegI tmp4, rFlagsReg cr)
+       iRegI_R0 result, iRegINoSp tmp1, iRegINoSp tmp2, iRegINoSp tmp3, iRegINoSp tmp4, rFlagsReg cr)
 %{
   predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::UU);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 cnt2)));
@@ -15520,7 +15520,7 @@
 %}
 
 instruct string_indexofLL(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2, iRegI_R2 cnt2,
-       iRegI_R0 result, iRegI tmp1, iRegI tmp2, iRegI tmp3, iRegI tmp4, rFlagsReg cr)
+       iRegI_R0 result, iRegINoSp tmp1, iRegINoSp tmp2, iRegINoSp tmp3, iRegINoSp tmp4, rFlagsReg cr)
 %{
   predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::LL);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 cnt2)));
@@ -15539,7 +15539,7 @@
 %}
 
 instruct string_indexofUL(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2, iRegI_R2 cnt2,
-       iRegI_R0 result, iRegI tmp1, iRegI tmp2, iRegI tmp3, iRegI tmp4, rFlagsReg cr)
+       iRegI_R0 result, iRegINoSp tmp1, iRegINoSp tmp2, iRegINoSp tmp3, iRegINoSp tmp4, rFlagsReg cr)
 %{
   predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::UL);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 cnt2)));
@@ -15558,7 +15558,7 @@
 %}
 
 instruct string_indexofLU(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2, iRegI_R2 cnt2,
-       iRegI_R0 result, iRegI tmp1, iRegI tmp2, iRegI tmp3, iRegI tmp4, rFlagsReg cr)
+       iRegI_R0 result, iRegINoSp tmp1, iRegINoSp tmp2, iRegINoSp tmp3, iRegINoSp tmp4, rFlagsReg cr)
 %{
   predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::LU);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 cnt2)));
@@ -15577,8 +15577,8 @@
 %}
 
 instruct string_indexof_conUU(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2,
-                 immI_le_4 int_cnt2, iRegI_R0 result, iRegI tmp1, iRegI tmp2,
-                 iRegI tmp3, iRegI tmp4, rFlagsReg cr)
+                 immI_le_4 int_cnt2, iRegI_R0 result, iRegINoSp tmp1, iRegINoSp tmp2,
+                 iRegINoSp tmp3, iRegINoSp tmp4, rFlagsReg cr)
 %{
   predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::UU);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 int_cnt2)));
@@ -15598,8 +15598,8 @@
 %}
 
 instruct string_indexof_conLL(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2,
-                 immI_le_4 int_cnt2, iRegI_R0 result, iRegI tmp1, iRegI tmp2,
-                 iRegI tmp3, iRegI tmp4, rFlagsReg cr)
+                 immI_le_4 int_cnt2, iRegI_R0 result, iRegINoSp tmp1, iRegINoSp tmp2,
+                 iRegINoSp tmp3, iRegINoSp tmp4, rFlagsReg cr)
 %{
   predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::LL);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 int_cnt2)));
@@ -15619,8 +15619,8 @@
 %}
 
 instruct string_indexof_conUL(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2,
-                 immI_1 int_cnt2, iRegI_R0 result, iRegI tmp1, iRegI tmp2,
-                 iRegI tmp3, iRegI tmp4, rFlagsReg cr)
+                 immI_1 int_cnt2, iRegI_R0 result, iRegINoSp tmp1, iRegINoSp tmp2,
+                 iRegINoSp tmp3, iRegINoSp tmp4, rFlagsReg cr)
 %{
   predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::UL);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 int_cnt2)));
@@ -15640,8 +15640,8 @@
 %}
 
 instruct string_indexof_conLU(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2,
-                 immI_1 int_cnt2, iRegI_R0 result, iRegI tmp1, iRegI tmp2,
-                 iRegI tmp3, iRegI tmp4, rFlagsReg cr)
+                 immI_1 int_cnt2, iRegI_R0 result, iRegINoSp tmp1, iRegINoSp tmp2,
+                 iRegINoSp tmp3, iRegINoSp tmp4, rFlagsReg cr)
 %{
   predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::LU);
   match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 int_cnt2)));
@@ -15661,8 +15661,8 @@
 %}
 
 instruct string_indexofU_char(iRegP_R1 str1, iRegI_R2 cnt1, iRegI_R3 ch,
-                              iRegI_R0 result, iRegI tmp1, iRegI tmp2,
-                              iRegI tmp3, rFlagsReg cr)
+                              iRegI_R0 result, iRegINoSp tmp1, iRegINoSp tmp2,
+                              iRegINoSp tmp3, rFlagsReg cr)
 %{
   match(Set result (StrIndexOfChar (Binary str1 cnt1) ch));
   effect(USE_KILL str1, USE_KILL cnt1, USE_KILL ch,
@@ -16101,7 +16101,7 @@
 
 // ====================REDUCTION ARITHMETIC====================================
 
-instruct reduce_add2I(iRegINoSp dst, iRegIorL2I src1, vecD src2, iRegI tmp, iRegI tmp2)
+instruct reduce_add2I(iRegINoSp dst, iRegIorL2I src1, vecD src2, iRegINoSp tmp, iRegINoSp tmp2)
 %{
   match(Set dst (AddReductionVI src1 src2));
   ins_cost(INSN_COST);
@@ -16120,7 +16120,7 @@
   ins_pipe(pipe_class_default);
 %}
 
-instruct reduce_add4I(iRegINoSp dst, iRegIorL2I src1, vecX src2, vecX tmp, iRegI tmp2)
+instruct reduce_add4I(iRegINoSp dst, iRegIorL2I src1, vecX src2, vecX tmp, iRegINoSp tmp2)
 %{
   match(Set dst (AddReductionVI src1 src2));
   ins_cost(INSN_COST);
@@ -16138,7 +16138,7 @@
   ins_pipe(pipe_class_default);
 %}
 
-instruct reduce_mul2I(iRegINoSp dst, iRegIorL2I src1, vecD src2, iRegI tmp)
+instruct reduce_mul2I(iRegINoSp dst, iRegIorL2I src1, vecD src2, iRegINoSp tmp)
 %{
   match(Set dst (MulReductionVI src1 src2));
   ins_cost(INSN_COST);
@@ -16157,7 +16157,7 @@
   ins_pipe(pipe_class_default);
 %}
 
-instruct reduce_mul4I(iRegINoSp dst, iRegIorL2I src1, vecX src2, vecX tmp, iRegI tmp2)
+instruct reduce_mul4I(iRegINoSp dst, iRegIorL2I src1, vecX src2, vecX tmp, iRegINoSp tmp2)
 %{
   match(Set dst (MulReductionVI src1 src2));
   ins_cost(INSN_COST);
--- a/hotspot/src/cpu/aarch64/vm/jniFastGetField_aarch64.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/jniFastGetField_aarch64.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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.
  *
@@ -82,6 +82,11 @@
   __ eor(robj, robj, rcounter);               // obj, since
                                               // robj ^ rcounter ^ rcounter == robj
                                               // robj is address dependent on rcounter.
+
+  // If mask changes we need to ensure that the inverse is still encodable as an immediate
+  STATIC_ASSERT(JNIHandles::weak_tag_mask == 1);
+  __ andr(robj, robj, ~JNIHandles::weak_tag_mask);
+
   __ ldr(robj, Address(robj, 0));             // *obj
   __ lsr(roffset, c_rarg2, 2);                // offset
 
--- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Wed Jul 05 23:09:40 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.
  * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -2052,13 +2052,31 @@
 
   __ reset_last_Java_frame(false);
 
-  // Unpack oop result
+  // Unbox oop result, e.g. JNIHandles::resolve result.
   if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
-      Label L;
-      __ cbz(r0, L);
-      __ ldr(r0, Address(r0, 0));
-      __ bind(L);
-      __ verify_oop(r0);
+    Label done, not_weak;
+    __ cbz(r0, done);           // Use NULL as-is.
+    STATIC_ASSERT(JNIHandles::weak_tag_mask == 1u);
+    __ tbz(r0, 0, not_weak);    // Test for jweak tag.
+    // Resolve jweak.
+    __ ldr(r0, Address(r0, -JNIHandles::weak_tag_value));
+    __ verify_oop(r0);
+#if INCLUDE_ALL_GCS
+    if (UseG1GC) {
+      __ g1_write_barrier_pre(noreg /* obj */,
+                              r0 /* pre_val */,
+                              rthread /* thread */,
+                              rscratch1 /* tmp */,
+                              true /* tosca_live */,
+                              true /* expand_call */);
+    }
+#endif // INCLUDE_ALL_GCS
+    __ b(done);
+    __ bind(not_weak);
+    // Resolve (untagged) jobject.
+    __ ldr(r0, Address(r0, 0));
+    __ verify_oop(r0);
+    __ bind(done);
   }
 
   if (CheckJNICalls) {
--- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Wed Jul 05 23:09:40 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.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -1399,13 +1399,32 @@
   // and result handler will pick it up
 
   {
-    Label no_oop, store_result;
+    Label no_oop, not_weak, store_result;
     __ adr(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT)));
     __ cmp(t, result_handler);
     __ br(Assembler::NE, no_oop);
-    // retrieve result
+    // Unbox oop result, e.g. JNIHandles::resolve result.
     __ pop(ltos);
-    __ cbz(r0, store_result);
+    __ cbz(r0, store_result);   // Use NULL as-is.
+    STATIC_ASSERT(JNIHandles::weak_tag_mask == 1u);
+    __ tbz(r0, 0, not_weak);    // Test for jweak tag.
+    // Resolve jweak.
+    __ ldr(r0, Address(r0, -JNIHandles::weak_tag_value));
+#if INCLUDE_ALL_GCS
+    if (UseG1GC) {
+      __ enter();                   // Barrier may call runtime.
+      __ g1_write_barrier_pre(noreg /* obj */,
+                              r0 /* pre_val */,
+                              rthread /* thread */,
+                              t /* tmp */,
+                              true /* tosca_live */,
+                              true /* expand_call */);
+      __ leave();
+    }
+#endif // INCLUDE_ALL_GCS
+    __ b(store_result);
+    __ bind(not_weak);
+    // Resolve (untagged) jobject.
     __ ldr(r0, Address(r0, 0));
     __ bind(store_result);
     __ str(r0, Address(rfp, frame::interpreter_frame_oop_temp_offset*wordSize));
--- a/hotspot/src/cpu/arm/vm/interp_masm_arm.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/arm/vm/interp_masm_arm.cpp	Wed Jul 05 23:09:40 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
@@ -476,185 +476,6 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////////
-#if INCLUDE_ALL_GCS
-
-// G1 pre-barrier.
-// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
-// If store_addr != noreg, then previous value is loaded from [store_addr];
-// in such case store_addr and new_val registers are preserved;
-// otherwise pre_val register is preserved.
-void InterpreterMacroAssembler::g1_write_barrier_pre(Register store_addr,
-                                                     Register new_val,
-                                                     Register pre_val,
-                                                     Register tmp1,
-                                                     Register tmp2) {
-  Label done;
-  Label runtime;
-
-  if (store_addr != noreg) {
-    assert_different_registers(store_addr, new_val, pre_val, tmp1, tmp2, noreg);
-  } else {
-    assert (new_val == noreg, "should be");
-    assert_different_registers(pre_val, tmp1, tmp2, noreg);
-  }
-
-  Address in_progress(Rthread, in_bytes(JavaThread::satb_mark_queue_offset() +
-                                        SATBMarkQueue::byte_offset_of_active()));
-  Address index(Rthread, in_bytes(JavaThread::satb_mark_queue_offset() +
-                                  SATBMarkQueue::byte_offset_of_index()));
-  Address buffer(Rthread, in_bytes(JavaThread::satb_mark_queue_offset() +
-                                   SATBMarkQueue::byte_offset_of_buf()));
-
-  // Is marking active?
-  assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "adjust this code");
-  ldrb(tmp1, in_progress);
-  cbz(tmp1, done);
-
-  // Do we need to load the previous value?
-  if (store_addr != noreg) {
-    load_heap_oop(pre_val, Address(store_addr, 0));
-  }
-
-  // Is the previous value null?
-  cbz(pre_val, done);
-
-  // Can we store original value in the thread's buffer?
-  // Is index == 0?
-  // (The index field is typed as size_t.)
-
-  ldr(tmp1, index);           // tmp1 := *index_adr
-  ldr(tmp2, buffer);
-
-  subs(tmp1, tmp1, wordSize); // tmp1 := tmp1 - wordSize
-  b(runtime, lt);             // If negative, goto runtime
-
-  str(tmp1, index);           // *index_adr := tmp1
-
-  // Record the previous value
-  str(pre_val, Address(tmp2, tmp1));
-  b(done);
-
-  bind(runtime);
-
-  // save the live input values
-#ifdef AARCH64
-  if (store_addr != noreg) {
-    raw_push(store_addr, new_val);
-  } else {
-    raw_push(pre_val, ZR);
-  }
-#else
-  if (store_addr != noreg) {
-    // avoid raw_push to support any ordering of store_addr and new_val
-    push(RegisterSet(store_addr) | RegisterSet(new_val));
-  } else {
-    push(pre_val);
-  }
-#endif // AARCH64
-
-  if (pre_val != R0) {
-    mov(R0, pre_val);
-  }
-  mov(R1, Rthread);
-
-  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), R0, R1);
-
-#ifdef AARCH64
-  if (store_addr != noreg) {
-    raw_pop(store_addr, new_val);
-  } else {
-    raw_pop(pre_val, ZR);
-  }
-#else
-  if (store_addr != noreg) {
-    pop(RegisterSet(store_addr) | RegisterSet(new_val));
-  } else {
-    pop(pre_val);
-  }
-#endif // AARCH64
-
-  bind(done);
-}
-
-// G1 post-barrier.
-// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
-void InterpreterMacroAssembler::g1_write_barrier_post(Register store_addr,
-                                                      Register new_val,
-                                                      Register tmp1,
-                                                      Register tmp2,
-                                                      Register tmp3) {
-
-  Address queue_index(Rthread, in_bytes(JavaThread::dirty_card_queue_offset() +
-                                        DirtyCardQueue::byte_offset_of_index()));
-  Address buffer(Rthread, in_bytes(JavaThread::dirty_card_queue_offset() +
-                                   DirtyCardQueue::byte_offset_of_buf()));
-
-  BarrierSet* bs = Universe::heap()->barrier_set();
-  CardTableModRefBS* ct = (CardTableModRefBS*)bs;
-  Label done;
-  Label runtime;
-
-  // Does store cross heap regions?
-
-  eor(tmp1, store_addr, new_val);
-#ifdef AARCH64
-  logical_shift_right(tmp1, tmp1, HeapRegion::LogOfHRGrainBytes);
-  cbz(tmp1, done);
-#else
-  movs(tmp1, AsmOperand(tmp1, lsr, HeapRegion::LogOfHRGrainBytes));
-  b(done, eq);
-#endif
-
-  // crosses regions, storing NULL?
-
-  cbz(new_val, done);
-
-  // storing region crossing non-NULL, is card already dirty?
-  const Register card_addr = tmp1;
-  assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
-
-  mov_address(tmp2, (address)ct->byte_map_base, symbolic_Relocation::card_table_reference);
-  add(card_addr, tmp2, AsmOperand(store_addr, lsr, CardTableModRefBS::card_shift));
-
-  ldrb(tmp2, Address(card_addr));
-  cmp(tmp2, (int)G1SATBCardTableModRefBS::g1_young_card_val());
-  b(done, eq);
-
-  membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), tmp2);
-
-  assert(CardTableModRefBS::dirty_card_val() == 0, "adjust this code");
-  ldrb(tmp2, Address(card_addr));
-  cbz(tmp2, done);
-
-  // storing a region crossing, non-NULL oop, card is clean.
-  // dirty card and log.
-
-  strb(zero_register(tmp2), Address(card_addr));
-
-  ldr(tmp2, queue_index);
-  ldr(tmp3, buffer);
-
-  subs(tmp2, tmp2, wordSize);
-  b(runtime, lt); // go to runtime if now negative
-
-  str(tmp2, queue_index);
-
-  str(card_addr, Address(tmp3, tmp2));
-  b(done);
-
-  bind(runtime);
-
-  if (card_addr != R0) {
-    mov(R0, card_addr);
-  }
-  mov(R1, Rthread);
-  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), R0, R1);
-
-  bind(done);
-}
-
-#endif // INCLUDE_ALL_GCS
-//////////////////////////////////////////////////////////////////////////////////
 
 
 // Java Expression Stack
--- a/hotspot/src/cpu/arm/vm/interp_masm_arm.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/arm/vm/interp_masm_arm.hpp	Wed Jul 05 23:09:40 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
@@ -146,27 +146,6 @@
 
   void set_card(Register card_table_base, Address card_table_addr, Register tmp);
 
-#if INCLUDE_ALL_GCS
-  // G1 pre-barrier.
-  // Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
-  // If store_addr != noreg, then previous value is loaded from [store_addr];
-  // in such case store_addr and new_val registers are preserved;
-  // otherwise pre_val register is preserved.
-  void g1_write_barrier_pre(Register store_addr,
-                            Register new_val,
-                            Register pre_val,
-                            Register tmp1,
-                            Register tmp2);
-
-  // G1 post-barrier.
-  // Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
-  void g1_write_barrier_post(Register store_addr,
-                             Register new_val,
-                             Register tmp1,
-                             Register tmp2,
-                             Register tmp3);
-#endif // INCLUDE_ALL_GCS
-
   void pop_ptr(Register r);
   void pop_i(Register r = R0_tos);
 #ifdef AARCH64
--- a/hotspot/src/cpu/arm/vm/jniFastGetField_arm.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/arm/vm/jniFastGetField_arm.cpp	Wed Jul 05 23:09:40 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
@@ -119,6 +119,14 @@
   __ ldr_s32(Rsafept_cnt, Address(Rsafepoint_counter_addr));
   __ tbnz(Rsafept_cnt, 0, slow_case);
 
+#ifdef AARCH64
+  // If mask changes we need to ensure that the inverse is still encodable as an immediate
+  STATIC_ASSERT(JNIHandles::weak_tag_mask == 1);
+  __ andr(R1, R1, ~JNIHandles::weak_tag_mask);
+#else
+  __ bic(R1, R1, JNIHandles::weak_tag_mask);
+#endif
+
   if (os::is_MP()) {
     // Address dependency restricts memory access ordering. It's cheaper than explicit LoadLoad barrier
     __ andr(Rtmp1, Rsafept_cnt, (unsigned)1);
--- a/hotspot/src/cpu/arm/vm/macroAssembler_arm.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/arm/vm/macroAssembler_arm.cpp	Wed Jul 05 23:09:40 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
@@ -2211,6 +2211,219 @@
   b(done, eq);
 }
 
+
+void MacroAssembler::resolve_jobject(Register value,
+                                     Register tmp1,
+                                     Register tmp2) {
+  assert_different_registers(value, tmp1, tmp2);
+  Label done, not_weak;
+  cbz(value, done);             // Use NULL as-is.
+  STATIC_ASSERT(JNIHandles::weak_tag_mask == 1u);
+  tbz(value, 0, not_weak);      // Test for jweak tag.
+  // Resolve jweak.
+  ldr(value, Address(value, -JNIHandles::weak_tag_value));
+  verify_oop(value);
+#if INCLUDE_ALL_GCS
+  if (UseG1GC) {
+    g1_write_barrier_pre(noreg, // store_addr
+                         noreg, // new_val
+                         value, // pre_val
+                         tmp1,  // tmp1
+                         tmp2); // tmp2
+    }
+#endif // INCLUDE_ALL_GCS
+  b(done);
+  bind(not_weak);
+  // Resolve (untagged) jobject.
+  ldr(value, Address(value));
+  verify_oop(value);
+  bind(done);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////
+
+#if INCLUDE_ALL_GCS
+
+// G1 pre-barrier.
+// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
+// If store_addr != noreg, then previous value is loaded from [store_addr];
+// in such case store_addr and new_val registers are preserved;
+// otherwise pre_val register is preserved.
+void MacroAssembler::g1_write_barrier_pre(Register store_addr,
+                                          Register new_val,
+                                          Register pre_val,
+                                          Register tmp1,
+                                          Register tmp2) {
+  Label done;
+  Label runtime;
+
+  if (store_addr != noreg) {
+    assert_different_registers(store_addr, new_val, pre_val, tmp1, tmp2, noreg);
+  } else {
+    assert (new_val == noreg, "should be");
+    assert_different_registers(pre_val, tmp1, tmp2, noreg);
+  }
+
+  Address in_progress(Rthread, in_bytes(JavaThread::satb_mark_queue_offset() +
+                                        SATBMarkQueue::byte_offset_of_active()));
+  Address index(Rthread, in_bytes(JavaThread::satb_mark_queue_offset() +
+                                  SATBMarkQueue::byte_offset_of_index()));
+  Address buffer(Rthread, in_bytes(JavaThread::satb_mark_queue_offset() +
+                                   SATBMarkQueue::byte_offset_of_buf()));
+
+  // Is marking active?
+  assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "adjust this code");
+  ldrb(tmp1, in_progress);
+  cbz(tmp1, done);
+
+  // Do we need to load the previous value?
+  if (store_addr != noreg) {
+    load_heap_oop(pre_val, Address(store_addr, 0));
+  }
+
+  // Is the previous value null?
+  cbz(pre_val, done);
+
+  // Can we store original value in the thread's buffer?
+  // Is index == 0?
+  // (The index field is typed as size_t.)
+
+  ldr(tmp1, index);           // tmp1 := *index_adr
+  ldr(tmp2, buffer);
+
+  subs(tmp1, tmp1, wordSize); // tmp1 := tmp1 - wordSize
+  b(runtime, lt);             // If negative, goto runtime
+
+  str(tmp1, index);           // *index_adr := tmp1
+
+  // Record the previous value
+  str(pre_val, Address(tmp2, tmp1));
+  b(done);
+
+  bind(runtime);
+
+  // save the live input values
+#ifdef AARCH64
+  if (store_addr != noreg) {
+    raw_push(store_addr, new_val);
+  } else {
+    raw_push(pre_val, ZR);
+  }
+#else
+  if (store_addr != noreg) {
+    // avoid raw_push to support any ordering of store_addr and new_val
+    push(RegisterSet(store_addr) | RegisterSet(new_val));
+  } else {
+    push(pre_val);
+  }
+#endif // AARCH64
+
+  if (pre_val != R0) {
+    mov(R0, pre_val);
+  }
+  mov(R1, Rthread);
+
+  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), R0, R1);
+
+#ifdef AARCH64
+  if (store_addr != noreg) {
+    raw_pop(store_addr, new_val);
+  } else {
+    raw_pop(pre_val, ZR);
+  }
+#else
+  if (store_addr != noreg) {
+    pop(RegisterSet(store_addr) | RegisterSet(new_val));
+  } else {
+    pop(pre_val);
+  }
+#endif // AARCH64
+
+  bind(done);
+}
+
+// G1 post-barrier.
+// Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
+void MacroAssembler::g1_write_barrier_post(Register store_addr,
+                                           Register new_val,
+                                           Register tmp1,
+                                           Register tmp2,
+                                           Register tmp3) {
+
+  Address queue_index(Rthread, in_bytes(JavaThread::dirty_card_queue_offset() +
+                                        DirtyCardQueue::byte_offset_of_index()));
+  Address buffer(Rthread, in_bytes(JavaThread::dirty_card_queue_offset() +
+                                   DirtyCardQueue::byte_offset_of_buf()));
+
+  BarrierSet* bs = Universe::heap()->barrier_set();
+  CardTableModRefBS* ct = (CardTableModRefBS*)bs;
+  Label done;
+  Label runtime;
+
+  // Does store cross heap regions?
+
+  eor(tmp1, store_addr, new_val);
+#ifdef AARCH64
+  logical_shift_right(tmp1, tmp1, HeapRegion::LogOfHRGrainBytes);
+  cbz(tmp1, done);
+#else
+  movs(tmp1, AsmOperand(tmp1, lsr, HeapRegion::LogOfHRGrainBytes));
+  b(done, eq);
+#endif
+
+  // crosses regions, storing NULL?
+
+  cbz(new_val, done);
+
+  // storing region crossing non-NULL, is card already dirty?
+  const Register card_addr = tmp1;
+  assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
+
+  mov_address(tmp2, (address)ct->byte_map_base, symbolic_Relocation::card_table_reference);
+  add(card_addr, tmp2, AsmOperand(store_addr, lsr, CardTableModRefBS::card_shift));
+
+  ldrb(tmp2, Address(card_addr));
+  cmp(tmp2, (int)G1SATBCardTableModRefBS::g1_young_card_val());
+  b(done, eq);
+
+  membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), tmp2);
+
+  assert(CardTableModRefBS::dirty_card_val() == 0, "adjust this code");
+  ldrb(tmp2, Address(card_addr));
+  cbz(tmp2, done);
+
+  // storing a region crossing, non-NULL oop, card is clean.
+  // dirty card and log.
+
+  strb(zero_register(tmp2), Address(card_addr));
+
+  ldr(tmp2, queue_index);
+  ldr(tmp3, buffer);
+
+  subs(tmp2, tmp2, wordSize);
+  b(runtime, lt); // go to runtime if now negative
+
+  str(tmp2, queue_index);
+
+  str(card_addr, Address(tmp3, tmp2));
+  b(done);
+
+  bind(runtime);
+
+  if (card_addr != R0) {
+    mov(R0, card_addr);
+  }
+  mov(R1, Rthread);
+  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), R0, R1);
+
+  bind(done);
+}
+
+#endif // INCLUDE_ALL_GCS
+
+//////////////////////////////////////////////////////////////////////////////////
+
 #ifdef AARCH64
 
 void MacroAssembler::load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed) {
--- a/hotspot/src/cpu/arm/vm/macroAssembler_arm.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/arm/vm/macroAssembler_arm.hpp	Wed Jul 05 23:09:40 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
@@ -402,6 +402,29 @@
   void biased_locking_enter_with_cas(Register obj_reg, Register old_mark_reg, Register new_mark_reg,
                                      Register tmp, Label& slow_case, int* counter_addr);
 
+  void resolve_jobject(Register value, Register tmp1, Register tmp2);
+
+#if INCLUDE_ALL_GCS
+  // G1 pre-barrier.
+  // Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
+  // If store_addr != noreg, then previous value is loaded from [store_addr];
+  // in such case store_addr and new_val registers are preserved;
+  // otherwise pre_val register is preserved.
+  void g1_write_barrier_pre(Register store_addr,
+                            Register new_val,
+                            Register pre_val,
+                            Register tmp1,
+                            Register tmp2);
+
+  // G1 post-barrier.
+  // Blows all volatile registers (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR).
+  void g1_write_barrier_post(Register store_addr,
+                             Register new_val,
+                             Register tmp1,
+                             Register tmp2,
+                             Register tmp3);
+#endif // INCLUDE_ALL_GCS
+
 #ifndef AARCH64
   void nop() {
     mov(R0, R0);
--- a/hotspot/src/cpu/arm/vm/sharedRuntime_arm.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/arm/vm/sharedRuntime_arm.cpp	Wed Jul 05 23:09:40 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
@@ -1732,14 +1732,7 @@
   case T_FLOAT  : // fall through
   case T_DOUBLE : /* nothing to do */          break;
   case T_OBJECT : // fall through
-  case T_ARRAY  : {
-    Label L;
-    __ cbz(R0, L);
-    __ ldr(R0, Address(R0));
-    __ verify_oop(R0);
-    __ bind(L);
-    break;
-  }
+  case T_ARRAY  : break; // See JNIHandles::resolve below
   default:
     ShouldNotReachHere();
   }
@@ -1748,13 +1741,14 @@
   if (CheckJNICalls) {
     __ str(__ zero_register(Rtemp), Address(Rthread, JavaThread::pending_jni_exception_check_fn_offset()));
   }
+#endif // AARCH64
 
-  // Unhandle the result
+  // Unbox oop result, e.g. JNIHandles::resolve value in R0.
   if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
-    __ cmp(R0, 0);
-    __ ldr(R0, Address(R0), ne);
+    __ resolve_jobject(R0,      // value
+                       Rtemp,   // tmp1
+                       R1_tmp); // tmp2
   }
-#endif // AARCH64
 
   // Any exception pending?
   __ ldr(Rtemp, Address(Rthread, Thread::pending_exception_offset()));
--- a/hotspot/src/cpu/arm/vm/templateInterpreterGenerator_arm.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/arm/vm/templateInterpreterGenerator_arm.cpp	Wed Jul 05 23:09:40 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
@@ -1240,28 +1240,25 @@
     __ str(__ zero_register(Rtemp), Address(Rthread, JavaThread::pending_jni_exception_check_fn_offset()));
   }
 
-  // Unbox if the result is non-zero object
+  // Unbox oop result, e.g. JNIHandles::resolve result if it's an oop.
+  {
+    Label Lnot_oop;
 #ifdef AARCH64
-  {
-    Label L, Lnull;
     __ mov_slow(Rtemp, AbstractInterpreter::result_handler(T_OBJECT));
     __ cmp(Rresult_handler, Rtemp);
-    __ b(L, ne);
-    __ cbz(Rsaved_result, Lnull);
-    __ ldr(Rsaved_result, Address(Rsaved_result));
-    __ bind(Lnull);
-    // Store oop on the stack for GC
-    __ str(Rsaved_result, Address(FP, frame::interpreter_frame_oop_temp_offset * wordSize));
-    __ bind(L);
+    __ b(Lnot_oop, ne);
+#else // !AARCH64
+    // For ARM32, Rresult_handler is -1 for oop result, 0 otherwise.
+    __ cbz(Rresult_handler, Lnot_oop);
+#endif // !AARCH64
+    Register value = AARCH64_ONLY(Rsaved_result) NOT_AARCH64(Rsaved_result_lo);
+    __ resolve_jobject(value,   // value
+                       Rtemp,   // tmp1
+                       R1_tmp); // tmp2
+    // Store resolved result in frame for GC visibility.
+    __ str(value, Address(FP, frame::interpreter_frame_oop_temp_offset * wordSize));
+    __ bind(Lnot_oop);
   }
-#else
-  __ tst(Rsaved_result_lo, Rresult_handler);
-  __ ldr(Rsaved_result_lo, Address(Rsaved_result_lo), ne);
-
-  // Store oop on the stack for GC
-  __ cmp(Rresult_handler, 0);
-  __ str(Rsaved_result_lo, Address(FP, frame::interpreter_frame_oop_temp_offset * wordSize), ne);
-#endif // AARCH64
 
 #ifdef AARCH64
   // Restore SP (drop native parameters area), to keep SP in sync with extended_sp in frame
--- a/hotspot/src/cpu/ppc/vm/frame_ppc.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/ppc/vm/frame_ppc.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -171,10 +171,7 @@
     switch (method->result_type()) {
       case T_OBJECT:
       case T_ARRAY: {
-        oop* obj_p = *(oop**)lresult;
-        oop obj = (obj_p == NULL) ? (oop)NULL : *obj_p;
-        assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
-        *oop_result = obj;
+        *oop_result = JNIHandles::resolve(*(jobject*)lresult);
         break;
       }
       // We use std/stfd to store the values.
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3033,6 +3033,34 @@
   stbx(R0, Rtmp, Robj);
 }
 
+// Kills R31 if value is a volatile register.
+void MacroAssembler::resolve_jobject(Register value, Register tmp1, Register tmp2, bool needs_frame) {
+  Label done;
+  cmpdi(CCR0, value, 0);
+  beq(CCR0, done);         // Use NULL as-is.
+
+  clrrdi(tmp1, value, JNIHandles::weak_tag_size);
+#if INCLUDE_ALL_GCS
+  if (UseG1GC) { andi_(tmp2, value, JNIHandles::weak_tag_mask); }
+#endif
+  ld(value, 0, tmp1);      // Resolve (untagged) jobject.
+
+#if INCLUDE_ALL_GCS
+  if (UseG1GC) {
+    Label not_weak;
+    beq(CCR0, not_weak);   // Test for jweak tag.
+    verify_oop(value);
+    g1_write_barrier_pre(noreg, // obj
+                         noreg, // offset
+                         value, // pre_val
+                         tmp1, tmp2, needs_frame);
+    bind(not_weak);
+  }
+#endif // INCLUDE_ALL_GCS
+  verify_oop(value);
+  bind(done);
+}
+
 #if INCLUDE_ALL_GCS
 // General G1 pre-barrier generator.
 // Goal: record the previous value if it is not null.
@@ -3094,7 +3122,7 @@
 
   bind(runtime);
 
-  // VM call need frame to access(write) O register.
+  // May need to preserve LR. Also needed if current frame is not compatible with C calling convention.
   if (needs_frame) {
     save_LR_CR(Rtmp1);
     push_frame_reg_args(0, Rtmp2);
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -649,6 +649,8 @@
   void card_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp);
   void card_table_write(jbyte* byte_map_base, Register Rtmp, Register Robj);
 
+  void resolve_jobject(Register value, Register tmp1, Register tmp2, bool needs_frame);
+
 #if INCLUDE_ALL_GCS
   // General G1 pre-barrier generator.
   void g1_write_barrier_pre(Register Robj, RegisterOrConstant offset, Register Rpre_val,
--- a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2477,16 +2477,11 @@
 
   __ reset_last_Java_frame();
 
-  // Unpack oop result.
+  // Unbox oop result, e.g. JNIHandles::resolve value.
   // --------------------------------------------------------------------------
 
   if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
-    Label skip_unboxing;
-    __ cmpdi(CCR0, R3_RET, 0);
-    __ beq(CCR0, skip_unboxing);
-    __ ld(R3_RET, 0, R3_RET);
-    __ bind(skip_unboxing);
-    __ verify_oop(R3_RET);
+    __ resolve_jobject(R3_RET, r_temp_1, r_temp_2, /* needs_frame */ false); // kills R31
   }
 
   if (CheckJNICalls) {
--- a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015, 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -401,11 +401,8 @@
   case T_LONG:
      break;
   case T_OBJECT:
-    // unbox result if not null
-    __ cmpdi(CCR0, R3_RET, 0);
-    __ beq(CCR0, done);
-    __ ld(R3_RET, 0, R3_RET);
-    __ verify_oop(R3_RET);
+    // JNIHandles::resolve result.
+    __ resolve_jobject(R3_RET, R11_scratch1, R12_scratch2, /* needs_frame */ true); // kills R31
     break;
   case T_FLOAT:
      break;
--- a/hotspot/src/cpu/s390/vm/macroAssembler_s390.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/s390/vm/macroAssembler_s390.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -3439,6 +3439,34 @@
   z_mvi(0, store_addr, 0); // Store byte 0.
 }
 
+void MacroAssembler::resolve_jobject(Register value, Register tmp1, Register tmp2) {
+  NearLabel Ldone;
+  z_ltgr(tmp1, value);
+  z_bre(Ldone);          // Use NULL result as-is.
+
+  z_nill(value, ~JNIHandles::weak_tag_mask);
+  z_lg(value, 0, value); // Resolve (untagged) jobject.
+
+#if INCLUDE_ALL_GCS
+  if (UseG1GC) {
+    NearLabel Lnot_weak;
+    z_tmll(tmp1, JNIHandles::weak_tag_mask); // Test for jweak tag.
+    z_braz(Lnot_weak);
+    verify_oop(value);
+    g1_write_barrier_pre(noreg /* obj */,
+                         noreg /* offset */,
+                         value /* pre_val */,
+                         noreg /* val */,
+                         tmp1  /* tmp1 */,
+                         tmp2  /* tmp2 */,
+                         true  /* pre_val_needed */);
+    bind(Lnot_weak);
+  }
+#endif // INCLUDE_ALL_GCS
+  verify_oop(value);
+  bind(Ldone);
+}
+
 #if INCLUDE_ALL_GCS
 
 //------------------------------------------------------
--- a/hotspot/src/cpu/s390/vm/macroAssembler_s390.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/s390/vm/macroAssembler_s390.hpp	Wed Jul 05 23:09:40 2017 +0200
@@ -726,6 +726,8 @@
   // Write to card table for modification at store_addr - register is destroyed afterwards.
   void card_write_barrier_post(Register store_addr, Register tmp);
 
+  void resolve_jobject(Register value, Register tmp1, Register tmp2);
+
 #if INCLUDE_ALL_GCS
   // General G1 pre-barrier generator.
   // Purpose: record the previous value if it is not null.
--- a/hotspot/src/cpu/s390/vm/sharedRuntime_s390.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/s390/vm/sharedRuntime_s390.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2272,13 +2272,9 @@
 
   __ reset_last_Java_frame();
 
-  // Unpack oop result
+  // Unpack oop result, e.g. JNIHandles::resolve result.
   if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
-    NearLabel L;
-    __ compare64_and_branch(Z_RET, (RegisterOrConstant)0L, Assembler::bcondEqual, L);
-    __ z_lg(Z_RET, 0, Z_RET);
-    __ bind(L);
-    __ verify_oop(Z_RET);
+    __ resolve_jobject(Z_RET, /* tmp1 */ Z_R13, /* tmp2 */ Z_R7);
   }
 
   if (CheckJNICalls) {
--- a/hotspot/src/cpu/s390/vm/templateInterpreterGenerator_s390.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/s390/vm/templateInterpreterGenerator_s390.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1695,14 +1695,11 @@
   // from the jni handle to z_ijava_state.oop_temp. This is
   // necessary, because we reset the jni handle block below.
   // NOTE: frame::interpreter_frame_result() depends on this, too.
-  { NearLabel no_oop_result, store_oop_result;
+  { NearLabel no_oop_result;
   __ load_absolute_address(Z_R1, AbstractInterpreter::result_handler(T_OBJECT));
   __ compareU64_and_branch(Z_R1, Rresult_handler, Assembler::bcondNotEqual, no_oop_result);
-  __ compareU64_and_branch(Rlresult, (intptr_t)0L, Assembler::bcondEqual, store_oop_result);
-  __ z_lg(Rlresult, 0, Rlresult);  // unbox
-  __ bind(store_oop_result);
+  __ resolve_jobject(Rlresult, /* tmp1 */ Rmethod, /* tmp2 */ Z_R1);
   __ z_stg(Rlresult, oop_tmp_offset, Z_fp);
-  __ verify_oop(Rlresult);
   __ bind(no_oop_result);
   }
 
--- a/hotspot/src/cpu/sparc/vm/jniFastGetField_sparc.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/sparc/vm/jniFastGetField_sparc.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, 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
@@ -68,6 +68,7 @@
   __ andcc (G4, 1, G0);
   __ br (Assembler::notZero, false, Assembler::pn, label1);
   __ delayed()->srl (O2, 2, O4);
+  __ andn (O1, JNIHandles::weak_tag_mask, O1);
   __ ld_ptr (O1, 0, O5);
 
   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
@@ -147,6 +148,7 @@
   __ andcc (G4, 1, G0);
   __ br (Assembler::notZero, false, Assembler::pn, label1);
   __ delayed()->srl (O2, 2, O4);
+  __ andn (O1, JNIHandles::weak_tag_mask, O1);
   __ ld_ptr (O1, 0, O5);
   __ add (O5, O4, O5);
 
@@ -219,6 +221,7 @@
   __ andcc (G4, 1, G0);
   __ br (Assembler::notZero, false, Assembler::pn, label1);
   __ delayed()->srl (O2, 2, O4);
+  __ andn (O1, JNIHandles::weak_tag_mask, O1);
   __ ld_ptr (O1, 0, O5);
 
   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
--- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Wed Jul 05 23:09:40 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
@@ -2754,15 +2754,30 @@
   __ verify_thread(); // G2_thread must be correct
   __ reset_last_Java_frame();
 
-  // Unpack oop result
+  // Unbox oop result, e.g. JNIHandles::resolve value in I0.
   if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
-      Label L;
-      __ addcc(G0, I0, G0);
-      __ brx(Assembler::notZero, true, Assembler::pt, L);
-      __ delayed()->ld_ptr(I0, 0, I0);
-      __ mov(G0, I0);
-      __ bind(L);
-      __ verify_oop(I0);
+    Label done, not_weak;
+    __ br_null(I0, false, Assembler::pn, done); // Use NULL as-is.
+    __ delayed()->andcc(I0, JNIHandles::weak_tag_mask, G0); // Test for jweak
+    __ brx(Assembler::zero, true, Assembler::pt, not_weak);
+    __ delayed()->ld_ptr(I0, 0, I0); // Maybe resolve (untagged) jobject.
+    // Resolve jweak.
+    __ ld_ptr(I0, -JNIHandles::weak_tag_value, I0);
+#if INCLUDE_ALL_GCS
+    if (UseG1GC) {
+      // Copy to O0 because macro doesn't allow pre_val in input reg.
+      __ mov(I0, O0);
+      __ g1_write_barrier_pre(noreg /* obj */,
+                              noreg /* index */,
+                              0 /* offset */,
+                              O0 /* pre_val */,
+                              G3_scratch /* tmp */,
+                              true /* preserve_o_regs */);
+    }
+#endif // INCLUDE_ALL_GCS
+    __ bind(not_weak);
+    __ verify_oop(I0);
+    __ bind(done);
   }
 
   if (CheckJNICalls) {
--- a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp	Wed Jul 05 23:09:40 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
@@ -1516,11 +1516,23 @@
 
     __ set((intptr_t)AbstractInterpreter::result_handler(T_OBJECT), G3_scratch);
     __ cmp_and_brx_short(G3_scratch, Lscratch, Assembler::notEqual, Assembler::pt, no_oop);
-    __ addcc(G0, O0, O0);
-    __ brx(Assembler::notZero, true, Assembler::pt, store_result);     // if result is not NULL:
-    __ delayed()->ld_ptr(O0, 0, O0);                                   // unbox it
-    __ mov(G0, O0);
-
+    // Unbox oop result, e.g. JNIHandles::resolve value in O0.
+    __ br_null(O0, false, Assembler::pn, store_result); // Use NULL as-is.
+    __ delayed()->andcc(O0, JNIHandles::weak_tag_mask, G0); // Test for jweak
+    __ brx(Assembler::zero, true, Assembler::pt, store_result);
+    __ delayed()->ld_ptr(O0, 0, O0); // Maybe resolve (untagged) jobject.
+    // Resolve jweak.
+    __ ld_ptr(O0, -JNIHandles::weak_tag_value, O0);
+#if INCLUDE_ALL_GCS
+    if (UseG1GC) {
+      __ g1_write_barrier_pre(noreg /* obj */,
+                              noreg /* index */,
+                              0 /* offset */,
+                              O0 /* pre_val */,
+                              G3_scratch /* tmp */,
+                              true /* preserve_o_regs */);
+    }
+#endif // INCLUDE_ALL_GCS
     __ bind(store_result);
     // Store it where gc will look for it and result handler expects it.
     __ st_ptr(O0, FP, (frame::interpreter_frame_oop_temp_offset*wordSize) + STACK_BIAS);
--- a/hotspot/src/cpu/x86/vm/jniFastGetField_x86_32.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/x86/vm/jniFastGetField_x86_32.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, 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
@@ -85,6 +85,9 @@
     __ movptr (rdx, Address(rsp, 2*wordSize));  // obj
   }
   __ movptr(rax, Address(rsp, 3*wordSize));  // jfieldID
+
+  __ clear_jweak_tag(rdx);
+
   __ movptr(rdx, Address(rdx, 0));           // *obj
   __ shrptr (rax, 2);                         // offset
 
@@ -202,6 +205,9 @@
     __ movptr(rdx, Address(rsp, 3*wordSize));  // obj
   }
   __ movptr(rsi, Address(rsp, 4*wordSize));  // jfieldID
+
+  __ clear_jweak_tag(rdx);
+
   __ movptr(rdx, Address(rdx, 0));           // *obj
   __ shrptr(rsi, 2);                         // offset
 
@@ -291,6 +297,9 @@
     __ movptr(rdx, Address(rsp, 2*wordSize)); // obj
   }
   __ movptr(rax, Address(rsp, 3*wordSize));  // jfieldID
+
+  __ clear_jweak_tag(rdx);
+
   __ movptr(rdx, Address(rdx, 0));           // *obj
   __ shrptr(rax, 2);                         // offset
 
--- a/hotspot/src/cpu/x86/vm/jniFastGetField_x86_64.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/x86/vm/jniFastGetField_x86_64.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, 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
@@ -80,6 +80,9 @@
                                                 // robj ^ rcounter ^ rcounter == robj
                                                 // robj is data dependent on rcounter.
   }
+
+  __ clear_jweak_tag(robj);
+
   __ movptr(robj, Address(robj, 0));             // *obj
   __ mov   (roffset, c_rarg2);
   __ shrptr(roffset, 2);                         // offset
@@ -178,6 +181,9 @@
                                                 // robj ^ rcounter ^ rcounter == robj
                                                 // robj is data dependent on rcounter.
   }
+
+  __ clear_jweak_tag(robj);
+
   __ movptr(robj, Address(robj, 0));             // *obj
   __ mov   (roffset, c_rarg2);
   __ shrptr(roffset, 2);                         // offset
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp	Wed Jul 05 23:09:40 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
@@ -5129,6 +5129,43 @@
 }
 
 
+void MacroAssembler::resolve_jobject(Register value,
+                                     Register thread,
+                                     Register tmp) {
+  assert_different_registers(value, thread, tmp);
+  Label done, not_weak;
+  testptr(value, value);
+  jcc(Assembler::zero, done);                // Use NULL as-is.
+  testptr(value, JNIHandles::weak_tag_mask); // Test for jweak tag.
+  jcc(Assembler::zero, not_weak);
+  // Resolve jweak.
+  movptr(value, Address(value, -JNIHandles::weak_tag_value));
+  verify_oop(value);
+#if INCLUDE_ALL_GCS
+  if (UseG1GC) {
+    g1_write_barrier_pre(noreg /* obj */,
+                         value /* pre_val */,
+                         thread /* thread */,
+                         tmp /* tmp */,
+                         true /* tosca_live */,
+                         true /* expand_call */);
+  }
+#endif // INCLUDE_ALL_GCS
+  jmp(done);
+  bind(not_weak);
+  // Resolve (untagged) jobject.
+  movptr(value, Address(value, 0));
+  verify_oop(value);
+  bind(done);
+}
+
+void MacroAssembler::clear_jweak_tag(Register possibly_jweak) {
+  const int32_t inverted_jweak_mask = ~static_cast<int32_t>(JNIHandles::weak_tag_mask);
+  STATIC_ASSERT(inverted_jweak_mask == -2); // otherwise check this code
+  // The inverted mask is sign-extended
+  andptr(possibly_jweak, inverted_jweak_mask);
+}
+
 //////////////////////////////////////////////////////////////////////////////////
 #if INCLUDE_ALL_GCS
 
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp	Wed Jul 05 23:09:40 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
@@ -297,6 +297,9 @@
   void store_check(Register obj);                // store check for obj - register is destroyed afterwards
   void store_check(Register obj, Address dst);   // same as above, dst is exact store location (reg. is destroyed)
 
+  void resolve_jobject(Register value, Register thread, Register tmp);
+  void clear_jweak_tag(Register possibly_jweak);
+
 #if INCLUDE_ALL_GCS
 
   void g1_write_barrier_pre(Register obj,
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Wed Jul 05 23:09:40 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
@@ -2226,14 +2226,11 @@
 
   __ reset_last_Java_frame(thread, false);
 
-  // Unpack oop result
+  // Unbox oop result, e.g. JNIHandles::resolve value.
   if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
-      Label L;
-      __ cmpptr(rax, (int32_t)NULL_WORD);
-      __ jcc(Assembler::equal, L);
-      __ movptr(rax, Address(rax, 0));
-      __ bind(L);
-      __ verify_oop(rax);
+    __ resolve_jobject(rax /* value */,
+                       thread /* thread */,
+                       rcx /* tmp */);
   }
 
   if (CheckJNICalls) {
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Wed Jul 05 23:09:40 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
@@ -2579,14 +2579,11 @@
 
   __ reset_last_Java_frame(false);
 
-  // Unpack oop result
+  // Unbox oop result, e.g. JNIHandles::resolve value.
   if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
-      Label L;
-      __ testptr(rax, rax);
-      __ jcc(Assembler::zero, L);
-      __ movptr(rax, Address(rax, 0));
-      __ bind(L);
-      __ verify_oop(rax);
+    __ resolve_jobject(rax /* value */,
+                       r15_thread /* thread */,
+                       rcx /* tmp */);
   }
 
   if (CheckJNICalls) {
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Wed Jul 05 23:09:40 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
@@ -1193,16 +1193,16 @@
   // and result handler will pick it up
 
   {
-    Label no_oop, store_result;
+    Label no_oop, not_weak, store_result;
     __ lea(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT)));
     __ cmpptr(t, Address(rbp, frame::interpreter_frame_result_handler_offset*wordSize));
     __ jcc(Assembler::notEqual, no_oop);
     // retrieve result
     __ pop(ltos);
-    __ testptr(rax, rax);
-    __ jcc(Assembler::zero, store_result);
-    __ movptr(rax, Address(rax, 0));
-    __ bind(store_result);
+    // Unbox oop result, e.g. JNIHandles::resolve value.
+    __ resolve_jobject(rax /* value */,
+                       thread /* thread */,
+                       t /* tmp */);
     __ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset*wordSize), rax);
     // keep stack depth as expected by pushing oop which will eventually be discarded
     __ push(ltos);
--- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp	Wed Jul 05 23:09:40 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.
  * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -406,10 +406,12 @@
   // oop_temp where the garbage collector can see it before
   // we release the handle it might be protected by.
   if (handler->result_type() == &ffi_type_pointer) {
-    if (result[0])
-      istate->set_oop_temp(*(oop *) result[0]);
-    else
+    if (result[0] == 0) {
       istate->set_oop_temp(NULL);
+    } else {
+      jobject handle = reinterpret_cast<jobject>(result[0]);
+      istate->set_oop_temp(JNIHandles::resolve(handle));
+    }
   }
 
   // Reset handle block
--- a/hotspot/src/share/vm/Xusage.txt	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/Xusage.txt	Wed Jul 05 23:09:40 2017 +0200
@@ -12,7 +12,7 @@
     -Xms<size>        set initial Java heap size
     -Xmx<size>        set maximum Java heap size
     -Xss<size>        set java thread stack size
-    -Xprof            output cpu profiling data
+    -Xprof            output cpu profiling data (deprecated)
     -Xfuture          enable strictest checks, anticipating future default
     -Xrs              reduce use of OS signals by Java/VM (see documentation)
     -Xcheck:jni       perform additional checks for JNI functions
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1540,7 +1540,7 @@
         ciMethod* caller = state()->scope()->method();
         ciMethodData* md = caller->method_data_or_null();
         ciProfileData* data = md->bci_to_data(invoke_bci);
-        if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) {
+        if (data != NULL && (data->is_CallTypeData() || data->is_VirtualCallTypeData())) {
           bool has_return = data->is_CallTypeData() ? ((ciCallTypeData*)data)->has_return() : ((ciVirtualCallTypeData*)data)->has_return();
           // May not be true in case of an inlined call through a method handle intrinsic.
           if (has_return) {
@@ -1758,7 +1758,7 @@
   start = has_receiver ? 1 : 0;
   if (profile_arguments()) {
     ciProfileData* data = method()->method_data()->bci_to_data(bci());
-    if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) {
+    if (data != NULL && (data->is_CallTypeData() || data->is_VirtualCallTypeData())) {
       n = data->is_CallTypeData() ? data->as_CallTypeData()->number_of_arguments() : data->as_VirtualCallTypeData()->number_of_arguments();
     }
   }
@@ -4349,7 +4349,7 @@
   }
   ciMethodData* md = m->method_data_or_null();
   ciProfileData* data = md->bci_to_data(invoke_bci);
-  if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) {
+  if (data != NULL && (data->is_CallTypeData() || data->is_VirtualCallTypeData())) {
     append(new ProfileReturnType(m , invoke_bci, callee, ret));
   }
 }
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -3262,50 +3262,52 @@
     int bci = x->bci_of_invoke();
     ciMethodData* md = x->method()->method_data_or_null();
     ciProfileData* data = md->bci_to_data(bci);
-    if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) ||
-        (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) {
-      ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset();
-      int base_offset = md->byte_offset_of_slot(data, extra);
-      LIR_Opr mdp = LIR_OprFact::illegalOpr;
-      ciTypeStackSlotEntries* args = data->is_CallTypeData() ? ((ciCallTypeData*)data)->args() : ((ciVirtualCallTypeData*)data)->args();
-
-      Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
-      int start = 0;
-      int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments();
-      if (x->callee()->is_loaded() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
-        // first argument is not profiled at call (method handle invoke)
-        assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected");
-        start = 1;
+    if (data != NULL) {
+      if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) ||
+          (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) {
+        ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset();
+        int base_offset = md->byte_offset_of_slot(data, extra);
+        LIR_Opr mdp = LIR_OprFact::illegalOpr;
+        ciTypeStackSlotEntries* args = data->is_CallTypeData() ? ((ciCallTypeData*)data)->args() : ((ciVirtualCallTypeData*)data)->args();
+
+        Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
+        int start = 0;
+        int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments();
+        if (x->callee()->is_loaded() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
+          // first argument is not profiled at call (method handle invoke)
+          assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected");
+          start = 1;
+        }
+        ciSignature* callee_signature = x->callee()->signature();
+        // method handle call to virtual method
+        bool has_receiver = x->callee()->is_loaded() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
+        ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL);
+
+        bool ignored_will_link;
+        ciSignature* signature_at_call = NULL;
+        x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
+        ciSignatureStream signature_at_call_stream(signature_at_call);
+
+        // if called through method handle invoke, some arguments may have been popped
+        for (int i = 0; i < stop && i+start < x->nb_profiled_args(); i++) {
+          int off = in_bytes(TypeEntriesAtCall::argument_type_offset(i)) - in_bytes(TypeEntriesAtCall::args_data_offset());
+          ciKlass* exact = profile_type(md, base_offset, off,
+              args->type(i), x->profiled_arg_at(i+start), mdp,
+              !x->arg_needs_null_check(i+start),
+              signature_at_call_stream.next_klass(), callee_signature_stream.next_klass());
+          if (exact != NULL) {
+            md->set_argument_type(bci, i, exact);
+          }
+        }
+      } else {
+#ifdef ASSERT
+        Bytecodes::Code code = x->method()->raw_code_at_bci(x->bci_of_invoke());
+        int n = x->nb_profiled_args();
+        assert(MethodData::profile_parameters() && (MethodData::profile_arguments_jsr292_only() ||
+            (x->inlined() && ((code == Bytecodes::_invokedynamic && n <= 1) || (code == Bytecodes::_invokehandle && n <= 2)))),
+            "only at JSR292 bytecodes");
+#endif
       }
-      ciSignature* callee_signature = x->callee()->signature();
-      // method handle call to virtual method
-      bool has_receiver = x->callee()->is_loaded() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
-      ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL);
-
-      bool ignored_will_link;
-      ciSignature* signature_at_call = NULL;
-      x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
-      ciSignatureStream signature_at_call_stream(signature_at_call);
-
-      // if called through method handle invoke, some arguments may have been popped
-      for (int i = 0; i < stop && i+start < x->nb_profiled_args(); i++) {
-        int off = in_bytes(TypeEntriesAtCall::argument_type_offset(i)) - in_bytes(TypeEntriesAtCall::args_data_offset());
-        ciKlass* exact = profile_type(md, base_offset, off,
-                                      args->type(i), x->profiled_arg_at(i+start), mdp,
-                                      !x->arg_needs_null_check(i+start),
-                                      signature_at_call_stream.next_klass(), callee_signature_stream.next_klass());
-        if (exact != NULL) {
-          md->set_argument_type(bci, i, exact);
-        }
-      }
-    } else {
-#ifdef ASSERT
-      Bytecodes::Code code = x->method()->raw_code_at_bci(x->bci_of_invoke());
-      int n = x->nb_profiled_args();
-      assert(MethodData::profile_parameters() && (MethodData::profile_arguments_jsr292_only() ||
-                                                  (x->inlined() && ((code == Bytecodes::_invokedynamic && n <= 1) || (code == Bytecodes::_invokehandle && n <= 2)))),
-             "only at JSR292 bytecodes");
-#endif
     }
   }
 }
@@ -3396,24 +3398,26 @@
   int bci = x->bci_of_invoke();
   ciMethodData* md = x->method()->method_data_or_null();
   ciProfileData* data = md->bci_to_data(bci);
-  assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type");
-  ciReturnTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret();
-  LIR_Opr mdp = LIR_OprFact::illegalOpr;
-
-  bool ignored_will_link;
-  ciSignature* signature_at_call = NULL;
-  x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
-
-  // The offset within the MDO of the entry to update may be too large
-  // to be used in load/store instructions on some platforms. So have
-  // profile_type() compute the address of the profile in a register.
-  ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0,
-                                ret->type(), x->ret(), mdp,
-                                !x->needs_null_check(),
-                                signature_at_call->return_type()->as_klass(),
-                                x->callee()->signature()->return_type()->as_klass());
-  if (exact != NULL) {
-    md->set_return_type(bci, exact);
+  if (data != NULL) {
+    assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type");
+    ciReturnTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret();
+    LIR_Opr mdp = LIR_OprFact::illegalOpr;
+
+    bool ignored_will_link;
+    ciSignature* signature_at_call = NULL;
+    x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
+
+    // The offset within the MDO of the entry to update may be too large
+    // to be used in load/store instructions on some platforms. So have
+    // profile_type() compute the address of the profile in a register.
+    ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0,
+        ret->type(), x->ret(), mdp,
+        !x->needs_null_check(),
+        signature_at_call->return_type()->as_klass(),
+        x->callee()->signature()->return_type()->as_klass());
+    if (exact != NULL) {
+      md->set_return_type(bci, exact);
+    }
   }
 }
 
--- a/hotspot/src/share/vm/ci/ciMethodData.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/ci/ciMethodData.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -408,11 +408,13 @@
   MethodData* mdo = get_MethodData();
   if (mdo != NULL) {
     ProfileData* data = mdo->bci_to_data(bci);
-    if (data->is_CallTypeData()) {
-      data->as_CallTypeData()->set_argument_type(i, k->get_Klass());
-    } else {
-      assert(data->is_VirtualCallTypeData(), "no arguments!");
-      data->as_VirtualCallTypeData()->set_argument_type(i, k->get_Klass());
+    if (data != NULL) {
+      if (data->is_CallTypeData()) {
+        data->as_CallTypeData()->set_argument_type(i, k->get_Klass());
+      } else {
+        assert(data->is_VirtualCallTypeData(), "no arguments!");
+        data->as_VirtualCallTypeData()->set_argument_type(i, k->get_Klass());
+      }
     }
   }
 }
@@ -430,11 +432,13 @@
   MethodData* mdo = get_MethodData();
   if (mdo != NULL) {
     ProfileData* data = mdo->bci_to_data(bci);
-    if (data->is_CallTypeData()) {
-      data->as_CallTypeData()->set_return_type(k->get_Klass());
-    } else {
-      assert(data->is_VirtualCallTypeData(), "no arguments!");
-      data->as_VirtualCallTypeData()->set_return_type(k->get_Klass());
+    if (data != NULL) {
+      if (data->is_CallTypeData()) {
+        data->as_CallTypeData()->set_return_type(k->get_Klass());
+      } else {
+        assert(data->is_VirtualCallTypeData(), "no arguments!");
+        data->as_VirtualCallTypeData()->set_return_type(k->get_Klass());
+      }
     }
   }
 }
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -105,6 +105,12 @@
 
 #define JAVA_9_VERSION                    53
 
+void ClassFileParser::set_class_bad_constant_seen(short bad_constant) {
+  assert((bad_constant == 19 || bad_constant == 20) && _major_version >= JAVA_9_VERSION,
+         "Unexpected bad constant pool entry");
+  if (_bad_constant_seen == 0) _bad_constant_seen = bad_constant;
+}
+
 void ClassFileParser::parse_constant_pool_entries(const ClassFileStream* const stream,
                                                   ConstantPool* cp,
                                                   const int length,
@@ -302,6 +308,18 @@
         }
         break;
       }
+      case 19:
+      case 20: {
+        // Record that an error occurred in these two cases but keep parsing so
+        // that ACC_Module can be checked for in the access_flags.  Need to
+        // throw NoClassDefFoundError in that case.
+        if (_major_version >= JAVA_9_VERSION) {
+          cfs->guarantee_more(3, CHECK);
+          cfs->get_u2_fast();
+          set_class_bad_constant_seen(tag);
+          break;
+        }
+      }
       default: {
         classfile_parse_error("Unknown constant tag %u in class file %s",
                               tag,
@@ -359,14 +377,18 @@
 #endif
 
 void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
-                                          ConstantPool* const cp,
-                                          const int length,
-                                          TRAPS) {
+                                         ConstantPool* const cp,
+                                         const int length,
+                                         TRAPS) {
   assert(cp != NULL, "invariant");
   assert(stream != NULL, "invariant");
 
   // parsing constant pool entries
   parse_constant_pool_entries(stream, cp, length, CHECK);
+  if (class_bad_constant_seen() != 0) {
+    // a bad CP entry has been detected previously so stop parsing and just return.
+    return;
+  }
 
   int index = 1;  // declared outside of loops for portability
 
@@ -1244,6 +1266,10 @@
       }
     } else if (_major_version >= JAVA_1_5_VERSION) {
       if (attribute_name == vmSymbols::tag_signature()) {
+        if (generic_signature_index != 0) {
+          classfile_parse_error(
+            "Multiple Signature attributes for field in class file %s", CHECK);
+        }
         if (attribute_length != 2) {
           classfile_parse_error(
             "Wrong size %u for field's Signature attribute in class file %s",
@@ -2565,6 +2591,11 @@
       }
     } else if (_major_version >= JAVA_1_5_VERSION) {
       if (method_attribute_name == vmSymbols::tag_signature()) {
+        if (generic_signature_index != 0) {
+          classfile_parse_error(
+            "Multiple Signature attributes for method in class file %s",
+            CHECK_NULL);
+        }
         if (method_attribute_length != 2) {
           classfile_parse_error(
             "Invalid Signature attribute length %u in class file %s",
@@ -3284,6 +3315,10 @@
       }
     } else if (_major_version >= JAVA_1_5_VERSION) {
       if (tag == vmSymbols::tag_signature()) {
+        if (_generic_signature_index != 0) {
+          classfile_parse_error(
+            "Multiple Signature attributes in class file %s", CHECK);
+        }
         if (attribute_length != 2) {
           classfile_parse_error(
             "Wrong Signature attribute length %u in class file %s",
@@ -5558,6 +5593,7 @@
   _protection_domain(protection_domain),
   _access_flags(),
   _pub_level(pub_level),
+  _bad_constant_seen(0),
   _synthetic_flag(false),
   _sde_length(false),
   _sde_buffer(NULL),
@@ -5765,9 +5801,15 @@
 
   verify_legal_class_modifiers(flags, CHECK);
 
+  short bad_constant = class_bad_constant_seen();
+  if (bad_constant != 0) {
+    // Do not throw CFE until after the access_flags are checked because if
+    // ACC_MODULE is set in the access flags, then NCDFE must be thrown, not CFE.
+    classfile_parse_error("Unknown constant tag %u in class file %s", bad_constant, CHECK);
+  }
+
   _access_flags.set_flags(flags);
 
-
   // This class and superclass
   _this_class_index = stream->get_u2_fast();
   check_property(
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp	Wed Jul 05 23:09:40 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
@@ -122,6 +122,15 @@
   // for tracing and notifications
   Publicity _pub_level;
 
+  // Used to keep track of whether a constant pool item 19 or 20 is found.  These
+  // correspond to CONSTANT_Module and CONSTANT_Package tags and are not allowed
+  // in regular class files.  For class file version >= 53, a CFE cannot be thrown
+  // immediately when these are seen because a NCDFE must be thrown if the class's
+  // access_flags have ACC_MODULE set.  But, the access_flags haven't been looked
+  // at yet.  So, the bad constant pool item is cached here.  A value of zero
+  // means that no constant pool item 19 or 20 was found.
+  short _bad_constant_seen;
+
   // class attributes parsed before the instance klass is created:
   bool _synthetic_flag;
   int _sde_length;
@@ -161,6 +170,8 @@
   void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS);
   void set_klass(InstanceKlass* instance);
 
+  void set_class_bad_constant_seen(short bad_constant);
+  short class_bad_constant_seen() { return  _bad_constant_seen; }
   void set_class_synthetic_flag(bool x)        { _synthetic_flag = x; }
   void set_class_sourcefile_index(u2 x)        { _sourcefile_index = x; }
   void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
--- a/hotspot/src/share/vm/classfile/moduleEntry.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp	Wed Jul 05 23:09:40 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
@@ -36,8 +36,8 @@
 #include "utilities/ostream.hpp"
 
 #define UNNAMED_MODULE "Unnamed Module"
-#define JAVAPKG "java/"
-#define JAVAPKG_LEN 5
+#define JAVAPKG "java"
+#define JAVAPKG_LEN 4
 #define JAVA_BASE_NAME "java.base"
 
 class ModuleClosure;
--- a/hotspot/src/share/vm/classfile/modules.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/classfile/modules.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -325,7 +325,8 @@
     // Only modules defined to either the boot or platform class loader, can define a "java/" package.
     if (!h_loader.is_null() &&
         !SystemDictionary::is_platform_class_loader(h_loader) &&
-        strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0) {
+        (strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0 &&
+          (package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) {
       const char* class_loader_name = SystemDictionary::loader_name(h_loader());
       size_t pkg_len = strlen(package_name);
       char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len);
@@ -748,7 +749,8 @@
   // Only modules defined to either the boot or platform class loader, can define a "java/" package.
   if (!loader_data->is_the_null_class_loader_data() &&
       !loader_data->is_platform_class_loader_data() &&
-      strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0) {
+      (strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0 &&
+        (package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) {
     const char* class_loader_name = SystemDictionary::loader_name(loader_data);
     size_t pkg_len = strlen(package_name);
     char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len);
--- a/hotspot/src/share/vm/classfile/stringTable.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/classfile/stringTable.cpp	Wed Jul 05 23:09:40 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
@@ -96,10 +96,14 @@
 
 // Pick hashing algorithm
 unsigned int StringTable::hash_string(const jchar* s, int len) {
-  return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) :
+  return use_alternate_hashcode() ? alt_hash_string(s, len) :
                                     java_lang_String::hash_code(s, len);
 }
 
+unsigned int StringTable::alt_hash_string(const jchar* s, int len) {
+  return AltHashing::murmur3_32(seed(), s, len);
+}
+
 unsigned int StringTable::hash_string(oop string) {
   EXCEPTION_MARK;
   if (string == NULL) {
@@ -117,11 +121,10 @@
   }
 }
 
-oop StringTable::lookup_shared(jchar* name, int len) {
-  // java_lang_String::hash_code() was used to compute hash values in the shared table. Don't
-  // use the hash value from StringTable::hash_string() as it might use alternate hashcode.
-  return _shared_table.lookup((const char*)name,
-                              java_lang_String::hash_code(name, len), len);
+oop StringTable::lookup_shared(jchar* name, int len, unsigned int hash) {
+  assert(hash == java_lang_String::hash_code(name, len),
+         "hash must be computed using java_lang_String::hash_code");
+  return _shared_table.lookup((const char*)name, hash, len);
 }
 
 oop StringTable::lookup_in_main_table(int index, jchar* name,
@@ -156,7 +159,7 @@
   unsigned int hashValue;
   int index;
   if (use_alternate_hashcode()) {
-    hashValue = hash_string(name, len);
+    hashValue = alt_hash_string(name, len);
     index = hash_to_index(hashValue);
   } else {
     hashValue = hashValue_arg;
@@ -199,12 +202,15 @@
 }
 
 oop StringTable::lookup(jchar* name, int len) {
-  oop string = lookup_shared(name, len);
+  // shared table always uses java_lang_String::hash_code
+  unsigned int hash = java_lang_String::hash_code(name, len);
+  oop string = lookup_shared(name, len, hash);
   if (string != NULL) {
     return string;
   }
-
-  unsigned int hash = hash_string(name, len);
+  if (use_alternate_hashcode()) {
+    hash = alt_hash_string(name, len);
+  }
   int index = the_table()->hash_to_index(hash);
   string = the_table()->lookup_in_main_table(index, name, len, hash);
 
@@ -215,12 +221,15 @@
 
 oop StringTable::intern(Handle string_or_null, jchar* name,
                         int len, TRAPS) {
-  oop found_string = lookup_shared(name, len);
+  // shared table always uses java_lang_String::hash_code
+  unsigned int hashValue = java_lang_String::hash_code(name, len);
+  oop found_string = lookup_shared(name, len, hashValue);
   if (found_string != NULL) {
     return found_string;
   }
-
-  unsigned int hashValue = hash_string(name, len);
+  if (use_alternate_hashcode()) {
+    hashValue = alt_hash_string(name, len);
+  }
   int index = the_table()->hash_to_index(hashValue);
   found_string = the_table()->lookup_in_main_table(index, name, len, hashValue);
 
--- a/hotspot/src/share/vm/classfile/stringTable.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/classfile/stringTable.hpp	Wed Jul 05 23:09:40 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
@@ -56,7 +56,7 @@
                 unsigned int hashValue, TRAPS);
 
   oop lookup_in_main_table(int index, jchar* chars, int length, unsigned int hashValue);
-  static oop lookup_shared(jchar* name, int len);
+  static oop lookup_shared(jchar* name, int len, unsigned int hash);
 
   // Apply the give oop closure to the entries to the buckets
   // in the range [start_idx, end_idx).
@@ -65,6 +65,13 @@
   // in the range [start_idx, end_idx).
   static void buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, int* processed, int* removed);
 
+  // Hashing algorithm, used as the hash value used by the
+  //     StringTable for bucket selection and comparison (stored in the
+  //     HashtableEntry structures).  This is used in the String.intern() method.
+  static unsigned int hash_string(const jchar* s, int len);
+  static unsigned int hash_string(oop string);
+  static unsigned int alt_hash_string(const jchar* s, int len);
+
   StringTable() : RehashableHashtable<oop, mtSymbol>((int)StringTableSize,
                               sizeof (HashtableEntry<oop, mtSymbol>)) {}
 
@@ -109,12 +116,6 @@
   }
   static void possibly_parallel_oops_do(OopClosure* f);
 
-  // Hashing algorithm, used as the hash value used by the
-  //     StringTable for bucket selection and comparison (stored in the
-  //     HashtableEntry structures).  This is used in the String.intern() method.
-  static unsigned int hash_string(const jchar* s, int len);
-  static unsigned int hash_string(oop string);
-
   // Internal test.
   static void test_alt_hash() PRODUCT_RETURN;
 
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jul 05 23:09:40 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
@@ -561,6 +561,7 @@
   template(int_StringBuffer_signature,                "(I)Ljava/lang/StringBuffer;")                              \
   template(char_StringBuffer_signature,               "(C)Ljava/lang/StringBuffer;")                              \
   template(int_String_signature,                      "(I)Ljava/lang/String;")                                    \
+  template(boolean_boolean_int_signature,             "(ZZ)I")                                                    \
   template(codesource_permissioncollection_signature, "(Ljava/security/CodeSource;Ljava/security/PermissionCollection;)V") \
   /* signature symbols needed by intrinsics */                                                                    \
   VM_INTRINSICS_DO(VM_INTRINSIC_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, template, VM_ALIAS_IGNORE)            \
--- a/hotspot/src/share/vm/compiler/compilerDefinitions.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/compiler/compilerDefinitions.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -100,7 +100,9 @@
     FLAG_SET_ERGO(size_t, MetaspaceSize, 12*M);
   }
   if (FLAG_IS_DEFAULT(MaxRAM)) {
-    FLAG_SET_ERGO(uint64_t, MaxRAM, 1ULL*G);
+    // Do not use FLAG_SET_ERGO to update MaxRAM, as this will impact
+    // heap setting done based on available phys_mem (see Arguments::set_heap_size).
+    FLAG_SET_DEFAULT(MaxRAM, 1ULL*G);
   }
   if (FLAG_IS_DEFAULT(CompileThreshold)) {
     FLAG_SET_ERGO(intx, CompileThreshold, 1500);
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -2456,22 +2456,24 @@
 void InstanceKlass::check_prohibited_package(Symbol* class_name,
                                              Handle class_loader,
                                              TRAPS) {
-  ResourceMark rm(THREAD);
   if (!class_loader.is_null() &&
       !SystemDictionary::is_platform_class_loader(class_loader) &&
-      class_name != NULL &&
-      strncmp(class_name->as_C_string(), JAVAPKG, JAVAPKG_LEN) == 0) {
-    TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name, CHECK);
-    assert(pkg_name != NULL, "Error in parsing package name starting with 'java/'");
-    char* name = pkg_name->as_C_string();
-    const char* class_loader_name = SystemDictionary::loader_name(class_loader());
-    StringUtils::replace_no_expand(name, "/", ".");
-    const char* msg_text1 = "Class loader (instance of): ";
-    const char* msg_text2 = " tried to load prohibited package name: ";
-    size_t len = strlen(msg_text1) + strlen(class_loader_name) + strlen(msg_text2) + strlen(name) + 1;
-    char* message = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, len);
-    jio_snprintf(message, len, "%s%s%s%s", msg_text1, class_loader_name, msg_text2, name);
-    THROW_MSG(vmSymbols::java_lang_SecurityException(), message);
+      class_name != NULL) {
+    ResourceMark rm(THREAD);
+    char* name = class_name->as_C_string();
+    if (strncmp(name, JAVAPKG, JAVAPKG_LEN) == 0 && name[JAVAPKG_LEN] == '/') {
+      TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name, CHECK);
+      assert(pkg_name != NULL, "Error in parsing package name starting with 'java/'");
+      name = pkg_name->as_C_string();
+      const char* class_loader_name = SystemDictionary::loader_name(class_loader());
+      StringUtils::replace_no_expand(name, "/", ".");
+      const char* msg_text1 = "Class loader (instance of): ";
+      const char* msg_text2 = " tried to load prohibited package name: ";
+      size_t len = strlen(msg_text1) + strlen(class_loader_name) + strlen(msg_text2) + strlen(name) + 1;
+      char* message = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, len);
+      jio_snprintf(message, len, "%s%s%s%s", msg_text1, class_loader_name, msg_text2, name);
+      THROW_MSG(vmSymbols::java_lang_SecurityException(), message);
+    }
   }
   return;
 }
--- a/hotspot/src/share/vm/opto/arraycopynode.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/arraycopynode.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -225,7 +225,6 @@
   Node* dest = in(ArrayCopyNode::Dest);
   const Type* src_type = phase->type(src);
   const TypeAryPtr* ary_src = src_type->isa_aryptr();
-  assert(ary_src != NULL, "should be an array copy/clone");
 
   if (is_arraycopy() || is_copyofrange() || is_copyof()) {
     const Type* dest_type = phase->type(dest);
@@ -286,7 +285,8 @@
 
     copy_type = dest_elem;
   } else {
-    assert (is_clonebasic(), "should be");
+    assert(ary_src != NULL, "should be a clone");
+    assert(is_clonebasic(), "should be");
 
     disjoint_bases = true;
     assert(src->is_AddP(), "should be base + off");
--- a/hotspot/src/share/vm/opto/callnode.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/callnode.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -784,8 +784,8 @@
       }
       // May modify (by reflection) if an boxing object is passed
       // as argument or returned.
-      if (returns_pointer() && (proj_out(TypeFunc::Parms) != NULL)) {
-        Node* proj = proj_out(TypeFunc::Parms);
+      Node* proj = returns_pointer() ? proj_out(TypeFunc::Parms) : NULL;
+      if (proj != NULL) {
         const TypeInstPtr* inst_t = phase->type(proj)->isa_instptr();
         if ((inst_t != NULL) && (!inst_t->klass_is_exact() ||
                                  (inst_t->klass() == boxing_klass))) {
--- a/hotspot/src/share/vm/opto/castnode.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/castnode.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -225,7 +225,10 @@
   }
 
   // Similar to ConvI2LNode::Ideal() for the same reasons
-  if (can_reshape && !phase->C->major_progress()) {
+  // Do not narrow the type of range check dependent CastIINodes to
+  // avoid corruption of the graph if a CastII is replaced by TOP but
+  // the corresponding range check is not removed.
+  if (can_reshape && !_range_check_dependency && !phase->C->major_progress()) {
     const TypeInt* this_type = this->type()->is_int();
     const TypeInt* in_type = phase->type(in(1))->isa_int();
     if (in_type != NULL && this_type != NULL &&
--- a/hotspot/src/share/vm/opto/convertnode.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/convertnode.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -294,8 +294,7 @@
   }
 
 #ifdef _LP64
-  // Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y)) or
-  // ConvI2L(CastII(AddI(x, y))) to AddL(ConvI2L(CastII(x)), ConvI2L(CastII(y))),
+  // Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y))
   // but only if x and y have subranges that cannot cause 32-bit overflow,
   // under the assumption that x+y is in my own subrange this->type().
 
@@ -319,13 +318,6 @@
 
   Node* z = in(1);
   int op = z->Opcode();
-  Node* ctrl = NULL;
-  if (op == Op_CastII && z->as_CastII()->has_range_check()) {
-    // Skip CastII node but save control dependency
-    ctrl = z->in(0);
-    z = z->in(1);
-    op = z->Opcode();
-  }
   if (op == Op_AddI || op == Op_SubI) {
     Node* x = z->in(1);
     Node* y = z->in(2);
@@ -385,8 +377,8 @@
     }
     assert(rxlo == (int)rxlo && rxhi == (int)rxhi, "x should not overflow");
     assert(rylo == (int)rylo && ryhi == (int)ryhi, "y should not overflow");
-    Node* cx = phase->C->constrained_convI2L(phase, x, TypeInt::make(rxlo, rxhi, widen), ctrl);
-    Node* cy = phase->C->constrained_convI2L(phase, y, TypeInt::make(rylo, ryhi, widen), ctrl);
+    Node* cx = phase->C->constrained_convI2L(phase, x, TypeInt::make(rxlo, rxhi, widen), NULL);
+    Node* cy = phase->C->constrained_convI2L(phase, y, TypeInt::make(rylo, ryhi, widen), NULL);
     switch (op) {
       case Op_AddI:  return new AddLNode(cx, cy);
       case Op_SubI:  return new SubLNode(cx, cy);
--- a/hotspot/src/share/vm/opto/ifnode.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/ifnode.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -249,6 +249,13 @@
       predicate_proj = proj;
     }
   }
+
+  // If all the defs of the phi are the same constant, we already have the desired end state.
+  // Skip the split that would create empty phi and region nodes.
+  if((r->req() - req_c) == 1) {
+    return NULL;
+  }
+
   if (nb_predicate_proj > 1) {
     // Can happen in case of loop unswitching and when the loop is
     // optimized out: it's not a loop anymore so we don't care about
@@ -1458,8 +1465,9 @@
   // be skipped. For example, range check predicate has two checks
   // for lower and upper bounds.
   ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj();
-  if (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL)
-   prev_dom = idom;
+  if ((unc_proj != NULL) && (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL)) {
+    prev_dom = idom;
+  }
 
   // Now walk the current IfNode's projections.
   // Loop ends when 'this' has no more uses.
--- a/hotspot/src/share/vm/opto/lcm.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/lcm.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -254,10 +254,12 @@
       const TypePtr *adr_type = NULL;  // Do not need this return value here
       const Node* base = mach->get_base_and_disp(offset, adr_type);
       if (base == NULL || base == NodeSentinel) {
-        // Narrow oop address doesn't have base, only index
-        if( val->bottom_type()->isa_narrowoop() &&
-            MacroAssembler::needs_explicit_null_check(offset) )
-          continue;             // Give up if offset is beyond page size
+        // Narrow oop address doesn't have base, only index.
+        // Give up if offset is beyond page size or if heap base is not protected.
+        if (val->bottom_type()->isa_narrowoop() &&
+            (MacroAssembler::needs_explicit_null_check(offset) ||
+             !Universe::narrow_oop_use_implicit_null_checks()))
+          continue;
         // cannot reason about it; is probably not implicit null exception
       } else {
         const TypePtr* tptr;
@@ -269,12 +271,17 @@
           // only regular oops are expected here
           tptr = base->bottom_type()->is_ptr();
         }
-        // Give up if offset is not a compile-time constant
-        if( offset == Type::OffsetBot || tptr->_offset == Type::OffsetBot )
+        // Give up if offset is not a compile-time constant.
+        if (offset == Type::OffsetBot || tptr->_offset == Type::OffsetBot)
           continue;
         offset += tptr->_offset; // correct if base is offseted
-        if( MacroAssembler::needs_explicit_null_check(offset) )
-          continue;             // Give up is reference is beyond 4K page size
+        // Give up if reference is beyond page size.
+        if (MacroAssembler::needs_explicit_null_check(offset))
+          continue;
+        // Give up if base is a decode node and the heap base is not protected.
+        if (base->is_Mach() && base->as_Mach()->ideal_Opcode() == Op_DecodeN &&
+            !Universe::narrow_oop_use_implicit_null_checks())
+          continue;
       }
     }
 
--- a/hotspot/src/share/vm/opto/library_call.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -2372,10 +2372,10 @@
   // the barriers get omitted and the unsafe reference begins to "pollute"
   // the alias analysis of the rest of the graph, either Compile::can_alias
   // or Compile::must_alias will throw a diagnostic assert.)
-  bool need_mem_bar;
+  bool need_mem_bar = false;
   switch (kind) {
       case Relaxed:
-          need_mem_bar = mismatched || can_access_non_heap;
+          need_mem_bar = mismatched && !adr_type->isa_aryptr();
           break;
       case Opaque:
           // Opaque uses CPUOrder membars for protection against code movement.
--- a/hotspot/src/share/vm/opto/loopTransform.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -3174,6 +3174,11 @@
     return false;
   }
 
+  Node* exit = head->loopexit()->proj_out(0);
+  if (exit == NULL) {
+    return false;
+  }
+
 #ifndef PRODUCT
   if (TraceLoopOpts) {
     tty->print("ArrayFill    ");
@@ -3281,7 +3286,6 @@
 */
 
   // Redirect the old control and memory edges that are outside the loop.
-  Node* exit = head->loopexit()->proj_out(0);
   // Sometimes the memory phi of the head is used as the outgoing
   // state of the loop.  It's safe in this case to replace it with the
   // result_mem.
--- a/hotspot/src/share/vm/opto/parse2.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/parse2.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -826,6 +826,9 @@
     ciMethodData* methodData = method()->method_data();
     if (!methodData->is_mature())  return PROB_UNKNOWN;
     ciProfileData* data = methodData->bci_to_data(bci());
+    if (data == NULL) {
+      return PROB_UNKNOWN;
+    }
     if (!data->is_JumpData())  return PROB_UNKNOWN;
 
     // get taken and not taken values
@@ -917,8 +920,8 @@
         // of the OSR-ed method, and we want to deopt to gather more stats.
         // If you have ANY counts, then this loop is simply 'cold' relative
         // to the OSR loop.
-        if (data->as_BranchData()->taken() +
-            data->as_BranchData()->not_taken() == 0 ) {
+        if (data == NULL ||
+            (data->as_BranchData()->taken() +  data->as_BranchData()->not_taken() == 0)) {
           // This is the only way to return PROB_UNKNOWN:
           return PROB_UNKNOWN;
         }
--- a/hotspot/src/share/vm/opto/stringopts.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/opto/stringopts.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -891,8 +891,9 @@
       ctrl_path.push(cn);
       ctrl_path.push(cn->proj_out(0));
       ctrl_path.push(cn->proj_out(0)->unique_out());
-      if (cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0) != NULL) {
-        ctrl_path.push(cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0));
+      Node* catchproj = cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0);
+      if (catchproj != NULL) {
+        ctrl_path.push(catchproj);
       }
     } else {
       ShouldNotReachHere();
--- a/hotspot/src/share/vm/prims/jni.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/prims/jni.cpp	Wed Jul 05 23:09:40 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.
  * Copyright (c) 2012 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -935,8 +935,7 @@
   inline void get_long()   { _arguments->push_long(va_arg(_ap, jlong)); }
   inline void get_float()  { _arguments->push_float((jfloat)va_arg(_ap, jdouble)); } // float is coerced to double w/ va_arg
   inline void get_double() { _arguments->push_double(va_arg(_ap, jdouble)); }
-  inline void get_object() { jobject l = va_arg(_ap, jobject);
-                             _arguments->push_oop(Handle((oop *)l, false)); }
+  inline void get_object() { _arguments->push_jobject(va_arg(_ap, jobject)); }
 
   inline void set_ap(va_list rap) {
     va_copy(_ap, rap);
@@ -1025,7 +1024,7 @@
   inline void get_long()   { _arguments->push_long((_ap++)->j);  }
   inline void get_float()  { _arguments->push_float((_ap++)->f); }
   inline void get_double() { _arguments->push_double((_ap++)->d);}
-  inline void get_object() { _arguments->push_oop(Handle((oop *)(_ap++)->l, false)); }
+  inline void get_object() { _arguments->push_jobject((_ap++)->l); }
 
   inline void set_ap(const jvalue *rap) { _ap = rap; }
 
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Wed Jul 05 23:09:40 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
@@ -1796,6 +1796,13 @@
     }
   }
 
+  if (initial_object != NULL) {
+    oop init_obj = JNIHandles::resolve_external_guard(initial_object);
+    if (init_obj == NULL) {
+      return JVMTI_ERROR_INVALID_OBJECT;
+    }
+  }
+
   Thread *thread = Thread::current();
   HandleMark hm(thread);
   KlassHandle kh (thread, k_oop);
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -2856,6 +2856,10 @@
       if (res != JNI_OK) {
         return res;
       }
+    } else if (match_option(option, "--permit-illegal-access")) {
+      if (!create_property("jdk.module.permitIllegalAccess", "true", ExternalProperty)) {
+        return JNI_ENOMEM;
+      }
     // -agentlib and -agentpath
     } else if (match_option(option, "-agentlib:", &tail) ||
           (is_absolute_path = match_option(option, "-agentpath:", &tail))) {
@@ -3098,6 +3102,7 @@
     // -Xprof
     } else if (match_option(option, "-Xprof")) {
 #if INCLUDE_FPROF
+      log_warning(arguments)("Option -Xprof was deprecated in version 9 and will likely be removed in a future release.");
       _has_profile = true;
 #else // INCLUDE_FPROF
       jio_fprintf(defaultStream::error_stream(),
--- a/hotspot/src/share/vm/runtime/java.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/runtime/java.cpp	Wed Jul 05 23:09:40 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
@@ -621,6 +621,13 @@
   }
 }
 
+void vm_exit_during_initialization() {
+  vm_notify_during_shutdown(NULL, NULL);
+
+  // Failure during initialization, we don't want to dump core
+  vm_abort(false);
+}
+
 void vm_exit_during_initialization(Handle exception) {
   tty->print_cr("Error occurred during initialization of VM");
   // If there are exceptions on this thread it must be cleared
--- a/hotspot/src/share/vm/runtime/java.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/runtime/java.hpp	Wed Jul 05 23:09:40 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
@@ -45,6 +45,7 @@
 extern void notify_vm_shutdown();
 
 // VM exit if error occurs during initialization of VM
+extern void vm_exit_during_initialization();
 extern void vm_exit_during_initialization(Handle exception);
 extern void vm_exit_during_initialization(Symbol* exception_name, const char* message);
 extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
--- a/hotspot/src/share/vm/runtime/javaCalls.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/runtime/javaCalls.cpp	Wed Jul 05 23:09:40 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
@@ -328,9 +328,9 @@
 // Verify the arguments
 
   if (CheckJNICalls)  {
-    args->verify(method, result->get_type(), thread);
+    args->verify(method, result->get_type());
   }
-  else debug_only(args->verify(method, result->get_type(), thread));
+  else debug_only(args->verify(method, result->get_type()));
 #if INCLUDE_JVMCI
   }
 #else
@@ -442,12 +442,43 @@
 //--------------------------------------------------------------------------------------
 // Implementation of JavaCallArguments
 
+inline bool is_value_state_indirect_oop(uint state) {
+  assert(state != JavaCallArguments::value_state_oop,
+         "Checking for handles after removal");
+  assert(state < JavaCallArguments::value_state_limit,
+         "Invalid value state %u", state);
+  return state != JavaCallArguments::value_state_primitive;
+}
+
+inline oop resolve_indirect_oop(intptr_t value, uint state) {
+  switch (state) {
+  case JavaCallArguments::value_state_handle:
+  {
+    oop* ptr = reinterpret_cast<oop*>(value);
+    return Handle::raw_resolve(ptr);
+  }
+
+  case JavaCallArguments::value_state_jobject:
+  {
+    jobject obj = reinterpret_cast<jobject>(value);
+    return JNIHandles::resolve(obj);
+  }
+
+  default:
+    ShouldNotReachHere();
+    return NULL;
+  }
+}
+
 intptr_t* JavaCallArguments::parameters() {
   // First convert all handles to oops
   for(int i = 0; i < _size; i++) {
-    if (_is_oop[i]) {
-      // Handle conversion
-      _value[i] = cast_from_oop<intptr_t>(Handle::raw_resolve((oop *)_value[i]));
+    uint state = _value_state[i];
+    assert(state != value_state_oop, "Multiple handle conversions");
+    if (is_value_state_indirect_oop(state)) {
+      oop obj = resolve_indirect_oop(_value[i], state);
+      _value[i] = cast_from_oop<intptr_t>(obj);
+      _value_state[i] = value_state_oop;
     }
   }
   // Return argument vector
@@ -457,30 +488,42 @@
 
 class SignatureChekker : public SignatureIterator {
  private:
-   bool *_is_oop;
-   int   _pos;
+   int _pos;
    BasicType _return_type;
-   intptr_t*   _value;
-   Thread* _thread;
+   u_char* _value_state;
+   intptr_t* _value;
 
  public:
   bool _is_return;
 
-  SignatureChekker(Symbol* signature, BasicType return_type, bool is_static, bool* is_oop, intptr_t* value, Thread* thread) : SignatureIterator(signature) {
-    _is_oop = is_oop;
-    _is_return = false;
-    _return_type = return_type;
-    _pos = 0;
-    _value = value;
-    _thread = thread;
-
+  SignatureChekker(Symbol* signature,
+                   BasicType return_type,
+                   bool is_static,
+                   u_char* value_state,
+                   intptr_t* value) :
+    SignatureIterator(signature),
+    _pos(0),
+    _return_type(return_type),
+    _value_state(value_state),
+    _value(value),
+    _is_return(false)
+  {
     if (!is_static) {
       check_value(true); // Receiver must be an oop
     }
   }
 
   void check_value(bool type) {
-    guarantee(_is_oop[_pos++] == type, "signature does not match pushed arguments");
+    uint state = _value_state[_pos++];
+    if (type) {
+      guarantee(is_value_state_indirect_oop(state),
+                "signature does not match pushed arguments: %u at %d",
+                state, _pos - 1);
+    } else {
+      guarantee(state == JavaCallArguments::value_state_primitive,
+                "signature does not match pushed arguments: %u at %d",
+                state, _pos - 1);
+    }
   }
 
   void check_doing_return(bool state) { _is_return = state; }
@@ -515,24 +558,20 @@
       return;
     }
 
-    // verify handle and the oop pointed to by handle
-    int p = _pos;
-    bool bad = false;
-    // If argument is oop
-    if (_is_oop[p]) {
-      intptr_t v = _value[p];
-      if (v != 0 ) {
-        size_t t = (size_t)v;
-        bad = (t < (size_t)os::vm_page_size() ) || !Handle::raw_resolve((oop *)v)->is_oop_or_null(true);
-        if (CheckJNICalls && bad) {
-          ReportJNIFatalError((JavaThread*)_thread, "Bad JNI oop argument");
-        }
-      }
-      // for the regular debug case.
-      assert(!bad, "Bad JNI oop argument");
+    intptr_t v = _value[_pos];
+    if (v != 0) {
+      // v is a "handle" referring to an oop, cast to integral type.
+      // There shouldn't be any handles in very low memory.
+      guarantee((size_t)v >= (size_t)os::vm_page_size(),
+                "Bad JNI oop argument %d: " PTR_FORMAT, _pos, v);
+      // Verify the pointee.
+      oop vv = resolve_indirect_oop(v, _value_state[_pos]);
+      guarantee(vv->is_oop_or_null(true),
+                "Bad JNI oop argument %d: " PTR_FORMAT " -> " PTR_FORMAT,
+                _pos, v, p2i(vv));
     }
 
-    check_value(true);
+    check_value(true);          // Verify value state.
   }
 
   void do_bool()                       { check_int(T_BOOLEAN);       }
@@ -549,8 +588,7 @@
 };
 
 
-void JavaCallArguments::verify(const methodHandle& method, BasicType return_type,
-  Thread *thread) {
+void JavaCallArguments::verify(const methodHandle& method, BasicType return_type) {
   guarantee(method->size_of_parameters() == size_of_parameters(), "wrong no. of arguments pushed");
 
   // Treat T_OBJECT and T_ARRAY as the same
@@ -559,7 +597,11 @@
   // Check that oop information is correct
   Symbol* signature = method->signature();
 
-  SignatureChekker sc(signature, return_type, method->is_static(),_is_oop, _value, thread);
+  SignatureChekker sc(signature,
+                      return_type,
+                      method->is_static(),
+                      _value_state,
+                      _value);
   sc.iterate_parameters();
   sc.check_doing_return(true);
   sc.iterate_returntype();
--- a/hotspot/src/share/vm/runtime/javaCalls.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/runtime/javaCalls.hpp	Wed Jul 05 23:09:40 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
@@ -80,11 +80,11 @@
    _default_size = 8    // Must be at least # of arguments in JavaCalls methods
   };
 
-  intptr_t    _value_buffer [_default_size + 1];
-  bool        _is_oop_buffer[_default_size + 1];
+  intptr_t    _value_buffer      [_default_size + 1];
+  u_char      _value_state_buffer[_default_size + 1];
 
   intptr_t*   _value;
-  bool*       _is_oop;
+  u_char*     _value_state;
   int         _size;
   int         _max_size;
   bool        _start_at_zero;      // Support late setting of receiver
@@ -92,8 +92,8 @@
 
   void initialize() {
     // Starts at first element to support set_receiver.
-    _value    = &_value_buffer[1];
-    _is_oop   = &_is_oop_buffer[1];
+    _value       = &_value_buffer[1];
+    _value_state = &_value_state_buffer[1];
 
     _max_size = _default_size;
     _size = 0;
@@ -101,6 +101,23 @@
     JVMCI_ONLY(_alternative_target = NULL;)
   }
 
+  // Helper for push_oop and the like.  The value argument is a
+  // "handle" that refers to an oop.  We record the address of the
+  // handle rather than the designated oop.  The handle is later
+  // resolved to the oop by parameters().  This delays the exposure of
+  // naked oops until it is GC-safe.
+  template<typename T>
+  inline int push_oop_impl(T handle, int size) {
+    // JNITypes::put_obj expects an oop value, so we play fast and
+    // loose with the type system.  The cast from handle type to oop
+    // *must* use a C-style cast.  In a product build it performs a
+    // reinterpret_cast. In a debug build (more accurately, in a
+    // CHECK_UNHANDLED_OOPS build) it performs a static_cast, invoking
+    // the debug-only oop class's conversion from void* constructor.
+    JNITypes::put_obj((oop)handle, _value, size); // Updates size.
+    return size;                // Return the updated size.
+  }
+
  public:
   JavaCallArguments() { initialize(); }
 
@@ -111,11 +128,12 @@
 
   JavaCallArguments(int max_size) {
     if (max_size > _default_size) {
-      _value  = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1);
-      _is_oop = NEW_RESOURCE_ARRAY(bool, max_size + 1);
+      _value = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1);
+      _value_state = NEW_RESOURCE_ARRAY(u_char, max_size + 1);
 
-      // Reserve room for potential receiver in value and is_oop
-      _value++; _is_oop++;
+      // Reserve room for potential receiver in value and state
+      _value++;
+      _value_state++;
 
       _max_size = max_size;
       _size = 0;
@@ -136,25 +154,52 @@
   }
 #endif
 
-  inline void push_oop(Handle h)    { _is_oop[_size] = true;
-                               JNITypes::put_obj((oop)h.raw_value(), _value, _size); }
+  // The possible values for _value_state elements.
+  enum {
+    value_state_primitive,
+    value_state_oop,
+    value_state_handle,
+    value_state_jobject,
+    value_state_limit
+  };
 
-  inline void push_int(int i)       { _is_oop[_size] = false;
-                               JNITypes::put_int(i, _value, _size); }
+  inline void push_oop(Handle h) {
+    _value_state[_size] = value_state_handle;
+    _size = push_oop_impl(h.raw_value(), _size);
+  }
+
+  inline void push_jobject(jobject h) {
+    _value_state[_size] = value_state_jobject;
+    _size = push_oop_impl(h, _size);
+  }
 
-  inline void push_double(double d) { _is_oop[_size] = false; _is_oop[_size + 1] = false;
-                               JNITypes::put_double(d, _value, _size); }
+  inline void push_int(int i) {
+    _value_state[_size] = value_state_primitive;
+    JNITypes::put_int(i, _value, _size);
+  }
+
+  inline void push_double(double d) {
+    _value_state[_size] = value_state_primitive;
+    _value_state[_size + 1] = value_state_primitive;
+    JNITypes::put_double(d, _value, _size);
+  }
 
-  inline void push_long(jlong l)    { _is_oop[_size] = false; _is_oop[_size + 1] = false;
-                               JNITypes::put_long(l, _value, _size); }
+  inline void push_long(jlong l) {
+    _value_state[_size] = value_state_primitive;
+    _value_state[_size + 1] = value_state_primitive;
+    JNITypes::put_long(l, _value, _size);
+  }
 
-  inline void push_float(float f)   { _is_oop[_size] = false;
-                               JNITypes::put_float(f, _value, _size); }
+  inline void push_float(float f) {
+    _value_state[_size] = value_state_primitive;
+    JNITypes::put_float(f, _value, _size);
+  }
 
   // receiver
   Handle receiver() {
     assert(_size > 0, "must at least be one argument");
-    assert(_is_oop[0], "first argument must be an oop");
+    assert(_value_state[0] == value_state_handle,
+           "first argument must be an oop");
     assert(_value[0] != 0, "receiver must be not-null");
     return Handle((oop*)_value[0], false);
   }
@@ -162,11 +207,11 @@
   void set_receiver(Handle h) {
     assert(_start_at_zero == false, "can only be called once");
     _start_at_zero = true;
-    _is_oop--;
+    _value_state--;
     _value--;
     _size++;
-    _is_oop[0] = true;
-    _value[0] = (intptr_t)h.raw_value();
+    _value_state[0] = value_state_handle;
+    push_oop_impl(h.raw_value(), 0);
   }
 
   // Converts all Handles to oops, and returns a reference to parameter vector
@@ -174,7 +219,7 @@
   int   size_of_parameters() const { return _size; }
 
   // Verify that pushed arguments fits a given method
-  void verify(const methodHandle& method, BasicType return_type, Thread *thread);
+  void verify(const methodHandle& method, BasicType return_type);
 };
 
 // All calls to Java have to go via JavaCalls. Sets up the stack frame
--- a/hotspot/src/share/vm/runtime/jniHandles.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/runtime/jniHandles.cpp	Wed Jul 05 23:09:40 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
@@ -31,6 +31,9 @@
 #include "runtime/jniHandles.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/thread.inline.hpp"
+#if INCLUDE_ALL_GCS
+#include "gc/g1/g1SATBCardTableModRefBS.hpp"
+#endif
 
 JNIHandleBlock* JNIHandles::_global_handles       = NULL;
 JNIHandleBlock* JNIHandles::_weak_global_handles  = NULL;
@@ -92,28 +95,48 @@
   jobject res = NULL;
   if (!obj.is_null()) {
     // ignore null handles
-    MutexLocker ml(JNIGlobalHandle_lock);
-    assert(Universe::heap()->is_in_reserved(obj()), "sanity check");
-    res = _weak_global_handles->allocate_handle(obj());
+    {
+      MutexLocker ml(JNIGlobalHandle_lock);
+      assert(Universe::heap()->is_in_reserved(obj()), "sanity check");
+      res = _weak_global_handles->allocate_handle(obj());
+    }
+    // Add weak tag.
+    assert(is_ptr_aligned(res, weak_tag_alignment), "invariant");
+    char* tptr = reinterpret_cast<char*>(res) + weak_tag_value;
+    res = reinterpret_cast<jobject>(tptr);
   } else {
     CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
   }
   return res;
 }
 
+template<bool external_guard>
+oop JNIHandles::resolve_jweak(jweak handle) {
+  assert(is_jweak(handle), "precondition");
+  oop result = jweak_ref(handle);
+  result = guard_value<external_guard>(result);
+#if INCLUDE_ALL_GCS
+  if (result != NULL && UseG1GC) {
+    G1SATBCardTableModRefBS::enqueue(result);
+  }
+#endif // INCLUDE_ALL_GCS
+  return result;
+}
+
+template oop JNIHandles::resolve_jweak<true>(jweak);
+template oop JNIHandles::resolve_jweak<false>(jweak);
 
 void JNIHandles::destroy_global(jobject handle) {
   if (handle != NULL) {
     assert(is_global_handle(handle), "Invalid delete of global JNI handle");
-    *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it
+    jobject_ref(handle) = deleted_handle();
   }
 }
 
 
 void JNIHandles::destroy_weak_global(jobject handle) {
   if (handle != NULL) {
-    assert(!CheckJNICalls || is_weak_global_handle(handle), "Invalid delete of weak global JNI handle");
-    *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it
+    jweak_ref(handle) = deleted_handle();
   }
 }
 
--- a/hotspot/src/share/vm/runtime/jniHandles.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/runtime/jniHandles.hpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,28 @@
   static JNIHandleBlock* _weak_global_handles;        // First weak global handle block
   static oop _deleted_handle;                         // Sentinel marking deleted handles
 
+  inline static bool is_jweak(jobject handle);
+  inline static oop& jobject_ref(jobject handle); // NOT jweak!
+  inline static oop& jweak_ref(jobject handle);
+
+  template<bool external_guard> inline static oop guard_value(oop value);
+  template<bool external_guard> inline static oop resolve_impl(jobject handle);
+  template<bool external_guard> static oop resolve_jweak(jweak handle);
+
  public:
+  // Low tag bit in jobject used to distinguish a jweak.  jweak is
+  // type equivalent to jobject, but there are places where we need to
+  // be able to distinguish jweak values from other jobjects, and
+  // is_weak_global_handle is unsuitable for performance reasons.  To
+  // provide such a test we add weak_tag_value to the (aligned) byte
+  // address designated by the jobject to produce the corresponding
+  // jweak.  Accessing the value of a jobject must account for it
+  // being a possibly offset jweak.
+  static const uintptr_t weak_tag_size = 1;
+  static const uintptr_t weak_tag_alignment = (1u << weak_tag_size);
+  static const uintptr_t weak_tag_mask = weak_tag_alignment - 1;
+  static const int weak_tag_value = 1;
+
   // Resolve handle into oop
   inline static oop resolve(jobject handle);
   // Resolve externally provided handle into oop with some guards
@@ -176,36 +197,85 @@
   #endif
 };
 
+inline bool JNIHandles::is_jweak(jobject handle) {
+  STATIC_ASSERT(weak_tag_size == 1);
+  STATIC_ASSERT(weak_tag_value == 1);
+  return (reinterpret_cast<uintptr_t>(handle) & weak_tag_mask) != 0;
+}
+
+inline oop& JNIHandles::jobject_ref(jobject handle) {
+  assert(!is_jweak(handle), "precondition");
+  return *reinterpret_cast<oop*>(handle);
+}
+
+inline oop& JNIHandles::jweak_ref(jobject handle) {
+  assert(is_jweak(handle), "precondition");
+  char* ptr = reinterpret_cast<char*>(handle) - weak_tag_value;
+  return *reinterpret_cast<oop*>(ptr);
+}
+
+// external_guard is true if called from resolve_external_guard.
+// Treat deleted (and possibly zapped) as NULL for external_guard,
+// else as (asserted) error.
+template<bool external_guard>
+inline oop JNIHandles::guard_value(oop value) {
+  if (!external_guard) {
+    assert(value != badJNIHandle, "Pointing to zapped jni handle area");
+    assert(value != deleted_handle(), "Used a deleted global handle");
+  } else if ((value == badJNIHandle) || (value == deleted_handle())) {
+    value = NULL;
+  }
+  return value;
+}
+
+// external_guard is true if called from resolve_external_guard.
+template<bool external_guard>
+inline oop JNIHandles::resolve_impl(jobject handle) {
+  assert(handle != NULL, "precondition");
+  oop result;
+  if (is_jweak(handle)) {       // Unlikely
+    result = resolve_jweak<external_guard>(handle);
+  } else {
+    result = jobject_ref(handle);
+    // Construction of jobjects canonicalize a null value into a null
+    // jobject, so for non-jweak the pointee should never be null.
+    assert(external_guard || result != NULL,
+           "Invalid value read from jni handle");
+    result = guard_value<external_guard>(result);
+  }
+  return result;
+}
 
 inline oop JNIHandles::resolve(jobject handle) {
-  oop result = (handle == NULL ? (oop)NULL : *(oop*)handle);
-  assert(result != NULL || (handle == NULL || !CheckJNICalls || is_weak_global_handle(handle)), "Invalid value read from jni handle");
-  assert(result != badJNIHandle, "Pointing to zapped jni handle area");
+  oop result = NULL;
+  if (handle != NULL) {
+    result = resolve_impl<false /* external_guard */ >(handle);
+  }
   return result;
-};
-
+}
 
+// Resolve some erroneous cases to NULL, rather than treating them as
+// possibly unchecked errors.  In particular, deleted handles are
+// treated as NULL (though a deleted and later reallocated handle
+// isn't detected).
 inline oop JNIHandles::resolve_external_guard(jobject handle) {
-  if (handle == NULL) return NULL;
-  oop result = *(oop*)handle;
-  if (result == NULL || result == badJNIHandle) return NULL;
+  oop result = NULL;
+  if (handle != NULL) {
+    result = resolve_impl<true /* external_guard */ >(handle);
+  }
   return result;
-};
-
+}
 
 inline oop JNIHandles::resolve_non_null(jobject handle) {
   assert(handle != NULL, "JNI handle should not be null");
-  oop result = *(oop*)handle;
-  assert(result != NULL, "Invalid value read from jni handle");
-  assert(result != badJNIHandle, "Pointing to zapped jni handle area");
-  // Don't let that private _deleted_handle object escape into the wild.
-  assert(result != deleted_handle(), "Used a deleted global handle.");
+  oop result = resolve_impl<false /* external_guard */ >(handle);
+  assert(result != NULL, "NULL read from jni handle");
   return result;
-};
+}
 
 inline void JNIHandles::destroy_local(jobject handle) {
   if (handle != NULL) {
-    *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it
+    jobject_ref(handle) = deleted_handle();
   }
 }
 
--- a/hotspot/src/share/vm/runtime/mutexLocker.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -181,13 +181,13 @@
   }
   if (UseG1GC) {
 
-    def(SATB_Q_FL_lock             , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);
-    def(SATB_Q_CBL_mon             , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_never);
-    def(Shared_SATB_Q_lock         , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_never);
+    def(SATB_Q_FL_lock             , PaddedMutex  , special  ,   true,  Monitor::_safepoint_check_never);
+    def(SATB_Q_CBL_mon             , PaddedMonitor, leaf - 1 ,   true,  Monitor::_safepoint_check_never);
+    def(Shared_SATB_Q_lock         , PaddedMutex  , leaf - 1 ,   true,  Monitor::_safepoint_check_never);
 
-    def(DirtyCardQ_FL_lock         , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);
-    def(DirtyCardQ_CBL_mon         , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_never);
-    def(Shared_DirtyCardQ_lock     , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_never);
+    def(DirtyCardQ_FL_lock         , PaddedMutex  , special  ,   true,  Monitor::_safepoint_check_never);
+    def(DirtyCardQ_CBL_mon         , PaddedMonitor, leaf - 1 ,   true,  Monitor::_safepoint_check_never);
+    def(Shared_DirtyCardQ_lock     , PaddedMutex  , leaf - 1 ,   true,  Monitor::_safepoint_check_never);
 
     def(FreeList_lock              , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
     def(SecondaryFreeList_lock     , PaddedMonitor, leaf     ,   true,  Monitor::_safepoint_check_never);
--- a/hotspot/src/share/vm/runtime/thread.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Jul 05 23:09:40 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
@@ -3409,9 +3409,16 @@
   Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
   instanceKlassHandle klass (THREAD, k);
 
-  JavaValue result(T_VOID);
+  JavaValue result(T_INT);
+  JavaCallArguments args;
+  args.push_int(DisplayVMOutputToStderr);
+  args.push_int(log_is_enabled(Debug, init)); // print stack trace if exception thrown
   JavaCalls::call_static(&result, klass, vmSymbols::initPhase2_name(),
-                                         vmSymbols::void_method_signature(), CHECK);
+                                         vmSymbols::boolean_boolean_int_signature(), &args, CHECK);
+  if (result.get_jint() != JNI_OK) {
+    vm_exit_during_initialization(); // no message or exception
+  }
+
   universe_post_module_init();
 }
 
--- a/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2009, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -300,6 +300,7 @@
       not_null, merge);
 
     builder()->SetInsertPoint(not_null);
+#error Needs to be updated for tagged jweak; see JNIHandles.
     Value *unboxed_result = builder()->CreateLoad(result);
     builder()->CreateBr(merge);
 
--- a/hotspot/src/share/vm/utilities/debug.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/utilities/debug.hpp	Wed Jul 05 23:09:40 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
@@ -140,6 +140,9 @@
 // For backward compatibility.
 #define assert(p, ...) vmassert(p, __VA_ARGS__)
 
+#ifndef ASSERT
+#define vmassert_status(p, status, msg)
+#else
 // This version of vmassert is for use with checking return status from
 // library calls that return actual error values eg. EINVAL,
 // ENOMEM etc, rather than returning -1 and setting errno.
@@ -155,6 +158,7 @@
     BREAKPOINT;                                                                \
   }                                                                            \
 } while (0)
+#endif
 
 // For backward compatibility.
 #define assert_status(p, status, msg) vmassert_status(p, status, msg)
--- a/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -153,6 +153,9 @@
 // offset_of as it is defined for gcc.
 #define offset_of(klass,field) (size_t)((intx)&(((klass*)16)->field) - 16)
 
+// AIX 5.3 has buggy __thread support. (see JDK-8176442).
+#define USE_LIBRARY_BASED_TLS_ONLY 1
+
 #ifndef USE_LIBRARY_BASED_TLS_ONLY
 #define THREAD_LOCAL_DECL __thread
 #endif
--- a/hotspot/test/ProblemList.txt	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/test/ProblemList.txt	Wed Jul 05 23:09:40 2017 +0200
@@ -79,7 +79,5 @@
 
 # :hotspot_misc
 
-testlibrary_tests/ctw/JarDirTest.java 8172457 windows-all
-
 #############################################################################
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/arraycopy/TestObjectArrayCopy.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8176505
+ * @summary Wrong assertion 'should be an array copy/clone' in arraycopynode.cpp
+ *
+ * @run main/othervm -Xbatch -XX:-UseOnStackReplacement compiler.arraycopy.TestObjectArrayCopy
+ *
+ * @author Volker Simonis
+ */
+
+package compiler.arraycopy;
+
+public class TestObjectArrayCopy {
+
+    public static boolean crash(Object src) {
+        String[] dst = new String[1];
+        System.arraycopy(src, 0, dst, 0, 1);
+        return dst[0] == null;
+    }
+
+    public static void main(String[] args) {
+        String[] sa = new String[1];
+        for (int i = 0; i < 20_000; i++) {
+            crash(sa);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/c2/TestNPEHeapBased.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017 SAP SE. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8176518
+ * @summary Invalid ImplicitNullChecks when heap base not protected
+ *
+ * @run main/othervm -XX:ObjectAlignmentInBytes=16 -XX:HeapBaseMinAddress=64g
+ *      -XX:-TieredCompilation -Xbatch
+ *      compiler.c2.TestNPEHeapBased
+ * @requires vm.bits == "64"
+ */
+
+package compiler.c2;
+public class TestNPEHeapBased {
+
+    TestNPEHeapBased instance = null;
+    int i = 0;
+
+    public void set_i(int value) {
+        instance.i = value;
+    }
+
+
+    static final int loop_cnt = 200000;
+
+    public static void main(String args[]){
+        TestNPEHeapBased xyz = new TestNPEHeapBased();
+        xyz.instance = xyz;
+        for (int x = 0; x < loop_cnt; x++) xyz.set_i(x);
+        xyz.instance = null;
+        try {
+            xyz.set_i(0);
+        } catch (NullPointerException npe) {
+            System.out.println("Got expected NullPointerException:");
+            npe.printStackTrace();
+            return;
+        }
+        throw new InternalError("NullPointerException is missing!");
+    }
+
+}
--- a/hotspot/test/compiler/loopopts/TestLoopPeeling.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/test/compiler/loopopts/TestLoopPeeling.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 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 8078262
+ * @bug 8078262 8177095
  * @summary Tests correct dominator information after loop peeling.
  *
  * @run main/othervm -Xcomp
@@ -40,14 +40,16 @@
     public static void main(String args[]) {
         TestLoopPeeling test = new TestLoopPeeling();
         try {
-            test.testArrayAccess(0, 1);
+            test.testArrayAccess1(0, 1);
+            test.testArrayAccess2(0);
+            test.testArrayAccess3(0, false);
             test.testArrayAllocation(0, 1);
         } catch (Exception e) {
             // Ignore exceptions
         }
     }
 
-    public void testArrayAccess(int index, int inc) {
+    public void testArrayAccess1(int index, int inc) {
         int storeIndex = -1;
 
         for (; index < 10; index += inc) {
@@ -63,7 +65,7 @@
 
             if (index == 42) {
                 // This store and the corresponding range check are moved out of the
-                // loop and both used after old loop and the peeled iteration exit.
+                // loop and both used after main loop and the peeled iteration exit.
                 // For the peeled iteration, storeIndex is always -1 and the ConvI2L
                 // is replaced by TOP. However, the range check is not folded because
                 // we don't do the split if optimization in PhaseIdealLoop2.
@@ -77,6 +79,44 @@
         }
     }
 
+    public int testArrayAccess2(int index) {
+        // Load1 and the corresponding range check are moved out of the loop
+        // and both are used after the main loop and the peeled iteration exit.
+        // For the peeled iteration, storeIndex is always Integer.MIN_VALUE and
+        // for the main loop it is 0. Hence, the merging phi has type int:<=0.
+        // Load1 reads the array at index ConvI2L(CastII(AddI(storeIndex, -1)))
+        // where the CastII is range check dependent and has type int:>=0.
+        // The CastII gets pushed through the AddI and its type is changed to int:>=1
+        // which does not overlap with the input type of storeIndex (int:<=0).
+        // The CastII is replaced by TOP causing a cascade of other eliminations.
+        // Since the control path through the range check CmpU(AddI(storeIndex, -1))
+        // is not eliminated, the graph is in a corrupted state. We fail once we merge
+        // with the result of Load2 because we get data from a non-dominating region.
+        int storeIndex = Integer.MIN_VALUE;
+        for (; index < 10; ++index) {
+            if (index == 42) {
+                return array[storeIndex-1]; // Load1
+            }
+            storeIndex = 0;
+        }
+        return array[42]; // Load2
+    }
+
+    public int testArrayAccess3(int index, boolean b) {
+        // Same as testArrayAccess2 but manifests as crash in register allocator.
+        int storeIndex = Integer.MIN_VALUE;
+        for (; index < 10; ++index) {
+            if (b) {
+                return 0;
+            }
+            if (index == 42) {
+                return array[storeIndex-1]; // Load1
+            }
+            storeIndex = 0;
+        }
+        return array[42]; // Load2
+    }
+
     public byte[] testArrayAllocation(int index, int inc) {
         int allocationCount = -1;
         byte[] result;
@@ -88,7 +128,7 @@
 
             if (index == 42) {
                 // This allocation and the corresponding size check are moved out of the
-                // loop and both used after old loop and the peeled iteration exit.
+                // loop and both used after main loop and the peeled iteration exit.
                 // For the peeled iteration, allocationCount is always -1 and the ConvI2L
                 // is replaced by TOP. However, the size check is not folded because
                 // we don't do the split if optimization in PhaseIdealLoop2.
--- a/hotspot/test/runtime/MinimalVM/JMX.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/test/runtime/MinimalVM/JMX.java	Wed Jul 05 23:09:40 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
@@ -47,9 +47,8 @@
                 .shouldContain("-Dcom.sun.management is not supported in this VM.")
                 .shouldHaveExitValue(1);
 
-        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), Long.toString(ProcessTools.getProcessId()), "VM.print_threads"});
+        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), "-l"});
         new OutputAnalyzer(pb.start())
-                .shouldContain("Could not find any processes matching ")
-                .shouldHaveExitValue(1);
+                .shouldNotMatch("^" + Long.toString(ProcessTools.getProcessId()) + "\\s+.*$");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/constantPool/ACCModule52.java	Wed Jul 05 23:09:40 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.
+ */
+
+import jdk.internal.org.objectweb.asm.*;
+
+/*
+ * @test
+ * @summary Test that the JVM ignores ACC_MODULE if it is set for a version
+ *          52 class file.
+ * @bug 8175383
+ * @library /test/lib
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * @compile -XDignore.symbol.file ACCModule52.java
+ * @run main ACCModule52
+ */
+
+public class ACCModule52 {
+
+    static final String CLASS_NAME = "ACCModule52Pkg";
+
+    public static void main(String[] args) throws Exception {
+        int ACC_MODULE = 0x8000;
+        ClassWriter cw = new ClassWriter(0);
+        cw.visit(Opcodes.V1_8,
+                Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+                CLASS_NAME,
+                null,
+                "java/lang/Object",
+                null);
+
+        cw.visitEnd();
+        byte[] bytes = cw.toByteArray();
+
+
+        ClassLoader loader = new ClassLoader(ACCModule52.class.getClassLoader()) {
+            @Override
+            protected Class<?> findClass(String cn)throws ClassNotFoundException {
+                if (cn.equals(CLASS_NAME)) {
+                    Class superClass = super.defineClass(cn, bytes, 0, bytes.length);
+                } else {
+                    throw new ClassNotFoundException(cn);
+                }
+                return null;
+            }
+        };
+
+        Class<?> clazz = loader.loadClass(CLASS_NAME);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/constantPool/ConstModule.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,255 @@
+/*
+ * 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.internal.org.objectweb.asm.*;
+
+/*
+ * @test
+ * @summary Test scenarios for constant pool CONSTANT_Module and CONSTANT_Package
+ *          types, for class file versions 53 and 52, when ACC_MODULE is set and
+ *          not set in the access_flags.
+ * @bug 8175383
+ * @library /test/lib
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * @compile -XDignore.symbol.file ConstModule.java
+ * @run main ConstModule
+ */
+
+public class ConstModule {
+
+    static final int ACC_MODULE = 0x8000;
+    static final boolean MODULE_TEST = true;
+    static final boolean PACKAGE_TEST = false;
+    static final boolean CFE_EXCEPTION = true;
+    static final boolean NCDFE_EXCEPTION = false;
+
+    public static void main(String[] args) throws Exception {
+
+        // Test that the JVM throws CFE for constant pool CONSTANT_Module type, for
+        // class file version 53, when ACC_MODULE is not set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_9,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC,
+            "jdk.fooMod", "FooMod", MODULE_TEST, CFE_EXCEPTION);
+
+        // Test that the JVM throws NCDFE for constant pool CONSTANT_Module type,
+        // for class file version 53, when ACC_MODULE is set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_9,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+            "jdk.fooModACC", "FooModACC", MODULE_TEST, NCDFE_EXCEPTION);
+
+        // Test that the JVM throws CFE for constant pool CONSTANT_Module type, for
+        // class file version 52, even when ACC_MODULE is set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_8,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+            "jdk.fooModACC52", "FooModACC52", MODULE_TEST, CFE_EXCEPTION);
+
+        // Test that the JVM throws CFE for constant pool CONSTANT_Package type, for
+        // class file version 53, when ACC_MODULE is not set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_9,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC,
+            "jdk.fooPkg", "FooPkg", PACKAGE_TEST, CFE_EXCEPTION);
+
+        // Test that the JVM throws NCDFE for constant pool CONSTANT_Package type,
+        // for class file version 53, when ACC_MODULE is set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_9,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+            "jdk.fooModACC", "FooModACC", PACKAGE_TEST, NCDFE_EXCEPTION);
+
+        // Test that the JVM throws CFE for constant pool CONSTANT_Package type, for
+        // class file version 52, even when ACC_MODULE is set in the access_flags.
+        ConstModule.write_and_load(Opcodes.V1_8,
+            Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + ACC_MODULE,
+            "jdk.fooModACC52", "FooModACC52", PACKAGE_TEST, CFE_EXCEPTION);
+
+    }
+
+    public static void write_and_load(int version,
+                                      int access_flags,
+                                      String attr,
+                                      String class_name,
+                                      boolean module_test,
+                                      boolean throwCFE) throws Exception {
+        ClassWriter cw = new ClassWriter(0);
+        cw.visit(version,
+                 access_flags,
+                 class_name,
+                 null,
+                 "java/lang/Object",
+                 null);
+
+        if (module_test)
+            cw.visitAttribute(new TestModuleAttribute(attr));
+        else
+            cw.visitAttribute(new TestPackageAttribute(attr));
+
+        cw.visitEnd();
+        byte[] bytes = cw.toByteArray();
+
+
+        ClassLoader loader = new ClassLoader(ConstModule.class.getClassLoader()) {
+            @Override
+            protected Class<?> findClass(String cn)throws ClassNotFoundException {
+                if (cn.equals(class_name)) {
+                    try {
+                        Class superClass = super.defineClass(cn, bytes, 0, bytes.length);
+                        throw new RuntimeException("Expected ClassFormatError not thrown");
+                    } catch (java.lang.ClassFormatError e) {
+                       if (!throwCFE) {
+                           throw new RuntimeException("Unexpected ClassFormatError exception: " + e.getMessage());
+                       }
+                       if (module_test && !e.getMessage().contains(
+                           "Unknown constant tag 19 in class file")) {
+                           throw new RuntimeException("Wrong ClassFormatError exception: " + e.getMessage());
+                       } else if (!module_test && !e.getMessage().contains(
+                           "Unknown constant tag 20 in class file")) {
+                           throw new RuntimeException("Wrong ClassFormatError exception: " + e.getMessage());
+                       }
+                    } catch (java.lang.NoClassDefFoundError f) {
+                       if (throwCFE) {
+                           throw new RuntimeException("Unexpected NoClassDefFoundError exception: " + f.getMessage());
+                       }
+                       if (!f.getMessage().contains(
+                           "is not a class because access_flag ACC_MODULE is set")) {
+                           throw new RuntimeException("Wrong NoClassDefFoundError exception: " + f.getMessage());
+                       }
+                    }
+                } else {
+                    throw new ClassNotFoundException(cn);
+                }
+                return null;
+            }
+        };
+
+        Class<?> clazz = loader.loadClass(class_name);
+    }
+
+    /**
+     * ConstModuleAttr attribute.
+     *
+     * <pre> {@code
+     *
+     * MainClass_attribute {
+     *   // index to CONSTANT_utf8_info structure in constant pool representing
+     *   // the string "ConstModuleAttr"
+     *   u2 attribute_name_index;
+     *   u4 attribute_length;
+     *
+     *   // index to CONSTANT_Module_info structure
+     *   u2 module_name_index
+     * }
+     *
+     * } </pre>
+     */
+    public static class TestModuleAttribute extends Attribute {
+        private final String moduleName;
+
+        public TestModuleAttribute(String moduleName) {
+            super("ConstModuleAttr");
+            this.moduleName = moduleName;
+        }
+
+        public TestModuleAttribute() {
+            this(null);
+        }
+
+        @Override
+        protected Attribute read(ClassReader cr,
+                                 int off,
+                                 int len,
+                                 char[] buf,
+                                 int codeOff,
+                                 Label[] labels)
+        {
+            String mn = cr.readModule(off, buf);
+            off += 2;
+            return new TestModuleAttribute(mn);
+        }
+
+        @Override
+        protected ByteVector write(ClassWriter cw,
+                                   byte[] code,
+                                   int len,
+                                   int maxStack,
+                                   int maxLocals)
+        {
+            ByteVector attr = new ByteVector();
+            attr.putShort(cw.newModule(moduleName));
+            return attr;
+        }
+    }
+
+    /**
+     * ConstPackageAttr attribute.
+     *
+     * <pre> {@code
+     *
+     * MainClass_attribute {
+     *   // index to CONSTANT_utf8_info structure in constant pool representing
+     *   // the string "ConstPackageAttr"
+     *   u2 attribute_name_index;
+     *   u4 attribute_length;
+     *
+     *   // index to CONSTANT_Package_info structure
+     *   u2 module_name_index
+     * }
+     *
+     * } </pre>
+     */
+    public static class TestPackageAttribute extends Attribute {
+        private final String packageName;
+
+        public TestPackageAttribute(String packageName) {
+            super("ConstPackageAttr");
+            this.packageName = packageName;
+        }
+
+        public TestPackageAttribute() {
+            this(null);
+        }
+
+        @Override
+        protected Attribute read(ClassReader cr,
+                                 int off,
+                                 int len,
+                                 char[] buf,
+                                 int codeOff,
+                                 Label[] labels)
+        {
+            String mn = cr.readPackage(off, buf);
+            off += 2;
+            return new TestPackageAttribute(mn);
+        }
+
+        @Override
+        protected ByteVector write(ClassWriter cw,
+                                   byte[] code,
+                                   int len,
+                                   int maxStack,
+                                   int maxLocals)
+        {
+            ByteVector attr = new ByteVector();
+            attr.putShort(cw.newPackage(packageName));
+            return attr;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/duplAttributes/DupSignatureAttrs.jcod	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,615 @@
+/*
+ * 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.
+ */
+
+// Class containing duplicate Signature attributes.  Loading it should cause a
+// ClassFormatError exception.
+class DupClassSigAttrs {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [33] { // Constant Pool
+    ; // first element is empty
+    Method #6 #17; // #1     at 0x0A
+    Field #18 #19; // #2     at 0x0F
+    String #20; // #3     at 0x14
+    Method #21 #22; // #4     at 0x17
+    class #23; // #5     at 0x1C
+    class #24; // #6     at 0x1F
+    Utf8 "<init>"; // #7     at 0x22
+    Utf8 "()V"; // #8     at 0x2B
+    Utf8 "Code"; // #9     at 0x31
+    Utf8 "LineNumberTable"; // #10     at 0x38
+    Utf8 "main"; // #11     at 0x4A
+    Utf8 "([Ljava/lang/String;)V"; // #12     at 0x51
+    Utf8 "Exceptions"; // #13     at 0x6A
+    class #25; // #14     at 0x77
+    Utf8 "SourceFile"; // #15     at 0x7A
+    Utf8 "DupClassSigAttrs.java"; // #16     at 0x87
+    NameAndType #7 #8; // #17     at 0x9F
+    class #26; // #18     at 0xA4
+    NameAndType #27 #28; // #19     at 0xA7
+    Utf8 "hi"; // #20     at 0xAC
+    class #29; // #21     at 0xB1
+    NameAndType #30 #31; // #22     at 0xB4
+    Utf8 "DupClassSigAttrs"; // #23     at 0xB9
+    Utf8 "java/lang/Object"; // #24     at 0xCC
+    Utf8 "java/lang/Throwable"; // #25     at 0xDF
+    Utf8 "java/lang/System"; // #26     at 0xF5
+    Utf8 "out"; // #27     at 0x0108
+    Utf8 "Ljava/io/PrintStream;"; // #28     at 0x010E
+    Utf8 "java/io/PrintStream"; // #29     at 0x0126
+    Utf8 "println"; // #30     at 0x013C
+    Utf8 "(Ljava/lang/String;)V"; // #31     at 0x0146
+    Utf8 "Signature"; // #32     at 0x015E
+  } // Constant Pool
+
+  0x0021; // access
+  #5;// this_cpx
+  #6;// super_cpx
+
+  [0] { // Interfaces
+  } // Interfaces
+
+  [0] { // fields
+  } // fields
+
+  [2] { // methods
+    { // Member at 0x0176
+      0x0001; // access
+      #7; // name_cpx
+      #8; // sig_cpx
+      [1] { // Attributes
+        Attr(#9, 29) { // Code at 0x017E
+          1; // max_stack
+          1; // max_locals
+          Bytes[5]{
+            0x2AB70001B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#10, 6) { // LineNumberTable at 0x0195
+              [1] { // LineNumberTable
+                0  1; //  at 0x01A1
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x01A1
+      0x0009; // access
+      #11; // name_cpx
+      #12; // sig_cpx
+      [2] { // Attributes
+        Attr(#9, 37) { // Code at 0x01A9
+          2; // max_stack
+          1; // max_locals
+          Bytes[9]{
+            0xB200021203B60004;
+            0xB1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#10, 10) { // LineNumberTable at 0x01C4
+              [2] { // LineNumberTable
+                0  4; //  at 0x01D0
+                8  5; //  at 0x01D4
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#13, 4) { // Exceptions at 0x01D4
+          [1] { // Exceptions
+            #14; //  at 0x01DE
+          }
+        } // end Exceptions
+      } // Attributes
+    } // Member
+  } // methods
+
+  [3] { // Attributes
+    Attr(#15, 2) { // SourceFile at 0x01E0
+      #16;
+    } // end SourceFile
+    ;
+    Attr(#32, 2) { // Signature at 0x01E8
+      #16;
+    } // end Signature
+    ;
+    Attr(#32, 2) { // *** Duplicate *** Signature at 0x01F0
+      #16;
+    } // end Signature
+  } // Attributes
+} // end class DupClassSigAttrs
+
+
+// Class containing a method with duplicate Signature attributes.  Loading it
+// should cause a ClassFormatError exception.
+class DupMthSigAttrs {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [33] { // Constant Pool
+    ; // first element is empty
+    Method #6 #17; // #1     at 0x0A
+    Field #18 #19; // #2     at 0x0F
+    String #20; // #3     at 0x14
+    Method #21 #22; // #4     at 0x17
+    class #23; // #5     at 0x1C
+    class #24; // #6     at 0x1F
+    Utf8 "<init>"; // #7     at 0x22
+    Utf8 "()V"; // #8     at 0x2B
+    Utf8 "Code"; // #9     at 0x31
+    Utf8 "LineNumberTable"; // #10     at 0x38
+    Utf8 "main"; // #11     at 0x4A
+    Utf8 "([Ljava/lang/String;)V"; // #12     at 0x51
+    Utf8 "Exceptions"; // #13     at 0x6A
+    class #25; // #14     at 0x77
+    Utf8 "SourceFile"; // #15     at 0x7A
+    Utf8 "DupMthSigAttrs.java"; // #16     at 0x87
+    NameAndType #7 #8; // #17     at 0x9D
+    class #26; // #18     at 0xA2
+    NameAndType #27 #28; // #19     at 0xA5
+    Utf8 "hi"; // #20     at 0xAA
+    class #29; // #21     at 0xAF
+    NameAndType #30 #31; // #22     at 0xB2
+    Utf8 "DupMthSigAttrs"; // #23     at 0xB7
+    Utf8 "java/lang/Object"; // #24     at 0xC8
+    Utf8 "java/lang/Throwable"; // #25     at 0xDB
+    Utf8 "java/lang/System"; // #26     at 0xF1
+    Utf8 "out"; // #27     at 0x0104
+    Utf8 "Ljava/io/PrintStream;"; // #28     at 0x010A
+    Utf8 "java/io/PrintStream"; // #29     at 0x0122
+    Utf8 "println"; // #30     at 0x0138
+    Utf8 "(Ljava/lang/String;)V"; // #31     at 0x0142
+    Utf8 "Signature"; // #32     at 0x015A
+  } // Constant Pool
+
+  0x0021; // access
+  #5;// this_cpx
+  #6;// super_cpx
+
+  [0] { // Interfaces
+  } // Interfaces
+
+  [0] { // fields
+  } // fields
+
+  [2] { // methods
+    { // Member at 0x0172
+      0x0001; // access
+      #7; // name_cpx
+      #8; // sig_cpx
+      [1] { // Attributes
+        Attr(#9, 29) { // Code at 0x017A
+          1; // max_stack
+          1; // max_locals
+          Bytes[5]{
+            0x2AB70001B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#10, 6) { // LineNumberTable at 0x0191
+              [1] { // LineNumberTable
+                0  1; //  at 0x019D
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x019D
+      0x0009; // access
+      #11; // name_cpx
+      #12; // sig_cpx
+      [4] { // Attributes
+        Attr(#9, 37) { // Code at 0x01A5
+          2; // max_stack
+          1; // max_locals
+          Bytes[9]{
+            0xB200021203B60004;
+            0xB1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#10, 10) { // LineNumberTable at 0x01C0
+              [2] { // LineNumberTable
+                0  4; //  at 0x01CC
+                8  5; //  at 0x01D0
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#32, 2) { // Signature at 0x01D0
+          #16;
+        } // end Signature
+        ;
+        Attr(#13, 4) { // Exceptions at 0x01D8
+          [1] { // Exceptions
+            #14; //  at 0x01E2
+          }
+        } // end Exceptions
+        ;
+        Attr(#32, 2) { // *** Duplicate *** Signature at 0x01E2
+          #16;
+        } // end Signature
+      } // Attributes
+    } // Member
+  } // methods
+
+  [1] { // Attributes
+    Attr(#15, 2) { // SourceFile at 0x01EC
+      #16;
+    } // end SourceFile
+  } // Attributes
+} // end class DupMthSigAttrs
+
+
+// Class containing a field with duplicate Signature attributes.  Loading it
+// should cause a ClassFormatError exception.
+class DupFldSigAttrs {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [42] { // Constant Pool
+    ; // first element is empty
+    Method #9 #23; // #1     at 0x0A
+    Field #24 #25; // #2     at 0x0F
+    Field #8 #26; // #3     at 0x14
+    Method #27 #28; // #4     at 0x19
+    class #29; // #5     at 0x1E
+    String #30; // #6     at 0x21
+    Method #5 #31; // #7     at 0x24
+    class #32; // #8     at 0x29
+    class #33; // #9     at 0x2C
+    Utf8 "str"; // #10     at 0x2F
+    Utf8 "Ljava/lang/String;"; // #11     at 0x35
+    Utf8 "<init>"; // #12     at 0x4A
+    Utf8 "()V"; // #13     at 0x53
+    Utf8 "Code"; // #14     at 0x59
+    Utf8 "LineNumberTable"; // #15     at 0x60
+    Utf8 "main"; // #16     at 0x72
+    Utf8 "([Ljava/lang/String;)V"; // #17     at 0x79
+    Utf8 "Exceptions"; // #18     at 0x92
+    class #34; // #19     at 0x9F
+    Utf8 "<clinit>"; // #20     at 0xA2
+    Utf8 "SourceFile"; // #21     at 0xAD
+    Utf8 "DupFldSigAttrs.java"; // #22     at 0xBA
+    NameAndType #12 #13; // #23     at 0xD0
+    class #35; // #24     at 0xD5
+    NameAndType #36 #37; // #25     at 0xD8
+    NameAndType #10 #11; // #26     at 0xDD
+    class #38; // #27     at 0xE2
+    NameAndType #39 #40; // #28     at 0xE5
+    Utf8 "java/lang/String"; // #29     at 0xEA
+    Utf8 "Hi"; // #30     at 0xFD
+    NameAndType #12 #40; // #31     at 0x0102
+    Utf8 "DupFldSigAttrs"; // #32     at 0x0107
+    Utf8 "java/lang/Object"; // #33     at 0x0118
+    Utf8 "java/lang/Throwable"; // #34     at 0x012B
+    Utf8 "java/lang/System"; // #35     at 0x0141
+    Utf8 "out"; // #36     at 0x0154
+    Utf8 "Ljava/io/PrintStream;"; // #37     at 0x015A
+    Utf8 "java/io/PrintStream"; // #38     at 0x0172
+    Utf8 "println"; // #39     at 0x0188
+    Utf8 "(Ljava/lang/String;)V"; // #40     at 0x0192
+    Utf8 "Signature"; // #41     at 0x01AA
+  } // Constant Pool
+
+  0x0021; // access
+  #8;// this_cpx
+  #9;// super_cpx
+
+  [0] { // Interfaces
+  } // Interfaces
+
+  [1] { // fields
+    { // Member at 0x01C0
+      0x0008; // access
+      #10; // name_cpx
+      #11; // sig_cpx
+      [2] { // Attributes
+        Attr(#41, 2) { // Signature at 0x01C8
+          #16;
+        } // end Signature
+        ;
+        Attr(#41, 2) { // *** Duplicate *** Signature at 0x01D0
+          #16;
+        } // end Signature
+      } // Attributes
+    } // Member
+  } // fields
+
+  [3] { // methods
+    { // Member at 0x01DA
+      0x0001; // access
+      #12; // name_cpx
+      #13; // sig_cpx
+      [1] { // Attributes
+        Attr(#14, 29) { // Code at 0x01E2
+          1; // max_stack
+          1; // max_locals
+          Bytes[5]{
+            0x2AB70001B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 6) { // LineNumberTable at 0x01F9
+              [1] { // LineNumberTable
+                0  1; //  at 0x0205
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x0205
+      0x0009; // access
+      #16; // name_cpx
+      #17; // sig_cpx
+      [2] { // Attributes
+        Attr(#14, 38) { // Code at 0x020D
+          2; // max_stack
+          1; // max_locals
+          Bytes[10]{
+            0xB20002B20003B600;
+            0x04B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 10) { // LineNumberTable at 0x0229
+              [2] { // LineNumberTable
+                0  6; //  at 0x0235
+                9  7; //  at 0x0239
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#18, 4) { // Exceptions at 0x0239
+          [1] { // Exceptions
+            #19; //  at 0x0243
+          }
+        } // end Exceptions
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x0243
+      0x0008; // access
+      #20; // name_cpx
+      #13; // sig_cpx
+      [1] { // Attributes
+        Attr(#14, 37) { // Code at 0x024B
+          3; // max_stack
+          0; // max_locals
+          Bytes[13]{
+            0xBB0005591206B700;
+            0x07B30003B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 6) { // LineNumberTable at 0x026A
+              [1] { // LineNumberTable
+                0  3; //  at 0x0276
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [1] { // Attributes
+    Attr(#21, 2) { // SourceFile at 0x0278
+      #22;
+    } // end SourceFile
+  } // Attributes
+} // end class DupFldSigAttrs
+
+
+// Class containing a Signature attribute and a field and methods with Signature
+// attributes.  Since neither the class nor any of its fields or methods have
+// duplicate Signature attributes, loading this class should not cause a
+// ClassFormatError exception.
+class OkaySigAttrs {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [42] { // Constant Pool
+    ; // first element is empty
+    Method #9 #23; // #1     at 0x0A
+    Field #24 #25; // #2     at 0x0F
+    Field #8 #26; // #3     at 0x14
+    Method #27 #28; // #4     at 0x19
+    class #29; // #5     at 0x1E
+    String #30; // #6     at 0x21
+    Method #5 #31; // #7     at 0x24
+    class #32; // #8     at 0x29
+    class #33; // #9     at 0x2C
+    Utf8 "str"; // #10     at 0x2F
+    Utf8 "Ljava/lang/String;"; // #11     at 0x35
+    Utf8 "<init>"; // #12     at 0x4A
+    Utf8 "()V"; // #13     at 0x53
+    Utf8 "Code"; // #14     at 0x59
+    Utf8 "LineNumberTable"; // #15     at 0x60
+    Utf8 "main"; // #16     at 0x72
+    Utf8 "([Ljava/lang/String;)V"; // #17     at 0x79
+    Utf8 "Exceptions"; // #18     at 0x92
+    class #34; // #19     at 0x9F
+    Utf8 "<clinit>"; // #20     at 0xA2
+    Utf8 "SourceFile"; // #21     at 0xAD
+    Utf8 "OkaySigAttrs.java"; // #22     at 0xBA
+    NameAndType #12 #13; // #23     at 0xCE
+    class #35; // #24     at 0xD3
+    NameAndType #36 #37; // #25     at 0xD6
+    NameAndType #10 #11; // #26     at 0xDB
+    class #38; // #27     at 0xE0
+    NameAndType #39 #40; // #28     at 0xE3
+    Utf8 "java/lang/String"; // #29     at 0xE8
+    Utf8 "Hi"; // #30     at 0xFB
+    NameAndType #12 #40; // #31     at 0x0100
+    Utf8 "OkaySigAttrs"; // #32     at 0x0105
+    Utf8 "java/lang/Object"; // #33     at 0x0114
+    Utf8 "java/lang/Throwable"; // #34     at 0x0127
+    Utf8 "java/lang/System"; // #35     at 0x013D
+    Utf8 "out"; // #36     at 0x0150
+    Utf8 "Ljava/io/PrintStream;"; // #37     at 0x0156
+    Utf8 "java/io/PrintStream"; // #38     at 0x016E
+    Utf8 "println"; // #39     at 0x0184
+    Utf8 "(Ljava/lang/String;)V"; // #40     at 0x018E
+    Utf8 "Signature"; // #41     at 0x01A6
+  } // Constant Pool
+
+  0x0021; // access
+  #8;// this_cpx
+  #9;// super_cpx
+
+  [0] { // Interfaces
+  } // Interfaces
+
+  [1] { // fields
+    { // Member at 0x01BC
+      0x0008; // access
+      #10; // name_cpx
+      #11; // sig_cpx
+      [1] { // Attributes
+        Attr(#41, 2) { // Signature at 0x01C4
+          #16;
+        } // end Signature
+      } // Attributes
+    } // Member
+  } // fields
+
+  [3] { // methods
+    { // Member at 0x01CE
+      0x0001; // access
+      #12; // name_cpx
+      #13; // sig_cpx
+      [2] { // Attributes
+        Attr(#14, 29) { // Code at 0x01D6
+          1; // max_stack
+          1; // max_locals
+          Bytes[5]{
+            0x2AB70001B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 6) { // LineNumberTable at 0x01ED
+              [1] { // LineNumberTable
+                0  1; //  at 0x01F9
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#41, 2) { // Signature at 0x01F9
+          #16;
+        } // end Signature
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x0201
+      0x0009; // access
+      #16; // name_cpx
+      #17; // sig_cpx
+      [3] { // Attributes
+        Attr(#14, 38) { // Code at 0x0209
+          2; // max_stack
+          1; // max_locals
+          Bytes[10]{
+            0xB20002B20003B600;
+            0x04B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 10) { // LineNumberTable at 0x0225
+              [2] { // LineNumberTable
+                0  6; //  at 0x0231
+                9  7; //  at 0x0235
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+        ;
+        Attr(#41, 2) { // Signature at 0x0235
+          #16;
+        } // end Signature
+        ;
+        Attr(#18, 4) { // Exceptions at 0x023D
+          [1] { // Exceptions
+            #19; //  at 0x0247
+          }
+        } // end Exceptions
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x0247
+      0x0008; // access
+      #20; // name_cpx
+      #13; // sig_cpx
+      [1] { // Attributes
+        Attr(#14, 37) { // Code at 0x024F
+          3; // max_stack
+          0; // max_locals
+          Bytes[13]{
+            0xBB0005591206B700;
+            0x07B30003B1;
+          };
+          [0] { // Traps
+          } // end Traps
+          [1] { // Attributes
+            Attr(#15, 6) { // LineNumberTable at 0x026E
+              [1] { // LineNumberTable
+                0  3; //  at 0x027A
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [2] { // Attributes
+    Attr(#21, 2) { // SourceFile at 0x027C
+      #22;
+    } // end SourceFile
+    ;
+    Attr(#41, 2) { // Signature at 0x0284
+      #16;
+    } // end Signature
+  } // Attributes
+} // end class OkaySigAttrs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/duplAttributes/TestDupSignatureAttr.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,63 @@
+/*
+ * 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 8176147
+ * @summary Throw ClassFormatError exception for multiple Signature attributes
+ * @compile DupSignatureAttrs.jcod
+ * @run main TestDupSignatureAttr
+ */
+
+public class TestDupSignatureAttr {
+    public static void main(String args[]) throws Throwable {
+
+        System.out.println("Regression test for bug 8176147");
+
+        String[] badClasses = new String[] {
+            "DupClassSigAttrs",
+            "DupMthSigAttrs",
+            "DupFldSigAttrs",
+        };
+        String[] messages = new String[] {
+            "Multiple Signature attributes in class file",
+            "Multiple Signature attributes for method",
+            "Multiple Signature attributes for field",
+        };
+
+        for (int x = 0; x < badClasses.length; x++) {
+            try {
+                Class newClass = Class.forName(badClasses[x]);
+                throw new RuntimeException("Expected ClassFormatError exception not thrown");
+            } catch (java.lang.ClassFormatError e) {
+                if (!e.getMessage().contains(messages[x])) {
+                    throw new RuntimeException("Wrong ClassFormatError exception thrown: " +
+                                               e.getMessage());
+                }
+            }
+        }
+
+        // Multiple Signature attributes but no duplicates.
+        Class newClass = Class.forName("OkaySigAttrs");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/jni/CallWithJNIWeak/CallWithJNIWeak.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8166188
+ * @summary Test call of native function with JNI weak global ref.
+ * @modules java.base
+ * @run main/othervm/native CallWithJNIWeak
+ */
+
+public class CallWithJNIWeak {
+    static {
+        System.loadLibrary("CallWithJNIWeak");
+    }
+
+    private static native void testJNIFieldAccessors(CallWithJNIWeak o);
+
+    // The field initializations must be kept in sync with the JNI code
+    // which reads verifies the values of these fields.
+    private int i = 1;
+    private long j = 2;
+    private boolean z = true;
+    private char c = 'a';
+    private short s = 3;
+    private float f = 1.0f;
+    private double d = 2.0;
+    private Object l;
+
+    private CallWithJNIWeak() {
+        this.l = this;
+    }
+
+    private native void weakReceiverTest0();
+    private void weakReceiverTest() {
+        weakReceiverTest0();
+    }
+
+    private synchronized void synchonizedWeakReceiverTest() {
+        this.notifyAll();
+    }
+
+
+    private static native void runTests(CallWithJNIWeak o);
+
+    public static void main(String[] args) {
+        CallWithJNIWeak w = new CallWithJNIWeak();
+        for (int i = 0; i < 20000; i++) {
+            runTests(w);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/jni/CallWithJNIWeak/libCallWithJNIWeak.c	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+
+/*
+ * Class:     CallWithJNIWeak
+ * Method:    testJNIFieldAccessors
+ * Signature: (LCallWithJNIWeak;)V
+ */
+JNIEXPORT void JNICALL
+Java_CallWithJNIWeak_testJNIFieldAccessors(JNIEnv *env, jclass clazz, jobject this) {
+  // Make sure that we have a weak reference to the receiver
+
+  jweak self = (*env)->NewWeakGlobalRef(env, this);
+
+  jclass this_class = (*env)->GetObjectClass(env, self);
+
+  jclass exception = (*env)->FindClass(env, "java/lang/RuntimeException");
+
+  jfieldID id_i = (*env)->GetFieldID(env, this_class, "i", "I");
+  jfieldID id_j = (*env)->GetFieldID(env, this_class, "j", "J");
+  jfieldID id_z = (*env)->GetFieldID(env, this_class, "z", "Z");
+  jfieldID id_c = (*env)->GetFieldID(env, this_class, "c", "C");
+  jfieldID id_s = (*env)->GetFieldID(env, this_class, "s", "S");
+  jfieldID id_f = (*env)->GetFieldID(env, this_class, "f", "F");
+  jfieldID id_d = (*env)->GetFieldID(env, this_class, "d", "D");
+  jfieldID id_l = (*env)->GetFieldID(env, this_class, "l", "Ljava/lang/Object;");
+  jvalue v;
+
+#define CHECK(variable, expected)                                   \
+  do {                                                              \
+    if ((variable) != (expected)) {                                 \
+      (*env)->ThrowNew(env, exception,  #variable" != " #expected); \
+      return;                                                       \
+    }                                                               \
+  } while(0)
+
+  // The values checked below must be kept in sync with the Java source file.
+
+  v.i = (*env)->GetIntField(env, self, id_i);
+  CHECK(v.i, 1);
+
+  v.j = (*env)->GetLongField(env, self, id_j);
+  CHECK(v.j, 2);
+
+  v.z = (*env)->GetBooleanField(env, self, id_z);
+  CHECK(v.z, JNI_TRUE);
+
+  v.c = (*env)->GetCharField(env, self, id_c);
+  CHECK(v.c, 'a');
+
+  v.s = (*env)->GetShortField(env, self, id_s);
+  CHECK(v.s, 3);
+
+  v.f = (*env)->GetFloatField(env, self, id_f);
+  CHECK(v.f, 1.0f);
+
+  v.d = (*env)->GetDoubleField(env, self, id_d);
+  CHECK(v.d, 2.0);
+
+#undef CHECK
+
+  v.l = (*env)->GetObjectField(env, self, id_l);
+  if (v.l == NULL) {
+    (*env)->ThrowNew(env, exception, "Object field was null");
+    return;
+  }
+  {
+    jclass clz = (*env)->GetObjectClass(env, v.l);
+    if (!(*env)->IsSameObject(env, clazz, clz)) {
+      (*env)->ThrowNew(env, exception, "Bad object class");
+    }
+  }
+
+  (*env)->DeleteWeakGlobalRef(env, self);
+}
+
+/*
+ * Class:     CallWithJNIWeak
+ * Method:    runTests
+ * Signature: (LCallWithJNIWeak;)V
+ */
+JNIEXPORT void JNICALL
+Java_CallWithJNIWeak_runTests(JNIEnv *env, jclass clazz, jobject this) {
+  jweak that = (*env)->NewWeakGlobalRef(env, this);
+  {
+    jmethodID method = (*env)->GetStaticMethodID(env,
+        clazz, "testJNIFieldAccessors", "(LCallWithJNIWeak;)V");
+    (*env)->CallStaticVoidMethod(env, clazz, method, that);
+    if ((*env)->ExceptionCheck(env)) {
+      return;
+    }
+  }
+
+  {
+    jmethodID method = (*env)->GetMethodID(env, clazz, "weakReceiverTest", "()V");
+    (*env)->CallVoidMethod(env, that, method);
+    if ((*env)->ExceptionCheck(env)) {
+      return;
+    }
+  }
+
+  {
+    jmethodID method = (*env)->GetMethodID(env, clazz, "synchonizedWeakReceiverTest", "()V");
+    (*env)->CallVoidMethod(env, that, method);
+    if ((*env)->ExceptionCheck(env)) {
+      return;
+    }
+  }
+  (*env)->DeleteWeakGlobalRef(env, that);
+}
+
+/*
+ * Class:     CallWithJNIWeak
+ * Method:    weakReceiverTest0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_CallWithJNIWeak_weakReceiverTest0(JNIEnv *env, jobject obj) {
+  (*env)->GetObjectClass(env, obj);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/jni/ReturnJNIWeak/ReturnJNIWeak.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,132 @@
+/*
+ * 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 8166188
+ * @requires vm.opt.ExplicitGCInvokesConcurrent != true
+ * @summary Test return of JNI weak global refs from native calls.
+ * @modules java.base
+ * @run main/othervm/native -Xint ReturnJNIWeak
+ * @run main/othervm/native -Xcomp ReturnJNIWeak
+ */
+
+public final class ReturnJNIWeak {
+
+    static {
+        System.loadLibrary("ReturnJNIWeak");
+    }
+
+    private static final class TestObject {
+        public final int value;
+
+        public TestObject(int value) {
+            this.value = value;
+        }
+    }
+
+    private static volatile TestObject testObject = null;
+
+    private static native void registerObject(Object o);
+    private static native void unregisterObject();
+    private static native Object getObject();
+
+    // Create the test object and record it both strongly and weakly.
+    private static void remember(int value) {
+        TestObject o = new TestObject(value);
+        registerObject(o);
+        testObject = o;
+    }
+
+    // Remove both strong and weak references to the current test object.
+    private static void forget() {
+        unregisterObject();
+        testObject = null;
+    }
+
+    // Verify the weakly recorded object
+    private static void checkValue(int value) throws Exception {
+        Object o = getObject();
+        if (o == null) {
+            throw new RuntimeException("Weak reference unexpectedly null");
+        }
+        TestObject t = (TestObject)o;
+        if (t.value != value) {
+            throw new RuntimeException("Incorrect value");
+        }
+    }
+
+    // Verify we can create a weak reference and get it back.
+    private static void testSanity() throws Exception {
+        System.out.println("running testSanity");
+        int value = 5;
+        try {
+            remember(value);
+            checkValue(value);
+        } finally {
+            forget();
+        }
+    }
+
+    // Verify weak ref value survives across collection if strong ref exists.
+    private static void testSurvival() throws Exception {
+        System.out.println("running testSurvival");
+        int value = 10;
+        try {
+            remember(value);
+            checkValue(value);
+            System.gc();
+            // Verify weak ref still has expected value.
+            checkValue(value);
+        } finally {
+            forget();
+        }
+    }
+
+    // Verify weak ref cleared if no strong ref exists.
+    private static void testClear() throws Exception {
+        System.out.println("running testClear");
+        int value = 15;
+        try {
+          remember(value);
+          checkValue(value);
+          // Verify still good.
+          checkValue(value);
+          // Drop reference.
+          testObject = null;
+          System.gc();
+          // Verify weak ref cleared as expected.
+          Object recorded = getObject();
+          if (recorded != null) {
+            throw new RuntimeException("expected clear");
+          }
+        } finally {
+          forget();
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        testSanity();
+        testSurvival();
+        testClear();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/jni/ReturnJNIWeak/libReturnJNIWeak.c	Wed Jul 05 23:09:40 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.
+ */
+
+/*
+ * Native support for ReturnJNIWeak test.
+ */
+
+#include "jni.h"
+
+static jweak registered = NULL;
+
+JNIEXPORT void JNICALL
+Java_ReturnJNIWeak_registerObject(JNIEnv* env,
+                                  jclass jclazz,
+                                  jobject value) {
+  // assert registered == NULL
+  registered = (*env)->NewWeakGlobalRef(env, value);
+}
+
+JNIEXPORT void JNICALL
+Java_ReturnJNIWeak_unregisterObject(JNIEnv* env, jclass jclazz) {
+  if (registered != NULL) {
+    (*env)->DeleteWeakGlobalRef(env, registered);
+    registered = NULL;
+  }
+}
+
+JNIEXPORT jobject JNICALL
+Java_ReturnJNIWeak_getObject(JNIEnv* env, jclass jclazz) {
+  // assert registered != NULL
+  return registered;
+}
--- a/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java	Wed Jul 05 23:09:40 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
@@ -44,7 +44,7 @@
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
             "-D" + prop + "=" + value, "-version");
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
-        output.shouldContain("java version ");
+        output.shouldContain(" version ");
         output.shouldHaveExitValue(0);
 
         // Ensure that the property and its value aren't available.
--- a/hotspot/test/serviceability/jvmti/GetNamedModule/libGetNamedModuleTest.c	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/test/serviceability/jvmti/GetNamedModule/libGetNamedModuleTest.c	Wed Jul 05 23:09:40 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
@@ -183,7 +183,7 @@
     err = (*jvmti)->GetNamedModule(jvmti, loader, pkg_name, module_ptr);
     if (err != JVMTI_ERROR_NONE) {
         printf("    Error in GetNamedModule for package \"%s\": %s (%d)\n",
-               pkg_name, TranslateError(err), err);
+               name, TranslateError(err), err);
         return err;
     }
     printf("    returned module: %p\n", *module_ptr);
--- a/hotspot/test/test_env.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/test/test_env.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -214,6 +214,11 @@
 then
   VM_CPU="aarch64"
 fi
+grep "arm64" vm_version.out > ${NULL}
+if [ $? = 0 ]
+then
+  VM_CPU="aarch64"
+fi
 export VM_TYPE VM_BITS VM_OS VM_CPU
 echo "VM_TYPE=${VM_TYPE}"
 echo "VM_BITS=${VM_BITS}"
--- a/hotspot/test/testlibrary_tests/ctw/CtwTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/hotspot/test/testlibrary_tests/ctw/CtwTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -37,6 +37,7 @@
 import java.nio.file.StandardCopyOption;
 import java.nio.charset.Charset;
 
+import jdk.test.lib.Platform;
 import jdk.test.lib.JDKToolFinder;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
@@ -93,7 +94,12 @@
         // concat CTW_COMMAND and args w/o 0th element
         String[] cmd = Arrays.copyOf(CTW_COMMAND, CTW_COMMAND.length + args.length - 1);
         System.arraycopy(args, 1, cmd, CTW_COMMAND.length, args.length - 1);
-
+        if (Platform.isWindows()) {
+            // '*' has to be escaped on windows
+            for (int i = 0; i < cmd.length; ++i) {
+                cmd[i] = cmd[i].replace("*", "\"*\"");
+            }
+        }
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmd);
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         dump(output, "compile");
--- a/jaxp/.hgtags	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/.hgtags	Wed Jul 05 23:09:40 2017 +0200
@@ -405,3 +405,6 @@
 5695854e8831d0c088ab0ecf83b367ec16c9760a jdk-9+159
 fb8f2c8e15295120ff0f281dc057cfffb309e90e jdk-9+160
 51b63f1b8001a48a16805b43babc3af7b314d501 jdk-9+161
+d02b6fbcab06c59a5f5a4a6736bd4ec6d2567855 jdk-9+162
+92a38c75cd277d8b11f4382511a62087044659a1 jdk-9+163
+6dc790a4e8310c86712cfdf7561a9820818546e6 jdk-9+164
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -486,7 +486,7 @@
             ModuleDescriptor descriptor =
                 ModuleDescriptor.newModule(mn, Set.of(ModuleDescriptor.Modifier.SYNTHETIC))
                                 .requires("java.xml")
-                                .exports(pn)
+                                .exports(pn, Set.of("java.xml"))
                                 .build();
 
             Module m = createModule(descriptor, loader);
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -88,6 +88,7 @@
     /**
      * Construct a Catalog with specified URI.
      *
+     * @param f the features object
      * @param uris the uri(s) to one or more catalogs
      * @throws CatalogException If an error happens while parsing the specified
      * catalog file.
@@ -100,6 +101,7 @@
      * Construct a Catalog with specified URI.
      *
      * @param parent The parent catalog
+     * @param f the features object
      * @param uris the uri(s) to one or more catalogs
      * @throws CatalogException If an error happens while parsing the specified
      * catalog file.
@@ -137,7 +139,7 @@
             for (String temp : catalogFile) {
                 uri = URI.create(temp);
                 start++;
-                if (verifyCatalogFile(uri)) {
+                if (verifyCatalogFile(null, uri)) {
                     systemId = temp;
                     try {
                         baseURI = new URL(systemId);
@@ -169,12 +171,14 @@
             parse(systemId);
         }
 
+        setCatalog(this);
+
         //save this catalog before loading the next
         loadedCatalogs.put(systemId, this);
 
         //Load delegate and alternative catalogs if defer is false.
         if (!isDeferred()) {
-           loadDelegateCatalogs();
+           loadDelegateCatalogs(this);
            loadNextCatalogs();
         }
     }
@@ -365,14 +369,16 @@
                 //Check those specified in nextCatalogs
                 if (nextCatalogs != null) {
                     while (c == null && nextCatalogIndex < nextCatalogs.size()) {
-                        c = getCatalog(nextCatalogs.get(nextCatalogIndex++).getCatalogURI());
+                        c = getCatalog(catalog,
+                                nextCatalogs.get(nextCatalogIndex++).getCatalogURI());
                     }
                 }
 
                 //Check the input list
                 if (c == null && inputFiles != null) {
                     while (c == null && inputFilesIndex < inputFiles.size()) {
-                        c = getCatalog(URI.create(inputFiles.get(inputFilesIndex++)));
+                        c = getCatalog(null,
+                                URI.create(inputFiles.get(inputFilesIndex++)));
                     }
                 }
 
@@ -408,14 +414,14 @@
         //loads catalogs specified in nextCatalogs
         if (nextCatalogs != null) {
             nextCatalogs.stream().forEach((next) -> {
-                getCatalog(next.getCatalogURI());
+                getCatalog(this, next.getCatalogURI());
             });
         }
 
         //loads catalogs from the input list
         if (inputFiles != null) {
             inputFiles.stream().forEach((uri) -> {
-                getCatalog(URI.create(uri));
+                getCatalog(null, URI.create(uri));
             });
         }
     }
@@ -423,17 +429,19 @@
     /**
      * Returns a Catalog object by the specified path.
      *
-     * @param path the path to a catalog
+     * @param parent the parent catalog for the alternative catalogs to be loaded.
+     * It will be null if the ones to be loaded are from the input list.
+     * @param uri the path to a catalog
      * @return a Catalog object
      */
-    Catalog getCatalog(URI uri) {
+    Catalog getCatalog(CatalogImpl parent, URI uri) {
         if (uri == null) {
             return null;
         }
 
         CatalogImpl c = null;
 
-        if (verifyCatalogFile(uri)) {
+        if (verifyCatalogFile(parent, uri)) {
             c = getLoadedCatalog(uri.toASCIIString());
             if (c == null) {
                 c = new CatalogImpl(this, features, uri);
@@ -459,6 +467,6 @@
      * @return a count of all loaded catalogs
      */
     int loadedCatalogCount() {
-        return loadedCatalogs.size() + delegateCatalogs.size();
+        return loadedCatalogs.size();
     }
 }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.properties	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -1,4 +1,4 @@
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -21,25 +21,32 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 
-# Messages for message reporting
-BadMessageKey = The error message corresponding to the message key can not be found.
-FormatFailed = An internal error occurred while formatting the following message:\n
+# General errors
+BadMessageKey = JAXP09000001: The error message corresponding to the message key can not be found.
+FormatFailed = JAXP09000002: An internal error occurred while formatting the following message:\n
+OtherError = JAXP09000003: Unexpected error.
 
-#invalid catalog file
-InvalidCatalog = The document element of a catalog must be catalog.
-InvalidEntryType = The entry type ''{0}'' is not valid.
-CircularReference = Circular reference is not allowed: ''{0}''.
+# Implementation restriction
+CircularReference = JAXP09010001: Circular reference is not allowed: ''{0}''.
 
-#errors
-UriNotAbsolute = The specified URI ''{0}'' is not absolute.
-UriNotValidUrl = The specified URI ''{0}'' is not a valid URL.
-InvalidArgument = The specified argument ''{0}'' (case sensitive) for ''{1}'' is not valid.
-NullArgument = The argument ''{0}'' can not be null.
-InvalidPath = The path ''{0}'' is invalid.
-ParserConf = Unexpected error while configuring a SAX parser.
-ParsingFailed = Failed to parse the catalog file.
-NoCatalogFound = No Catalog is specified.
-NoMatchFound = No match found for publicId ''{0}'' and systemId ''{1}''.
-NoMatchURIFound = No match found for href ''{0}'' and base ''{1}''.
-FailedCreatingURI = Can not construct URI using href ''{0}'' and base ''{1}''.
-OtherError = Unexpected error.
\ No newline at end of file
+# Input or configuration errors
+InvalidCatalog = JAXP09020001: The document element of a catalog must be catalog.
+InvalidEntryType = JAXP09020002: The entry type ''{0}'' is not valid.
+UriNotAbsolute = JAXP09020003: The specified URI ''{0}'' is not absolute.
+UriNotValidUrl = JAXP09020004: The specified URI ''{0}'' is not a valid URL.
+InvalidArgument = JAXP09020005: The specified argument ''{0}'' (case sensitive) for ''{1}'' is not valid.
+NullArgument = JAXP09020006: The argument ''{0}'' can not be null.
+InvalidPath = JAXP09020007: The path ''{0}'' is invalid.
+
+
+# Parsing errors
+ParserConf = JAXP09030001: Unexpected error while configuring a SAX parser.
+ParsingFailed = JAXP09030002: Failed to parse the catalog file.
+NoCatalogFound = JAXP09030003: No Catalog is specified.
+
+
+# Resolving errors
+NoMatchFound = JAXP09040001: No match found for publicId ''{0}'' and systemId ''{1}''.
+NoMatchURIFound = JAXP09040002: No match found for href ''{0}'' and base ''{1}''.
+FailedCreatingURI = JAXP09040003: Can not construct URI using href ''{0}'' and base ''{1}''.
+
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java	Wed Jul 05 23:09:40 2017 +0200
@@ -135,7 +135,8 @@
     /**
      * Constructs a GroupEntry
      *
-     * @param type The type of the entry
+     * @param type the type of the entry
+     * @param parent the parent Catalog
      */
     public GroupEntry(CatalogEntryType type, CatalogImpl parent) {
         super(type);
@@ -165,9 +166,9 @@
     }
     /**
      * Constructs a group entry.
-     * @param catalog The catalog this GroupEntry belongs
-     * @param base The baseURI attribute
-     * @param attributes The attributes
+     * @param catalog the catalog this GroupEntry belongs to
+     * @param base the baseURI attribute
+     * @param attributes the attributes
      */
     public GroupEntry(CatalogImpl catalog, String base, String... attributes) {
         super(CatalogEntryType.GROUP, base);
@@ -176,6 +177,15 @@
     }
 
     /**
+     * Sets the catalog for this GroupEntry.
+     *
+     * @param catalog the catalog this GroupEntry belongs to
+     */
+    void setCatalog(CatalogImpl catalog) {
+        this.catalog = catalog;
+    }
+
+    /**
      * Adds an entry.
      *
      * @param entry The entry to be added.
@@ -382,10 +392,9 @@
     /**
      * Matches delegatePublic or delegateSystem against the specified id
      *
-     * @param isSystem The flag to indicate whether the delegate is system or
-     * public
-     * @param id The system or public id to be matched
-     * @return The URI string if a mapping is found, or null otherwise.
+     * @param type the type of the Catalog entry
+     * @param id the system or public id to be matched
+     * @return the URI string if a mapping is found, or null otherwise.
      */
     private String matchDelegate(CatalogEntryType type, String id) {
         String match = null;
@@ -412,7 +421,7 @@
 
         //Check delegate Catalogs
         if (catalogId != null) {
-            Catalog delegateCatalog = loadCatalog(catalogId);
+            Catalog delegateCatalog = loadDelegateCatalog(catalog, catalogId);
 
             if (delegateCatalog != null) {
                 if (type == CatalogEntryType.DELEGATESYSTEM) {
@@ -430,30 +439,34 @@
 
     /**
      * Loads all delegate catalogs.
+     *
+     * @param parent the parent catalog of the delegate catalogs
      */
-    void loadDelegateCatalogs() {
+    void loadDelegateCatalogs(CatalogImpl parent) {
         entries.stream()
                 .filter((entry) -> (entry.type == CatalogEntryType.DELEGATESYSTEM ||
                         entry.type == CatalogEntryType.DELEGATEPUBLIC ||
                         entry.type == CatalogEntryType.DELEGATEURI))
                 .map((entry) -> (AltCatalog)entry)
                 .forEach((altCatalog) -> {
-                        loadCatalog(altCatalog.getCatalogURI());
+                        loadDelegateCatalog(parent, altCatalog.getCatalogURI());
         });
     }
 
     /**
      * Loads a delegate catalog by the catalogId specified.
-     * @param catalogId the catalog Id
+     *
+     * @param parent the parent catalog of the delegate catalog
+     * @param catalogURI the URI to the catalog
      */
-    Catalog loadCatalog(URI catalogURI) {
+    Catalog loadDelegateCatalog(CatalogImpl parent, URI catalogURI) {
         CatalogImpl delegateCatalog = null;
         if (catalogURI != null) {
             String catalogId = catalogURI.toASCIIString();
-            delegateCatalog = getLoadedCatalog(catalogId);
-            if (delegateCatalog == null) {
-                if (verifyCatalogFile(catalogURI)) {
-                    delegateCatalog = new CatalogImpl(catalog, features, catalogURI);
+            if (verifyCatalogFile(parent, catalogURI)) {
+                delegateCatalog = getLoadedCatalog(catalogId);
+                if (delegateCatalog == null) {
+                    delegateCatalog = new CatalogImpl(parent, features, catalogURI);
                     delegateCatalog.load();
                     delegateCatalogs.put(catalogId, delegateCatalog);
                 }
@@ -473,7 +486,7 @@
     CatalogImpl getLoadedCatalog(String catalogId) {
         CatalogImpl c = null;
 
-        //checl delegate Catalogs
+        //check delegate Catalogs
         c = delegateCatalogs.get(catalogId);
         if (c == null) {
             //check other loaded Catalogs
@@ -492,11 +505,12 @@
      * Verifies that the catalog represented by the catalogId has not been
      * searched or is not circularly referenced.
      *
-     * @param catalogId The URI to a catalog
+     * @param parent the parent of the catalog to be loaded
+     * @param catalogURI the URI to the catalog
      * @throws CatalogException if circular reference is found.
      * @return true if the catalogId passed verification, false otherwise
      */
-    final boolean verifyCatalogFile(URI catalogURI) {
+    final boolean verifyCatalogFile(CatalogImpl parent, URI catalogURI) {
         if (catalogURI == null) {
             return false;
         }
@@ -508,7 +522,7 @@
         }
 
         String catalogId = catalogURI.toASCIIString();
-        if (catalogsSearched.contains(catalogId) || isCircular(catalogId)) {
+        if (catalogsSearched.contains(catalogId) || isCircular(parent, catalogId)) {
             CatalogMessages.reportRunTimeError(CatalogMessages.ERR_CIRCULAR_REFERENCE,
                     new Object[]{CatalogMessages.sanitize(catalogId)});
         }
@@ -518,10 +532,13 @@
 
     /**
      * Checks whether the catalog is circularly referenced
+     *
+     * @param parent the parent of the catalog to be loaded
      * @param systemId the system identifier of the catalog to be loaded
      * @return true if is circular, false otherwise
      */
-    boolean isCircular(String systemId) {
+    boolean isCircular(CatalogImpl parent, String systemId) {
+        // first, check the parent of the catalog to be loaded
         if (parent == null) {
             return false;
         }
@@ -530,6 +547,7 @@
             return true;
         }
 
-        return parent.isCircular(systemId);
+       // next, check parent's parent
+        return parent.isCircular(parent.parent, systemId);
     }
 }
--- a/jaxp/src/java.xml/share/classes/javax/xml/stream/FactoryFinder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/FactoryFinder.java	Wed Jul 05 23:09:40 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
@@ -270,7 +270,7 @@
                     "Failed to read factoryId '" + factoryId + "'", se);
         }
 
-        // Try read $java.home/lib/stax.properties followed by
+        // Try read $java.home/conf/stax.properties followed by
         // $java.home/conf/jaxp.properties if former not present
         String configFile = null;
         try {
@@ -278,7 +278,7 @@
                 synchronized (cacheProps) {
                     if (firstTime) {
                         configFile = ss.getSystemProperty("java.home") + File.separator +
-                            "lib" + File.separator + "stax.properties";
+                            "conf" + File.separator + "stax.properties";
                         final File fStax = new File(configFile);
                         firstTime = false;
                         if (ss.doesFileExist(fStax)) {
--- a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java	Wed Jul 05 23:09:40 2017 +0200
@@ -155,7 +155,7 @@
    *              #newFactory(java.lang.String, java.lang.ClassLoader)}
    *              method defines no changes in behavior.
    */
-  @Deprecated(since="7")
+  @Deprecated(since="1.7")
   public static XMLEventFactory newInstance(String factoryId,
           ClassLoader classLoader)
           throws FactoryConfigurationError {
--- a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLInputFactory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLInputFactory.java	Wed Jul 05 23:09:40 2017 +0200
@@ -222,7 +222,7 @@
    *   java.util.ServiceConfigurationError service configuration error} or if
    *   the implementation is not available or cannot be instantiated.
    */
-  @Deprecated(since="7")
+  @Deprecated(since="1.7")
   public static XMLInputFactory newFactory()
     throws FactoryConfigurationError
   {
@@ -244,7 +244,7 @@
    *              #newFactory(java.lang.String, java.lang.ClassLoader)} method
    *              defines no changes in behavior.
    */
-  @Deprecated(since="7")
+  @Deprecated(since="1.7")
   public static XMLInputFactory newInstance(String factoryId,
           ClassLoader classLoader)
           throws FactoryConfigurationError {
--- a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLOutputFactory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLOutputFactory.java	Wed Jul 05 23:09:40 2017 +0200
@@ -222,7 +222,7 @@
    *              Use the new method {@link #newFactory(java.lang.String,
    *              java.lang.ClassLoader)} instead.
    */
-  @Deprecated(since="7")
+  @Deprecated(since="1.7")
   public static XMLInputFactory newInstance(String factoryId,
           ClassLoader classLoader)
           throws FactoryConfigurationError {
--- a/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2016, 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
@@ -176,9 +176,9 @@
 
         String javah = ss.getSystemProperty( "java.home" );
         String configFile = javah + File.separator +
-        "lib" + File.separator + "jaxp.properties";
+        "conf" + File.separator + "jaxp.properties";
 
-        // try to read from $java.home/lib/jaxp.properties
+        // try to read from $java.home/conf/jaxp.properties
         try {
             if(firstTime){
                 synchronized(cacheProps){
@@ -193,7 +193,7 @@
                 }
             }
             final String factoryClassName = cacheProps.getProperty(propertyName);
-            debugPrintln(()->"found " + factoryClassName + " in $java.home/jaxp.properties");
+            debugPrintln(()->"found " + factoryClassName + " in $java.home/conf/jaxp.properties");
 
             if (factoryClassName != null) {
                 xpathFactory = createInstance(factoryClassName, true);
--- a/jaxp/src/java.xml/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
  * Defines the Java API for XML Processing (JAXP), the Streaming API for XML (StAX),
  * the Simple API for XML (SAX), and the W3C Document Object Model (DOM) API.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.xml {
--- a/jaxp/src/java.xml/share/classes/org/xml/sax/AttributeList.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/org/xml/sax/AttributeList.java	Wed Jul 05 23:09:40 2017 +0200
@@ -93,7 +93,7 @@
  * @see org.xml.sax.DocumentHandler#startElement startElement
  * @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl
  */
-@Deprecated(since="5")
+@Deprecated(since="1.5")
 public interface AttributeList {
 
 
--- a/jaxp/src/java.xml/share/classes/org/xml/sax/DocumentHandler.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/org/xml/sax/DocumentHandler.java	Wed Jul 05 23:09:40 2017 +0200
@@ -68,7 +68,7 @@
  * @see org.xml.sax.Locator
  * @see org.xml.sax.HandlerBase
  */
-@Deprecated(since="5")
+@Deprecated(since="1.5")
 public interface DocumentHandler {
 
 
--- a/jaxp/src/java.xml/share/classes/org/xml/sax/Parser.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/org/xml/sax/Parser.java	Wed Jul 05 23:09:40 2017 +0200
@@ -73,7 +73,7 @@
  * @see org.xml.sax.HandlerBase
  * @see org.xml.sax.InputSource
  */
-@Deprecated(since="5")
+@Deprecated(since="1.5")
 public interface Parser
 {
 
--- a/jaxp/src/java.xml/share/classes/org/xml/sax/helpers/ParserFactory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/org/xml/sax/helpers/ParserFactory.java	Wed Jul 05 23:09:40 2017 +0200
@@ -64,7 +64,7 @@
  * @version 2.0.1 (sax2r2)
  */
 @SuppressWarnings( "deprecation" )
-@Deprecated(since="5")
+@Deprecated(since="1.5")
 public class ParserFactory {
     private static SecuritySupport ss = new SecuritySupport();
 
--- a/jaxp/src/java.xml/share/legal/bcel.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/legal/bcel.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
-## Apache Byte Code Engineering Library v5.2
+## Apache Byte Code Engineering Library (BCEL) v5.2
 
-### Notice
+### Apache BCEL Notice
 <pre>
 
     =========================================================================
--- a/jaxp/src/java.xml/share/legal/dom.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/legal/dom.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
-## DOM Level 3 core specification, v1.0
+## DOM Level 3 Core Specification v1.0
 
-## W3C License
+### W3C License
 <pre>
 
 W3C SOFTWARE NOTICE AND LICENSE
--- a/jaxp/src/java.xml/share/legal/xalan.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/legal/xalan.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 ## Apache Xalan v2.7.1
 
-### Notice
+### Apache Xalan Notice
 <pre>
 
     ======================================================================================
--- a/jaxp/src/java.xml/share/legal/xerces.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/legal/xerces.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,7 +1,7 @@
 ## Apache Xerces v2.11.0
 
-### Notice
-
+### Apache Xerces Notice
+<pre>
     =========================================================================
     == NOTICE file corresponding to section 4(d) of the Apache License, ==
     == Version 2.0, in this case for the Apache Xerces Java distribution. ==
@@ -17,6 +17,7 @@
     - voluntary contributions made by Paul Eng on behalf of the
     Apache Software Foundation that were originally developed at iClick, Inc.,
     software copyright (c) 1999.
+</pre>
 
 ### Apache 2.0 License
 <pre>
--- a/jaxp/src/java.xml/share/legal/xmlresolver.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/java.xml/share/legal/xmlresolver.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 ## Apache XML Resolver Library v1.2
 
-### Notice
+### Apache XML Resolver Notice
 <pre>
 
 Apache XML Commons Resolver
--- a/jaxp/src/jdk.xml.dom/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/src/jdk.xml.dom/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
  * Defines the subset of the W3C Document Object Model (DOM) API that is not part
  * of the Java SE API.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.xml.dom {
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java	Wed Jul 05 23:09:40 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,14 +27,16 @@
 import static catalog.CatalogTestUtils.DEFER_TRUE;
 import static catalog.CatalogTestUtils.getCatalogPath;
 import static javax.xml.catalog.CatalogFeatures.Feature.DEFER;
-import static javax.xml.catalog.CatalogManager.catalog;
 import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
 import static jaxp.library.JAXPTestUtilities.tryRunWithAllPerm;
 
 import java.lang.reflect.Method;
 
 import javax.xml.catalog.Catalog;
+import javax.xml.catalog.CatalogException;
 import javax.xml.catalog.CatalogFeatures;
+import javax.xml.catalog.CatalogManager;
+import javax.xml.catalog.CatalogResolver;
 
 import org.testng.Assert;
 import org.testng.annotations.DataProvider;
@@ -43,7 +45,7 @@
 
 /*
  * @test
- * @bug 8077931
+ * @bug 8077931 8176405
  * @library /javax/xml/jaxp/libs
  * @modules java.xml/javax.xml.catalog:open
  * @run testng/othervm -DrunSecMngr=true catalog.DeferFeatureTest
@@ -61,6 +63,18 @@
         Assert.assertEquals(loadedCatalogCount(catalog), catalogCount);
     }
 
+    @Test(dataProvider = "testDeferFeatureByResolve")
+    public void testDeferFeatureByResolve(Catalog catalog, int catalogCount)
+            throws Exception {
+        CatalogResolver cr = createResolver(catalog);
+        // trigger loading alternative catalogs
+        try {
+            cr.resolveEntity("-//REMOTE//DTD ALICE DOCALICE", "http://remote/dtd/alice/");
+        } catch (CatalogException ce) {}
+
+        Assert.assertEquals(loadedCatalogCount(catalog), catalogCount);
+    }
+
     @DataProvider(name = "catalog-countOfLoadedCatalogFile")
     public Object[][] data() {
         return new Object[][]{
@@ -73,12 +87,23 @@
             {createCatalog(createDeferFeature(DEFER_FALSE)), 4}};
     }
 
+    @DataProvider(name = "testDeferFeatureByResolve")
+    public Object[][] getData() {
+        return new Object[][]{
+            {createCatalog(createDeferFeature(DEFER_TRUE)), 4}
+        };
+    }
+
     private CatalogFeatures createDeferFeature(String defer) {
         return CatalogFeatures.builder().with(DEFER, defer).build();
     }
 
     private Catalog createCatalog(CatalogFeatures feature) {
-        return catalog(feature, getCatalogPath("deferFeature.xml"));
+        return CatalogManager.catalog(feature, getCatalogPath("deferFeature.xml"));
+    }
+
+    private CatalogResolver createResolver(Catalog catalog) {
+        return CatalogManager.catalogResolver(catalog);
     }
 
     private int loadedCatalogCount(Catalog catalog) throws Exception {
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -88,35 +88,6 @@
     }
 
     /*
-     * @bug 8162431
-     * Verifies that circular references are caught and
-     * CatalogException is thrown.
-     */
-    @Test(dataProvider = "getFeatures", expectedExceptions = CatalogException.class)
-    public void testCircularRef(CatalogFeatures cf, String xml) throws Exception {
-        CatalogResolver catalogResolver = CatalogManager.catalogResolver(
-                cf,
-                getClass().getResource(xml).toURI());
-        catalogResolver.resolve("anyuri", "");
-    }
-
-    /*
-       DataProvider: used to verify circular reference
-        Data columns: CatalogFeatures, catalog
-     */
-    @DataProvider(name = "getFeatures")
-    public Object[][] getFeatures() {
-        String self = "catalogReferCircle-itself.xml";
-        String left = "catalogReferCircle-left.xml";
-        return new Object[][]{
-            {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(), self},
-            {CatalogFeatures.defaults(), self},
-            {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(), left},
-            {CatalogFeatures.defaults(), left}
-        };
-    }
-
-    /*
      * @bug 8163232
      * Verifies that the CatalogResolver supports the following XML Resolvers:
           javax.xml.stream.XMLResolver
@@ -437,7 +408,10 @@
     public void resolveWithPrefer(String prefer, String cfile, String publicId,
             String systemId, String expected) throws Exception {
         URI catalogFile = getClass().getResource(cfile).toURI();
-        CatalogFeatures f = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).with(CatalogFeatures.Feature.RESOLVE, "ignore").build();
+        CatalogFeatures f = CatalogFeatures.builder()
+                .with(CatalogFeatures.Feature.PREFER, prefer)
+                .with(CatalogFeatures.Feature.RESOLVE, "ignore")
+                .build();
         CatalogResolver catalogResolver = CatalogManager.catalogResolver(f, catalogFile);
         String result = catalogResolver.resolveEntity(publicId, systemId).getSystemId();
         Assert.assertEquals(expected, result);
@@ -452,7 +426,9 @@
     @Test(dataProvider = "invalidAltCatalogs", expectedExceptions = CatalogException.class)
     public void testDeferAltCatalogs(String file) throws Exception {
         URI catalogFile = getClass().getResource(file).toURI();
-        CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "true").build();
+        CatalogFeatures features = CatalogFeatures.builder().
+                with(CatalogFeatures.Feature.DEFER, "true")
+                .build();
         /*
           Since the defer attribute is set to false in the specified catalog file,
           the parent catalog will try to load the alt catalog, which will fail
@@ -471,11 +447,17 @@
         URI catalogFile = getClass().getResource("JDK8146237_catalog.xml").toURI();
 
         try {
-            CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, "system").build();
+            CatalogFeatures features = CatalogFeatures.builder()
+                    .with(CatalogFeatures.Feature.PREFER, "system")
+                    .build();
             Catalog catalog = CatalogManager.catalog(features, catalogFile);
             CatalogResolver catalogResolver = CatalogManager.catalogResolver(catalog);
-            String actualSystemId = catalogResolver.resolveEntity("-//FOO//DTD XML Dummy V0.0//EN", "http://www.oracle.com/alt1sys.dtd").getSystemId();
-            Assert.assertTrue(actualSystemId.contains("dummy.dtd"), "Resulting id should contain dummy.dtd, indicating a match by publicId");
+            String actualSystemId = catalogResolver.resolveEntity(
+                    "-//FOO//DTD XML Dummy V0.0//EN",
+                    "http://www.oracle.com/alt1sys.dtd")
+                    .getSystemId();
+            Assert.assertTrue(actualSystemId.contains("dummy.dtd"),
+                    "Resulting id should contain dummy.dtd, indicating a match by publicId");
 
         } catch (Exception e) {
             Assert.fail(e.getMessage());
@@ -572,20 +554,21 @@
     */
     @Test
     public void testInvalidCatalog() throws Exception {
+        String expectedMsgId = "JAXP09040001";
         URI catalog = getClass().getResource("catalog_invalid.xml").toURI();
 
-        String test = "testInvalidCatalog";
         try {
-            CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog);
-            String actualSystemId = resolver.resolveEntity(null, "http://remote/xml/dtd/sys/alice/docAlice.dtd").getSystemId();
+            CatalogResolver resolver = CatalogManager.catalogResolver(
+                    CatalogFeatures.defaults(), catalog);
+            String actualSystemId = resolver.resolveEntity(
+                    null,
+                    "http://remote/xml/dtd/sys/alice/docAlice.dtd")
+                    .getSystemId();
         } catch (Exception e) {
             String msg = e.getMessage();
             if (msg != null) {
-                if (msg.contains("No match found for publicId")) {
-                    Assert.assertEquals(msg, "No match found for publicId 'null' and systemId 'http://remote/xml/dtd/sys/alice/docAlice.dtd'.");
-                    System.out.println(test + ": expected [No match found for publicId 'null' and systemId 'http://remote/xml/dtd/sys/alice/docAlice.dtd'.]");
-                    System.out.println("actual [" + msg + "]");
-                }
+                Assert.assertTrue(msg.contains(expectedMsgId),
+                        "Message shall contain the corrent message ID " + expectedMsgId);
             }
         }
     }
@@ -607,7 +590,10 @@
         String test = "testInvalidCatalog";
         try {
             CatalogResolver resolver = CatalogManager.catalogResolver(f);
-            String actualSystemId = resolver.resolveEntity(null, "http://remote/xml/dtd/sys/alice/docAlice.dtd").getSystemId();
+            String actualSystemId = resolver.resolveEntity(
+                    null,
+                    "http://remote/xml/dtd/sys/alice/docAlice.dtd")
+                    .getSystemId();
             System.out.println("testIgnoreInvalidCatalog: expected [null]");
             System.out.println("testIgnoreInvalidCatalog: expected [null]");
             System.out.println("actual [" + actualSystemId + "]");
@@ -628,7 +614,11 @@
     @DataProvider(name = "resolveUri")
     public Object[][] getDataForUriResolver() {
         return new Object[][]{
-            {"uri.xml", "urn:publicid:-:Acme,+Inc.:DTD+Book+Version+1.0", null, "http://local/base/dtd/book.dtd", "Uri in publicId namespace is incorrectly unwrapped"},
+            {"uri.xml",
+                "urn:publicid:-:Acme,+Inc.:DTD+Book+Version+1.0",
+                null,
+                "http://local/base/dtd/book.dtd",
+                "Uri in publicId namespace is incorrectly unwrapped"},
         };
     }
 
@@ -654,7 +644,13 @@
     public Object[][] getDataForMatchingBothIds() {
         String expected = "http://www.groupxmlbase.com/dtds/rewrite.dtd";
         return new Object[][]{
-            {"rewriteSystem_id.xml", "system", "http://www.sys00test.com/rewrite.dtd", "PUB-404", expected, expected, "Relative rewriteSystem with xml:base at group level failed"},
+            {"rewriteSystem_id.xml",
+                "system",
+                "http://www.sys00test.com/rewrite.dtd",
+                "PUB-404",
+                expected,
+                expected,
+                "Relative rewriteSystem with xml:base at group level failed"},
         };
     }
 
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml	Sat Apr 08 03:25:14 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
-    <nextCatalog catalog="catalogReferCircle-itself.xml" />
-</catalog>
-
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml	Sat Apr 08 03:25:14 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
-    <nextCatalog catalog="catalogReferCircle-right.xml" />
-</catalog>
-
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml	Sat Apr 08 03:25:14 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
-    <nextCatalog catalog="catalogReferCircle-left.xml" />
-</catalog>
-
--- a/jaxws/.hgtags	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxws/.hgtags	Wed Jul 05 23:09:40 2017 +0200
@@ -408,3 +408,6 @@
 0ea34706c7fa5cd71accd493eb4f54262e4a5f4e jdk-9+159
 6bff08fd5d217549aec10a20007378e52099be6c jdk-9+160
 7d5352c54fc802b3301d8433b6b2b2a92b616630 jdk-9+161
+b8aebe5292f23689f97cb8e66a9f327834dd43e6 jdk-9+162
+3890f96e8995be8c84f330d1f65269b03ac36b24 jdk-9+163
+1a52de2da827459e866fd736f9e9c62eb2ecd6bb jdk-9+164
--- a/jaxws/src/java.activation/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxws/src/java.activation/share/classes/module-info.java	Wed Jul 05 23:09:40 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
@@ -26,8 +26,10 @@
 /**
  * Defines the JavaBeans Activation Framework (JAF) API.
  *
+ * @moduleGraph
  * @since 9
  */
+@Deprecated(since="9", forRemoval=true)
 module java.activation {
     requires transitive java.datatransfer;
     requires java.logging;
--- a/jaxws/src/java.xml.bind/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxws/src/java.xml.bind/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,8 +26,10 @@
 /**
  * Defines the Java Architecture for XML Binding (JAXB) API.
  *
+ * @moduleGraph
  * @since 9
  */
+@Deprecated(since="9", forRemoval=true)
 module java.xml.bind {
     requires transitive java.activation;
     requires transitive java.xml;
--- a/jaxws/src/java.xml.ws.annotation/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxws/src/java.xml.ws.annotation/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,8 +27,10 @@
  * Defines a subset of the Common Annotations API to support programs running
  * on the Java SE Platform.
  *
+ * @moduleGraph
  * @since 9
  */
+@Deprecated(since="9", forRemoval=true)
 module java.xml.ws.annotation {
     exports javax.annotation;
 }
--- a/jaxws/src/java.xml.ws/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxws/src/java.xml.ws/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,8 +27,10 @@
  * Defines the Java API for XML-Based Web Services (JAX-WS), and
  * the Web Services Metadata API.
  *
+ * @moduleGraph
  * @since 9
  */
+@Deprecated(since="9", forRemoval=true)
 module java.xml.ws {
     requires transitive java.activation;
     requires transitive java.xml;
--- a/jaxws/src/jdk.xml.bind/share/legal/xmlresolver.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jaxws/src/jdk.xml.bind/share/legal/xmlresolver.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 ## Apache XML Resolver Library v1.2
 
-### Notice
+### Apache XML Resolver Notice
 <pre>
 
 Apache XML Commons Resolver
--- a/jdk/.hgtags	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/.hgtags	Wed Jul 05 23:09:40 2017 +0200
@@ -405,3 +405,6 @@
 49b54a4d9e84b7ba956b8c27fced5035465146ae jdk-9+159
 cac788454598b95d8b0153c021a7fae3cd7e6fda jdk-9+160
 09b92d3067a38ee07bc14efa336b14790c93f7e7 jdk-9+161
+f6bf027e88e9a4dd19f721001a7af00157af42c4 jdk-9+162
+50171f8c47961710cbf87aead6f03fa431d8d240 jdk-9+163
+6dea581453d7c0e767e3169cfec8b423a381e71d jdk-9+164
--- a/jdk/make/GenerateModuleSummary.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/make/GenerateModuleSummary.gmk	Wed Jul 05 23:09:40 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
@@ -31,7 +31,7 @@
 include ModuleTools.gmk
 
 GENGRAPHS_DIR := $(IMAGES_OUTPUTDIR)/gengraphs
-SPEC_DOTFILES_DIR := $(IMAGES_OUTPUTDIR)/spec-dotfiles
+SPEC_DOTFILES_DIR := $(GENGRAPHS_DIR)/spec-dotfiles
 TOOLS_MODULE_SRCDIR := $(JDK_TOPDIR)/make/src/classes/build/tools/jigsaw
 
 $(GENGRAPHS_DIR)/jdk.dot: $(BUILD_JIGSAW_TOOLS)
--- a/jdk/make/ModuleTools.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/make/ModuleTools.gmk	Wed Jul 05 23:09:40 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
@@ -23,8 +23,9 @@
 # questions.
 #
 
-include $(SPEC)
-include MakeBase.gmk
+ifndef _MODULE_TOOLS_GMK
+_MODULE_TOOLS_GMK := 1
+
 include JavaCompilation.gmk
 
 TOOLS_CLASSES_DIR := $(BUILDTOOLS_OUTPUTDIR)/tools_jigsaw_classes
@@ -32,7 +33,7 @@
 # To avoid reevaluating the compilation setup for the tools each time this file
 # is included, the actual compilation is handled by CompileModuleTools.gmk. The
 # following trick is used to be able to declare a dependency on the built tools.
-BUILD_TOOLS_JDK := $(call SetupJavaCompilationCompileTarget, \
+BUILD_JIGSAW_TOOLS := $(call SetupJavaCompilationCompileTarget, \
     BUILD_JIGSAW_TOOLS, $(TOOLS_CLASSES_DIR))
 
 TOOL_GENGRAPHS := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \
@@ -47,3 +48,5 @@
     -cp $(TOOLS_CLASSES_DIR) \
     --add-exports java.base/jdk.internal.module=ALL-UNNAMED \
     build.tools.jigsaw.AddPackagesAttribute
+
+endif # _MODULE_TOOLS_GMK
--- a/jdk/make/copy/Copy-java.base.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/make/copy/Copy-java.base.gmk	Wed Jul 05 23:09:40 2017 +0200
@@ -235,8 +235,10 @@
 
 # JDK license and assembly exception files to be packaged in JMOD
 
-JDK_LICENSE ?= $(TOPDIR)/LICENSE
-JDK_NOTICE  ?= $(TOPDIR)/ASSEMBLY_EXCEPTION
+# The license files may not be present if the source has been obtained using a
+# different license.
+JDK_LICENSE ?= $(wildcard $(TOPDIR)/LICENSE)
+JDK_NOTICE  ?= $(wildcard $(TOPDIR)/ASSEMBLY_EXCEPTION)
 
 $(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \
     FILES := $(JDK_LICENSE) $(JDK_NOTICE), \
@@ -245,4 +247,3 @@
 ))
 
 TARGETS += $(COPY_JDK_NOTICES)
-
--- a/jdk/make/mapfiles/libjava/mapfile-vers	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/make/mapfiles/libjava/mapfile-vers	Wed Jul 05 23:09:40 2017 +0200
@@ -128,7 +128,6 @@
 		Java_java_lang_Class_isInstance;
 		Java_java_lang_Class_registerNatives;
 		Java_java_lang_ClassLoader_findBootstrapClass;
-		Java_java_lang_ClassLoader_defineClass0;
 		Java_java_lang_ClassLoader_defineClass1;
 		Java_java_lang_ClassLoader_defineClass2;
 		Java_java_lang_ClassLoader_findBuiltinLib;
--- a/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
 package build.tools.jigsaw;
 
 import com.sun.tools.jdeps.ModuleDotGraph;
-import com.sun.tools.jdeps.ModuleDotGraph.DotGraphBuilder;
 
 import java.io.IOException;
 import java.lang.module.Configuration;
@@ -36,10 +35,15 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * Generate the DOT file for a module graph for each module in the JDK
@@ -50,13 +54,19 @@
     public static void main(String[] args) throws Exception {
         Path dir = null;
         boolean spec = false;
+        Properties props = null;
         for (int i=0; i < args.length; i++) {
             String arg = args[i];
             if (arg.equals("--spec")) {
                 spec = true;
+            } else if (arg.equals("--dot-attributes")) {
+                if (i++ == args.length) {
+                    throw new IllegalArgumentException("Missing argument: --dot-attributes option");
+                }
+                props = new Properties();
+                props.load(Files.newInputStream(Paths.get(args[i])));
             } else if (arg.equals("--output")) {
-                i++;
-                dir = i < args.length ? Paths.get(args[i]) : null;
+                dir = ++i < args.length ? Paths.get(args[i]) : null;
             } else if (arg.startsWith("-")) {
                 throw new IllegalArgumentException("Invalid option: " + arg);
             }
@@ -67,11 +77,14 @@
             System.exit(1);
         }
 
-        // setup and configure the dot graph attributes
-        initDotGraphAttributes();
         Files.createDirectories(dir);
-
-        GenGraphs genGraphs = new GenGraphs(dir, spec);
+        ModuleGraphAttributes attributes;
+        if (props != null) {
+            attributes = new ModuleGraphAttributes(props);
+        } else {
+            attributes = new ModuleGraphAttributes();
+        }
+        GenGraphs genGraphs = new GenGraphs(dir, spec, attributes);
 
         // print dot file for each module
         Map<String, Configuration> configurations = new HashMap<>();
@@ -99,49 +112,149 @@
         genGraphs.genDotFiles(configurations);
     }
 
-    static void initDotGraphAttributes() {
-        int h = 1000;
-        DotGraphBuilder.weight("java.se", "java.sql.rowset", h * 10);
-        DotGraphBuilder.weight("java.sql.rowset", "java.sql", h * 10);
-        DotGraphBuilder.weight("java.sql", "java.xml", h * 10);
-        DotGraphBuilder.weight("java.xml", "java.base", h * 10);
+    /**
+     * Custom dot file attributes.
+     */
+    static class ModuleGraphAttributes implements ModuleDotGraph.Attributes {
+        static Map<String, String> DEFAULT_ATTRIBUTES = Map.of(
+            "ranksep", "0.6",
+            "fontsize", "12",
+            "fontcolor", BLACK,
+            "fontname", "DejaVuSans",
+            "arrowsize", "1",
+            "arrowwidth", "2",
+            "arrowcolor", DARK_GRAY,
+            // custom
+            "requiresMandatedColor", LIGHT_GRAY,
+            "javaSubgraphColor", ORANGE,
+            "jdkSubgraphColor", BLUE
+        );
+
+        final Map<String, Integer> weights = new HashMap<>();
+        final List<Set<String>> ranks = new ArrayList<>();
+        final Map<String, String> attrs;
+        ModuleGraphAttributes(Map<String, String> attrs) {
+            int h = 1000;
+            weight("java.se", "java.sql.rowset", h * 10);
+            weight("java.sql.rowset", "java.sql", h * 10);
+            weight("java.sql", "java.xml", h * 10);
+            weight("java.xml", "java.base", h * 10);
+
+            ranks.add(Set.of("java.logging", "java.scripting", "java.xml"));
+            ranks.add(Set.of("java.sql"));
+            ranks.add(Set.of("java.compiler", "java.instrument"));
+            ranks.add(Set.of("java.desktop", "java.management"));
+            ranks.add(Set.of("java.corba", "java.xml.ws"));
+            ranks.add(Set.of("java.xml.bind", "java.xml.ws.annotation"));
+
+            this.attrs = attrs;
+        }
+
+        ModuleGraphAttributes() {
+            this(DEFAULT_ATTRIBUTES);
+        }
+        ModuleGraphAttributes(Properties props) {
+            this(toAttributes(props));
+        }
+
+        @Override
+        public double rankSep() {
+            return Double.valueOf(attrs.get("ranksep"));
+        }
+
+        @Override
+        public int fontSize() {
+            return Integer.valueOf(attrs.get("fontsize"));
+        }
+
+        @Override
+        public String fontName() {
+            return attrs.get("fontname");
+        }
 
-        DotGraphBuilder.sameRankNodes(Set.of("java.logging", "java.scripting", "java.xml"));
-        DotGraphBuilder.sameRankNodes(Set.of("java.sql"));
-        DotGraphBuilder.sameRankNodes(Set.of("java.compiler", "java.instrument"));
-        DotGraphBuilder.sameRankNodes(Set.of("java.desktop", "java.management"));
-        DotGraphBuilder.sameRankNodes(Set.of("java.corba", "java.xml.ws"));
-        DotGraphBuilder.sameRankNodes(Set.of("java.xml.bind", "java.xml.ws.annotation"));
-        DotGraphBuilder.setRankSep(0.7);
-        DotGraphBuilder.setFontSize(12);
-        DotGraphBuilder.setArrowSize(1);
-        DotGraphBuilder.setArrowWidth(2);
+        @Override
+        public String fontColor() {
+            return attrs.get("fontcolor");
+        }
+
+        @Override
+        public int arrowSize() {
+            return Integer.valueOf(attrs.get("arrowsize"));
+        }
+
+        @Override
+        public int arrowWidth() {
+            return Integer.valueOf(attrs.get("arrowwidth"));
+        }
+
+        @Override
+        public String arrowColor() {
+            return attrs.get("arrowcolor");
+        }
+
+        @Override
+        public List<Set<String>> ranks() {
+            return ranks;
+        }
+
+        @Override
+        public String requiresMandatedColor() {
+            return attrs.get("requiresMandatedColor");
+        }
+
+        @Override
+        public String javaSubgraphColor() {
+            return attrs.get("javaSubgraphColor");
+        }
+
+        @Override
+        public String jdkSubgraphColor() {
+            return attrs.get("jdkSubgraphColor");
+        }
+
+        @Override
+        public int weightOf(String s, String t) {
+            int w = weights.getOrDefault(s + ":" + t, 1);
+            if (w != 1)
+                return w;
+            if (s.startsWith("java.") && t.startsWith("java."))
+                return 10;
+            return 1;
+        }
+
+        public void weight(String s, String t, int w) {
+            weights.put(s + ":" + t, w);
+        }
+
+        static Map<String, String> toAttributes(Properties props) {
+            return DEFAULT_ATTRIBUTES.keySet().stream()
+                .collect(Collectors.toMap(Function.identity(),
+                    k -> props.getProperty(k, DEFAULT_ATTRIBUTES.get(k))));
+        }
     }
 
     private final Path dir;
     private final boolean spec;
-    GenGraphs(Path dir, boolean spec) {
+    private final ModuleGraphAttributes attributes;
+    GenGraphs(Path dir, boolean spec, ModuleGraphAttributes attributes) {
         this.dir = dir;
         this.spec = spec;
+        this.attributes = attributes;
     }
 
     void genDotFiles(Map<String, Configuration> configurations) throws IOException {
         ModuleDotGraph dotGraph = new ModuleDotGraph(configurations, spec);
-        dotGraph.genDotFiles(dir);
+        dotGraph.genDotFiles(dir, attributes);
     }
 
+    /**
+     * Returns true for any name if generating graph for non-spec;
+     * otherwise, returns true except "jdk" and name with "jdk.internal." prefix
+     */
     boolean accept(String name, ModuleDescriptor descriptor) {
-        if (!spec) return true;
-
-        if (name.equals("jdk"))
-            return false;
-
-        if (name.equals("java.se") || name.equals("java.se.ee"))
+        if (!spec)
             return true;
 
-        // only the module that has exported API
-        return descriptor.exports().stream()
-                         .filter(e -> !e.isQualified())
-                         .findAny().isPresent();
+        return !name.equals("jdk") && !name.startsWith("jdk.internal.");
     }
-}
\ No newline at end of file
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/src/classes/build/tools/jigsaw/javadoc-graphs.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+arrowcolor=#999999
+requiresMandatedColor=#999999
--- a/jdk/make/src/classes/build/tools/taglet/Incubating.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/make/src/classes/build/tools/taglet/Incubating.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,7 @@
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Set;
+import javax.lang.model.element.Element;
 import com.sun.source.doctree.DocTree;
 import jdk.javadoc.doclet.Taglet;
 import static jdk.javadoc.doclet.Taglet.Location.*;
@@ -59,7 +60,7 @@
                 + " Will be removed in a future release.</b>";
 
     @Override
-    public String toString(List<? extends DocTree> tags) {
+    public String toString(List<? extends DocTree> tags, Element elem) {
         return MESSAGE;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/src/classes/build/tools/taglet/ModuleGraph.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,96 @@
+/*
+ * 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 build.tools.taglet;
+
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import javax.lang.model.element.Element;
+import com.sun.source.doctree.DocTree;
+import jdk.javadoc.doclet.Taglet;
+import static jdk.javadoc.doclet.Taglet.Location.*;
+
+/**
+ * A block tag to optionally insert a reference to a module graph.
+ */
+public class ModuleGraph implements Taglet {
+    private static final boolean enableModuleGraph =
+        Boolean.getBoolean("enableModuleGraph");
+
+    /** Returns the set of locations in which a taglet may be used. */
+    @Override
+    public Set<Location> getAllowedLocations() {
+        return EnumSet.of(MODULE);
+    }
+
+    @Override
+    public boolean isInlineTag() {
+        return false;
+    }
+
+    @Override
+    public String getName() {
+        return "moduleGraph";
+    }
+
+    @Override
+    public String toString(List<? extends DocTree> tags, Element element) {
+        if (!enableModuleGraph) {
+            return "";
+        }
+
+        String moduleName = element.getSimpleName().toString();
+        String imageFile = moduleName + "-graph.png";
+        int thumbnailHeight = -1;
+        String hoverImage = "";
+        if (!moduleName.equals("java.base")) {
+            thumbnailHeight = 100; // also appears in the stylesheet
+            hoverImage = "<span>"
+                + getImage(moduleName, imageFile, -1, true)
+                + "</span>";
+        }
+        return "<dt>"
+            + "<span class=\"simpleTagLabel\">Module Graph:</span>\n"
+            + "</dt>"
+            + "<dd>"
+            + "<a class=moduleGraph href=\"" + imageFile + "\">"
+            + getImage(moduleName, imageFile, thumbnailHeight, false)
+            + hoverImage
+            + "</a>"
+            + "</dd>";
+    }
+
+    private static final String VERTICAL_ALIGN = "vertical-align:top";
+    private static final String BORDER = "border: solid lightgray 1px;";
+
+    private String getImage(String moduleName, String file, int height, boolean useBorder) {
+        return String.format("<img style=\"%s\" alt=\"Module graph for %s\" src=\"%s\"%s>",
+                             useBorder ? BORDER + " " + VERTICAL_ALIGN : VERTICAL_ALIGN,
+                             moduleName,
+                             file,
+                             (height <= 0 ? "" : " height=\"" + height + "\""));
+    }
+}
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java	Wed Jul 05 23:09:40 2017 +0200
@@ -104,7 +104,6 @@
      * @return  {@link Status#ALLOWED Status.ALLOWED} if accepted,
      *          {@link Status#REJECTED Status.REJECTED} if rejected,
      *          {@link Status#UNDECIDED Status.UNDECIDED} if undecided.
-     * @since 9
      */
     Status checkInput(FilterInfo filterInfo);
 
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Wed Jul 05 23:09:40 2017 +0200
@@ -812,23 +812,24 @@
     }
 
     /**
-     * Enable the stream to allow objects read from the stream to be replaced.
-     * When enabled, the resolveObject method is called for every object being
+     * Enables the stream to do replacement of objects read from the stream. When
+     * enabled, the {@link #resolveObject} method is called for every object being
      * deserialized.
      *
-     * <p>If <i>enable</i> is true, and there is a security manager installed,
+     * <p>If object replacement is currently not enabled, and
+     * {@code enable} is true, and there is a security manager installed,
      * this method first calls the security manager's
-     * <code>checkPermission</code> method with the
-     * <code>SerializablePermission("enableSubstitution")</code> permission to
-     * ensure it's ok to enable the stream to allow objects read from the
-     * stream to be replaced.
+     * {@code checkPermission} method with the
+     * {@code SerializablePermission("enableSubstitution")} permission to
+     * ensure that the caller is permitted to enable the stream to do replacement
+     * of objects read from the stream.
      *
-     * @param   enable true for enabling use of <code>resolveObject</code> for
+     * @param   enable true for enabling use of {@code resolveObject} for
      *          every object being deserialized
      * @return  the previous setting before this method was invoked
      * @throws  SecurityException if a security manager exists and its
-     *          <code>checkPermission</code> method denies enabling the stream
-     *          to allow objects read from the stream to be replaced.
+     *          {@code checkPermission} method denies enabling the stream
+     *          to do replacement of objects read from the stream.
      * @see SecurityManager#checkPermission
      * @see java.io.SerializablePermission
      */
--- a/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java	Wed Jul 05 23:09:40 2017 +0200
@@ -589,22 +589,24 @@
     }
 
     /**
-     * Enable the stream to do replacement of objects in the stream.  When
-     * enabled, the replaceObject method is called for every object being
+     * Enables the stream to do replacement of objects written to the stream.  When
+     * enabled, the {@link #replaceObject} method is called for every object being
      * serialized.
      *
-     * <p>If <code>enable</code> is true, and there is a security manager
-     * installed, this method first calls the security manager's
-     * <code>checkPermission</code> method with a
-     * <code>SerializablePermission("enableSubstitution")</code> permission to
-     * ensure it's ok to enable the stream to do replacement of objects in the
-     * stream.
+     * <p>If object replacement is currently not enabled, and
+     * {@code enable} is true, and there is a security manager installed,
+     * this method first calls the security manager's
+     * {@code checkPermission} method with the
+     * {@code SerializablePermission("enableSubstitution")} permission to
+     * ensure that the caller is permitted to enable the stream to do replacement
+     * of objects written to the stream.
      *
-     * @param   enable boolean parameter to enable replacement of objects
+     * @param   enable true for enabling use of {@code replaceObject} for
+     *          every object being serialized
      * @return  the previous setting before this method was invoked
      * @throws  SecurityException if a security manager exists and its
-     *          <code>checkPermission</code> method denies enabling the stream
-     *          to do replacement of objects in the stream.
+     *          {@code checkPermission} method denies enabling the stream
+     *          to do replacement of objects written to the stream.
      * @see SecurityManager#checkPermission
      * @see java.io.SerializablePermission
      */
--- a/jdk/src/java.base/share/classes/java/lang/Class.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java	Wed Jul 05 23:09:40 2017 +0200
@@ -64,9 +64,9 @@
 import jdk.internal.HotSpotIntrinsicCandidate;
 import jdk.internal.loader.BootLoader;
 import jdk.internal.loader.BuiltinClassLoader;
-import jdk.internal.loader.ResourceHelper;
 import jdk.internal.misc.Unsafe;
 import jdk.internal.misc.VM;
+import jdk.internal.module.Resources;
 import jdk.internal.reflect.CallerSensitive;
 import jdk.internal.reflect.ConstantPool;
 import jdk.internal.reflect.Reflection;
@@ -2563,11 +2563,11 @@
 
         Module module = getModule();
         if (module.isNamed()) {
-            if (!ResourceHelper.isSimpleResource(name)) {
+            if (Resources.canEncapsulate(name)) {
                 Module caller = Reflection.getCallerClass().getModule();
                 if (caller != module) {
                     Set<String> packages = module.getDescriptor().packages();
-                    String pn = ResourceHelper.getPackageName(name);
+                    String pn = Resources.toPackageName(name);
                     if (packages.contains(pn) && !module.isOpen(pn, caller)) {
                         // resource is in package not open to caller
                         return null;
@@ -2665,11 +2665,11 @@
 
         Module module = getModule();
         if (module.isNamed()) {
-            if (!ResourceHelper.isSimpleResource(name)) {
+            if (Resources.canEncapsulate(name)) {
                 Module caller = Reflection.getCallerClass().getModule();
                 if (caller != module) {
                     Set<String> packages = module.getDescriptor().packages();
-                    String pn = ResourceHelper.getPackageName(name);
+                    String pn = Resources.toPackageName(name);
                     if (packages.contains(pn) && !module.isOpen(pn, caller)) {
                         // resource is in package not open to caller
                         return null;
@@ -2771,7 +2771,7 @@
          * In all other cases, it requires RuntimePermission("accessDeclaredMembers")
          * permission.
          */
-        final ClassLoader ccl = caller.getClassLoader0();
+        final ClassLoader ccl = ClassLoader.getClassLoader(caller);
         if (which != Member.PUBLIC) {
             final ClassLoader cl = getClassLoader0();
             if (ccl != cl) {
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Wed Jul 05 23:09:40 2017 +0200
@@ -983,7 +983,7 @@
     {
         protectionDomain = preDefineClass(name, protectionDomain);
         String source = defineClassSourceLocation(protectionDomain);
-        Class<?> c = defineClass1(name, b, off, len, protectionDomain, source);
+        Class<?> c = defineClass1(this, name, b, off, len, protectionDomain, source);
         postDefineClass(c, protectionDomain);
         return c;
     }
@@ -1075,17 +1075,17 @@
 
         protectionDomain = preDefineClass(name, protectionDomain);
         String source = defineClassSourceLocation(protectionDomain);
-        Class<?> c = defineClass2(name, b, b.position(), len, protectionDomain, source);
+        Class<?> c = defineClass2(this, name, b, b.position(), len, protectionDomain, source);
         postDefineClass(c, protectionDomain);
         return c;
     }
 
-    private native Class<?> defineClass1(String name, byte[] b, int off, int len,
-                                         ProtectionDomain pd, String source);
+    static native Class<?> defineClass1(ClassLoader loader, String name, byte[] b, int off, int len,
+                                        ProtectionDomain pd, String source);
 
-    private native Class<?> defineClass2(String name, java.nio.ByteBuffer b,
-                                         int off, int len, ProtectionDomain pd,
-                                         String source);
+    static native Class<?> defineClass2(ClassLoader loader, String name, java.nio.ByteBuffer b,
+                                        int off, int len, ProtectionDomain pd,
+                                        String source);
 
     // true if the name is null or has the potential to be a valid binary name
     private boolean checkName(String name) {
--- a/jdk/src/java.base/share/classes/java/lang/LiveStackFrame.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/LiveStackFrame.java	Wed Jul 05 23:09:40 2017 +0200
@@ -169,7 +169,7 @@
      * it denies access to {@code RuntimePermission("liveStackFrames")}; or
      * or if the given {@code options} contains
      * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
-     * and it denies access to {@code StackFramePermission("retainClassReference")}.
+     * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
      */
     public static StackWalker getStackWalker(Set<StackWalker.Option> options) {
         SecurityManager sm = System.getSecurityManager();
--- a/jdk/src/java.base/share/classes/java/lang/Math.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/Math.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1079,6 +1079,7 @@
      * @param x the first value
      * @param y the second value
      * @return the result
+     * @since 9
      */
     public static long multiplyFull(int x, int y) {
         return (long)x * (long)y;
@@ -1091,6 +1092,7 @@
      * @param x the first value
      * @param y the second value
      * @return the result
+     * @since 9
      */
     public static long multiplyHigh(long x, long y) {
         if (x < 0 || y < 0) {
--- a/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1251,6 +1251,7 @@
      *          If the operating system does not support the creation of processes
      *
      * @throws IOException if an I/O error occurs
+     * @since 9
      */
     public static List<Process> startPipeline(List<ProcessBuilder> builders) throws IOException {
         // Accumulate and check the builders
--- a/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java	Wed Jul 05 23:09:40 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
@@ -24,6 +24,7 @@
  */
 package java.lang;
 
+import java.lang.annotation.Native;
 import java.security.PrivilegedAction;
 import java.time.Duration;
 import java.time.Instant;
@@ -57,6 +58,12 @@
     private static long REAPER_DEFAULT_STACKSIZE = 128 * 1024;
 
     /**
+     * Return value from waitForProcessExit0 indicating the process is not a child.
+     */
+    @Native
+    private static final int NOT_A_CHILD = -2;
+
+    /**
      * Cache the ProcessHandle of this process.
      */
     private static final ProcessHandleImpl current;
@@ -131,6 +138,29 @@
                 // spawn a thread to wait for and deliver the exit value
                 processReaperExecutor.execute(() -> {
                     int exitValue = waitForProcessExit0(pid, shouldReap);
+                    if (exitValue == NOT_A_CHILD) {
+                        // pid not alive or not a child of this process
+                        // If it is alive wait for it to terminate
+                        long sleep = 300;     // initial milliseconds to sleep
+                        int incr = 30;        // increment to the sleep time
+
+                        long startTime = isAlive0(pid);
+                        long origStart = startTime;
+                        while (startTime >= 0) {
+                            try {
+                                Thread.sleep(Math.min(sleep, 5000L)); // no more than 5 sec
+                                sleep += incr;
+                            } catch (InterruptedException ie) {
+                                // ignore and retry
+                            }
+                            startTime = isAlive0(pid);  // recheck if is alive
+                            if (origStart > 0 && startTime != origStart) {
+                                // start time changed, pid is not the same process
+                                break;
+                            }
+                        }
+                        exitValue = 0;
+                    }
                     newCompletion.complete(exitValue);
                     // remove from cache afterwards
                     completions.remove(pid, newCompletion);
--- a/jdk/src/java.base/share/classes/java/lang/Runtime.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -955,7 +955,7 @@
      *
      * <p> A <em>version number</em>, {@code $VNUM}, is a non-empty sequence
      * of elements separated by period characters (U+002E).  An element is
-     * either zero, or a unsigned integer numeral without leading zeros.  The
+     * either zero, or an unsigned integer numeral without leading zeros.  The
      * final element in a version number must not be zero.  The format is:
      * </p>
      *
@@ -1053,8 +1053,8 @@
      *
      * </ul>
      *
-     * <p> A version number {@code 10-ea} matches {@code $VNUM = "10"} and
-     * {@code $PRE = "ea"}.  The version number {@code 10+-ea} matches
+     * <p> A version string {@code 10-ea} matches {@code $VNUM = "10"} and
+     * {@code $PRE = "ea"}.  The version string {@code 10+-ea} matches
      * {@code $VNUM = "10"} and {@code $OPT = "ea"}. </p>
      *
      * <p> When comparing two version strings, the value of {@code $OPT}, if
@@ -1247,7 +1247,7 @@
          * Compares this version to another.
          *
          * <p> Each of the components in the <a href="#verStr">version</a> is
-         * compared in the follow order of precedence: version numbers,
+         * compared in the following order of precedence: version numbers,
          * pre-release identifiers, build numbers, optional build information.
          * </p>
          *
@@ -1337,14 +1337,12 @@
             int oSize = ob.version().size();
             int min = Math.min(size, oSize);
             for (int i = 0; i < min; i++) {
-                Integer val = version.get(i);
-                Integer oVal = ob.version().get(i);
+                int val = version.get(i);
+                int oVal = ob.version().get(i);
                 if (val != oVal)
                     return val - oVal;
             }
-            if (size != oSize)
-                return size - oSize;
-            return 0;
+            return size - oSize;
         }
 
         private int comparePre(Version ob) {
@@ -1375,9 +1373,9 @@
             if (oBuild.isPresent()) {
                 return (build.isPresent()
                         ? build.get().compareTo(oBuild.get())
-                        : 1);
+                        : -1);
             } else if (build.isPresent()) {
-                return -1;
+                return 1;
             }
             return 0;
         }
@@ -1461,7 +1459,7 @@
          *
          * @return  {@code true} if, and only if, the given object is a {@code
          *          Version} that is identical to this {@code Version}
-         *          ignoring the optinal build information
+         *          ignoring the optional build information
          *
          */
         public boolean equalsIgnoreOptional(Object ob) {
--- a/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java	Wed Jul 05 23:09:40 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,9 +26,7 @@
 package java.lang;
 
 import java.security.*;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.StringTokenizer;
+import java.lang.module.ModuleFinder;
 
 /**
  * This class is for runtime permissions. A {@code RuntimePermission}
@@ -265,6 +263,16 @@
  * </tr>
  *
  * <tr>
+ *   <td>defineClass</td>
+ *   <td>Define a class with
+ * {@link java.lang.invoke.MethodHandles.Lookup#defineClass(byte[])
+ * Lookup.defineClass}.</td>
+ *   <td>This grants code with a suitably privileged {@code Lookup} object
+ * permission to define classes in the same package as the {@code Lookup}'s
+ * lookup class. </td>
+ * </tr>
+ *
+ * <tr>
  *   <td>accessDeclaredMembers</td>
  *   <td>Access to the declared members of a class</td>
  *   <td>This grants code permission to query a class for its public,
@@ -298,6 +306,14 @@
  * </tr>
  *
  * <tr>
+ *   <td>getStackWalkerWithClassReference</td>
+ *   <td>Get a stack walker that can retrieve stack frames with class reference.</td>
+ *   <td>This allows retrieval of Class objects from stack walking.
+ *   This might allow malicious code to access Class objects on the stack
+ *   outside its own context.</td>
+ * </tr>
+ *
+ * <tr>
  *   <td>setDefaultUncaughtExceptionHandler</td>
  *   <td>Setting the default handler to be used when a thread
  *   terminates abruptly due to an uncaught exception</td>
@@ -359,6 +375,14 @@
  *   <td>See {@link java.lang.System.LoggerFinder java.lang.System.LoggerFinder}
  *   for more information.</td>
  * </tr>
+ *
+ * <tr>
+ *   <td>accessSystemModules</td>
+ *   <td>Access system modules in the runtime image.</td>
+ *   <td>This grants the permission to access resources in the
+ *   {@linkplain ModuleFinder#ofSystem system modules} in the runtime image.</td>
+ * </tr>
+ *
  * </table>
  *
  * @implNote
--- a/jdk/src/java.base/share/classes/java/lang/StackFramePermission.java	Sat Apr 08 03:25:14 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +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.lang;
-
-/**
- * Permission to access {@link StackWalker.StackFrame}.
- *
- * @see java.lang.StackWalker.Option#RETAIN_CLASS_REFERENCE
- * @see StackWalker.StackFrame#getDeclaringClass()
- */
-public class StackFramePermission extends java.security.BasicPermission {
-    private static final long serialVersionUID = 2841894854386706014L;
-
-    /**
-     * Creates a new {@code StackFramePermission} object.
-     *
-     * @param name Permission name.  Must be "retainClassReference".
-     *
-     * @throws IllegalArgumentException if {@code name} is invalid.
-     * @throws NullPointerException if {@code name} is {@code null}.
-     */
-    public StackFramePermission(String name) {
-        super(name);
-        if (!name.equals("retainClassReference")) {
-            throw new IllegalArgumentException("name: " + name);
-        }
-    }
-}
--- a/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java	Wed Jul 05 23:09:40 2017 +0200
@@ -982,13 +982,6 @@
     }
 
     private static boolean isReflectionFrame(Class<?> c) {
-        if (c.getName().startsWith("jdk.internal.reflect") &&
-                !MethodAccessor.class.isAssignableFrom(c) &&
-                !ConstructorAccessor.class.isAssignableFrom(c)) {
-            throw new InternalError("Not jdk.internal.reflect.MethodAccessor"
-                    + " or jdk.internal.reflect.ConstructorAccessor: "
-                    + c.toString());
-        }
         // ## should filter all @Hidden frames?
         return c == Method.class ||
                c == Constructor.class ||
--- a/jdk/src/java.base/share/classes/java/lang/StackWalker.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/StackWalker.java	Wed Jul 05 23:09:40 2017 +0200
@@ -279,7 +279,7 @@
      * If a security manager is present and the given {@code option} is
      * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE},
      * it calls its {@link SecurityManager#checkPermission checkPermission}
-     * method for {@code StackFramePermission("retainClassReference")}.
+     * method for {@code RuntimePermission("getStackWalkerWithClassReference")}.
      *
      * @param option {@link Option stack walking option}
      *
@@ -303,7 +303,7 @@
      * If a security manager is present and the given {@code options} contains
      * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE},
      * it calls its {@link SecurityManager#checkPermission checkPermission}
-     * method for {@code StackFramePermission("retainClassReference")}.
+     * method for {@code RuntimePermission("getStackWalkerWithClassReference")}.
      *
      * @param options {@link Option stack walking option}
      *
@@ -333,7 +333,7 @@
      * If a security manager is present and the given {@code options} contains
      * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE},
      * it calls its {@link SecurityManager#checkPermission checkPermission}
-     * method for {@code StackFramePermission("retainClassReference")}.
+     * method for {@code RuntimePermission("getStackWalkerWithClassReference")}.
      *
      * <p>
      * The {@code estimateDepth} specifies the estimate number of stack frames
@@ -376,7 +376,7 @@
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             if (options.contains(Option.RETAIN_CLASS_REFERENCE)) {
-                sm.checkPermission(new StackFramePermission("retainClassReference"));
+                sm.checkPermission(new RuntimePermission("getStackWalkerWithClassReference"));
             }
         }
     }
--- a/jdk/src/java.base/share/classes/java/lang/String.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/String.java	Wed Jul 05 23:09:40 2017 +0200
@@ -2672,7 +2672,6 @@
      * point</a> is passed through uninterpreted.
      *
      * @return an IntStream of char values from this sequence
-     * @since 9
      */
     @Override
     public IntStream chars() {
@@ -2692,7 +2691,6 @@
      * {@code int} values which are then passed to the stream.
      *
      * @return an IntStream of Unicode code points from this sequence
-     * @since 9
      */
     @Override
     public IntStream codePoints() {
--- a/jdk/src/java.base/share/classes/java/lang/StringCoding.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/StringCoding.java	Wed Jul 05 23:09:40 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	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/System.java	Wed Jul 05 23:09:40 2017 +0200
@@ -43,6 +43,7 @@
 import java.lang.reflect.Module;
 import java.net.URL;
 import java.security.AccessControlContext;
+import java.security.ProtectionDomain;
 import java.util.Properties;
 import java.util.PropertyPermission;
 import java.util.Map;
@@ -1569,6 +1570,14 @@
      * obtained by calling {@link LoggerFinder#getLogger(java.lang.String,
      * java.lang.reflect.Module) LoggerFinder.getLogger(name, module)}, where
      * {@code module} is the caller's module.
+     * In cases where {@code System.getLogger} is called from a context where
+     * there is no caller frame on the stack (e.g when called directly
+     * from a JNI attached thread), {@code IllegalCallerException} is thrown.
+     * To obtain a logger in such a context, use an auxiliary class that will
+     * implicitly be identified as the caller, or use the system {@link
+     * LoggerFinder#getLoggerFinder() LoggerFinder} to obtain a logger instead.
+     * Note that doing the latter may eagerly initialize the underlying
+     * logging system.
      *
      * @apiNote
      * This method may defer calling the {@link
@@ -1581,6 +1590,8 @@
      * @return an instance of {@link Logger} that can be used by the calling
      *         class.
      * @throws NullPointerException if {@code name} is {@code null}.
+     * @throws IllegalCallerException if there is no Java caller frame on the
+     *         stack.
      *
      * @since 9
      */
@@ -1588,6 +1599,9 @@
     public static Logger getLogger(String name) {
         Objects.requireNonNull(name);
         final Class<?> caller = Reflection.getCallerClass();
+        if (caller == null) {
+            throw new IllegalCallerException("no caller frame");
+        }
         return LazyLoggers.getLogger(name, caller.getModule());
     }
 
@@ -1601,8 +1615,16 @@
      * The returned logger will perform message localization as specified
      * by {@link LoggerFinder#getLocalizedLogger(java.lang.String,
      * java.util.ResourceBundle, java.lang.reflect.Module)
-     * LoggerFinder.getLocalizedLogger(name, bundle, module}, where
+     * LoggerFinder.getLocalizedLogger(name, bundle, module)}, where
      * {@code module} is the caller's module.
+     * In cases where {@code System.getLogger} is called from a context where
+     * there is no caller frame on the stack (e.g when called directly
+     * from a JNI attached thread), {@code IllegalCallerException} is thrown.
+     * To obtain a logger in such a context, use an auxiliary class that
+     * will implicitly be identified as the caller, or use the system {@link
+     * LoggerFinder#getLoggerFinder() LoggerFinder} to obtain a logger instead.
+     * Note that doing the latter may eagerly initialize the underlying
+     * logging system.
      *
      * @apiNote
      * This method is intended to be used after the system is fully initialized.
@@ -1621,6 +1643,8 @@
      * resource bundle for message localization.
      * @throws NullPointerException if {@code name} is {@code null} or
      *         {@code bundle} is {@code null}.
+     * @throws IllegalCallerException if there is no Java caller frame on the
+     *         stack.
      *
      * @since 9
      */
@@ -1629,6 +1653,9 @@
         final ResourceBundle rb = Objects.requireNonNull(bundle);
         Objects.requireNonNull(name);
         final Class<?> caller = Reflection.getCallerClass();
+        if (caller == null) {
+            throw new IllegalCallerException("no caller frame");
+        }
         final SecurityManager sm = System.getSecurityManager();
         // We don't use LazyLoggers if a resource bundle is specified.
         // Bootstrap sensitive classes in the JDK do not use resource bundles
@@ -1847,6 +1874,39 @@
     }
 
     /**
+     * Logs an exception/error at initialization time to stdout or stderr.
+     *
+     * @param printToStderr to print to stderr rather than stdout
+     * @param printStackTrace to print the stack trace
+     * @param msg the message to print before the exception, can be {@code null}
+     * @param e the exception or error
+     */
+    private static void logInitException(boolean printToStderr,
+                                         boolean printStackTrace,
+                                         String msg,
+                                         Throwable e) {
+        if (VM.initLevel() < 1) {
+            throw new InternalError("system classes not initialized");
+        }
+        PrintStream log = (printToStderr) ? err : out;
+        if (msg != null) {
+            log.println(msg);
+        }
+        if (printStackTrace) {
+            e.printStackTrace(log);
+        } else {
+            log.println(e);
+            for (Throwable suppressed : e.getSuppressed()) {
+                log.println("Suppressed: " + suppressed);
+            }
+            Throwable cause = e.getCause();
+            if (cause != null) {
+                log.println("Caused by: " + cause);
+            }
+        }
+    }
+
+    /**
      * Initialize the system class.  Called after thread initialization.
      */
     private static void initPhase1() {
@@ -1924,13 +1984,25 @@
     /*
      * Invoked by VM.  Phase 2 module system initialization.
      * Only classes in java.base can be loaded in this phase.
+     *
+     * @param printToStderr print exceptions to stderr rather than stdout
+     * @param printStackTrace print stack trace when exception occurs
+     *
+     * @return JNI_OK for success, JNI_ERR for failure
      */
-    private static void initPhase2() {
-        // initialize the module system
-        System.bootLayer = ModuleBootstrap.boot();
+    private static int initPhase2(boolean printToStderr, boolean printStackTrace) {
+        try {
+            bootLayer = ModuleBootstrap.boot();
+        } catch (Exception | Error e) {
+            logInitException(printToStderr, printStackTrace,
+                             "Error occurred during initialization of boot layer", e);
+            return -1; // JNI_ERR
+        }
 
         // module system initialized
         VM.initLevel(2);
+
+        return 0; // JNI_OK
     }
 
     /*
@@ -2036,6 +2108,9 @@
             public ConcurrentHashMap<?, ?> createOrGetClassLoaderValueMap(ClassLoader cl) {
                 return cl.createOrGetClassLoaderValueMap();
             }
+            public Class<?> defineClass(ClassLoader loader, String name, byte[] b, ProtectionDomain pd, String source) {
+                return ClassLoader.defineClass1(loader, name, b, 0, b.length, pd, source);
+            }
             public Class<?> findBootstrapClassOrNull(ClassLoader cl, String name) {
                 return cl.findBootstrapClassOrNull(name);
             }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/CallSite.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/CallSite.java	Wed Jul 05 23:09:40 2017 +0200
@@ -82,6 +82,7 @@
 }
 }</pre></blockquote>
  * @author John Rose, JSR 292 EG
+ * @since 1.7
  */
 abstract
 public class CallSite {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,6 +30,7 @@
  * An {@code invokedynamic} instruction linked to a {@code ConstantCallSite} is permanently
  * bound to the call site's target.
  * @author John Rose, JSR 292 EG
+ * @since 1.7
  */
 public class ConstantCallSite extends CallSite {
     private final boolean isFrozen;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaConversionException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaConversionException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,8 @@
 
 /**
  * LambdaConversionException
+ *
+ * @since 1.8
  */
 public class LambdaConversionException extends Exception {
     private static final long serialVersionUID = 292L + 8L;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java	Wed Jul 05 23:09:40 2017 +0200
@@ -211,6 +211,7 @@
  * theory, any method handle could be used. Currently supported are direct method
  * handles representing invocation of virtual, interface, constructor and static
  * methods.
+ * @since 1.8
  */
 public class LambdaMetafactory {
 
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java	Wed Jul 05 23:09:40 2017 +0200
@@ -423,6 +423,7 @@
  * @see MethodType
  * @see MethodHandles
  * @author John Rose, JSR 292 EG
+ * @since 1.7
  */
 public abstract class MethodHandle {
 
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java	Wed Jul 05 23:09:40 2017 +0200
@@ -38,6 +38,8 @@
 /**
  * This class consists exclusively of static methods that help adapt
  * method handles to other JVM types, such as interfaces.
+ *
+ * @since 1.7
  */
 public class MethodHandleProxies {
 
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,6 +25,9 @@
 
 package java.lang.invoke;
 
+import jdk.internal.misc.SharedSecrets;
+import jdk.internal.module.IllegalAccessLogger;
+import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.reflect.CallerSensitive;
 import jdk.internal.reflect.Reflection;
 import jdk.internal.vm.annotation.ForceInline;
@@ -43,6 +46,9 @@
 import java.lang.reflect.Module;
 import java.lang.reflect.ReflectPermission;
 import java.nio.ByteOrder;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.BitSet;
@@ -191,6 +197,12 @@
         }
         if ((lookup.lookupModes() & Lookup.MODULE) == 0)
             throw new IllegalAccessException("lookup does not have MODULE lookup mode");
+        if (!callerModule.isNamed() && targetModule.isNamed()) {
+            IllegalAccessLogger logger = IllegalAccessLogger.illegalAccessLogger();
+            if (logger != null) {
+                logger.logIfOpenedByBackdoor(lookup, targetClass);
+            }
+        }
         return new Lookup(targetClass);
     }
 
@@ -855,6 +867,112 @@
             return new Lookup(lookupClass(), newModes);
         }
 
+        /**
+         * Defines a class to the same class loader and in the same runtime package and
+         * {@linkplain java.security.ProtectionDomain protection domain} as this lookup's
+         * {@linkplain #lookupClass() lookup class}.
+         *
+         * <p> The {@linkplain #lookupModes() lookup modes} for this lookup must include
+         * {@link #PACKAGE PACKAGE} access as default (package) members will be
+         * accessible to the class. The {@code PACKAGE} lookup mode serves to authenticate
+         * that the lookup object was created by a caller in the runtime package (or derived
+         * from a lookup originally created by suitably privileged code to a target class in
+         * the runtime package). The lookup modes cannot include {@link #PRIVATE PRIVATE}
+         * access. A lookup with {@code PRIVATE} access can be downgraded to drop this lookup
+         * mode with the {@linkplain #dropLookupMode(int) dropLookupMode} method. </p>
+         *
+         * <p> The {@code bytes} parameter is the class bytes of a valid class file (as defined
+         * by the <em>The Java Virtual Machine Specification</em>) with a class name in the
+         * same package as the lookup class. </p>
+         *
+         * <p> This method does not run the class initializer. The class initializer may
+         * run at a later time, as detailed in section 12.4 of the <em>The Java Language
+         * Specification</em>. </p>
+         *
+         * <p> If there is a security manager, its {@code checkPermission} method is first called
+         * to check {@code RuntimePermission("defineClass")}. </p>
+         *
+         * @param bytes the class bytes
+         * @return the {@code Class} object for the class
+         * @throws IllegalArgumentException the bytes are for a class in a different package
+         * to the lookup class
+         * @throws IllegalAccessException if this lookup does not have {@code PACKAGE} access
+         * @throws UnsupportedOperationException if the lookup class has {@code PRIVATE} access
+         * @throws LinkageError if the class is malformed ({@code ClassFormatError}), cannot be
+         * verified ({@code VerifyError}), is already defined, or another linkage error occurs
+         * @throws SecurityException if denied by the security manager
+         * @throws NullPointerException if {@code bytes} is {@code null}
+         * @since 9
+         * @spec JPMS
+         * @see Lookup#privateLookupIn
+         * @see Lookup#dropLookupMode
+         * @see ClassLoader#defineClass(String,byte[],int,int,ProtectionDomain)
+         */
+        public Class<?> defineClass(byte[] bytes) throws IllegalAccessException {
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null)
+                sm.checkPermission(new RuntimePermission("defineClass"));
+            if (hasPrivateAccess())
+                throw new UnsupportedOperationException("PRIVATE access not supported");
+            if ((lookupModes() & PACKAGE) == 0)
+                throw new IllegalAccessException("Lookup does not have PACKAGE access");
+            assert (lookupModes() & (MODULE|PUBLIC)) != 0;
+
+            // parse class bytes to get class name (in internal form)
+            bytes = bytes.clone();
+            String name;
+            try {
+                ClassReader reader = new ClassReader(bytes);
+                name = reader.getClassName();
+            } catch (RuntimeException e) {
+                // ASM exceptions are poorly specified
+                ClassFormatError cfe = new ClassFormatError();
+                cfe.initCause(e);
+                throw cfe;
+            }
+
+            // get package and class name in binary form
+            String cn, pn;
+            int index = name.lastIndexOf('/');
+            if (index == -1) {
+                cn = name;
+                pn = "";
+            } else {
+                cn = name.replace('/', '.');
+                pn = cn.substring(0, index);
+            }
+            if (!pn.equals(lookupClass.getPackageName())) {
+                throw new IllegalArgumentException("Class not in same package as lookup class");
+            }
+
+            // invoke the class loader's defineClass method
+            ClassLoader loader = lookupClass.getClassLoader();
+            ProtectionDomain pd = (loader != null) ? lookupClassProtectionDomain() : null;
+            String source = "__Lookup_defineClass__";
+            Class<?> clazz = SharedSecrets.getJavaLangAccess().defineClass(loader, cn, bytes, pd, source);
+            assert clazz.getClassLoader() == lookupClass.getClassLoader()
+                    && clazz.getPackageName().equals(lookupClass.getPackageName())
+                    && protectionDomain(clazz) == lookupClassProtectionDomain();
+            return clazz;
+        }
+
+        private ProtectionDomain lookupClassProtectionDomain() {
+            ProtectionDomain pd = cachedProtectionDomain;
+            if (pd == null) {
+                cachedProtectionDomain = pd = protectionDomain(lookupClass);
+            }
+            return pd;
+        }
+
+        private ProtectionDomain protectionDomain(Class<?> clazz) {
+            PrivilegedAction<ProtectionDomain> pa = clazz::getProtectionDomain;
+            return AccessController.doPrivileged(pa);
+        }
+
+        // cached protection domain
+        private volatile ProtectionDomain cachedProtectionDomain;
+
+
         // Make sure outer class is initialized first.
         static { IMPL_NAMES.getClass(); }
 
@@ -1948,7 +2066,7 @@
 
         /**
          * Returns {@code true} if this lookup has {@code PRIVATE} access.
-         * @return {@code true} if this lookup has {@code PRIVATE} acesss.
+         * @return {@code true} if this lookup has {@code PRIVATE} access.
          * @since 9
          */
         public boolean hasPrivateAccess() {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Wed Jul 05 23:09:40 2017 +0200
@@ -88,6 +88,7 @@
  * (But the classes need not be initialized, as is the case with a {@code CONSTANT_Class}.)
  * This loading may occur at any time before the {@code MethodType} object is first derived.
  * @author John Rose, JSR 292 EG
+ * @since 1.7
  */
 public final
 class MethodType implements java.io.Serializable {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java	Wed Jul 05 23:09:40 2017 +0200
@@ -81,6 +81,7 @@
  * For target values which will be frequently updated, consider using
  * a {@linkplain VolatileCallSite volatile call site} instead.
  * @author John Rose, JSR 292 EG
+ * @since 1.7
  */
 public class MutableCallSite extends CallSite {
     /**
--- a/jdk/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java	Wed Jul 05 23:09:40 2017 +0200
@@ -54,6 +54,7 @@
  * lambda actually captured by that class.
  *
  * @see LambdaMetafactory
+ * @since 1.8
  */
 public final class SerializedLambda implements Serializable {
     private static final long serialVersionUID = 8025925345765570181L;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/SwitchPoint.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/SwitchPoint.java	Wed Jul 05 23:09:40 2017 +0200
@@ -108,6 +108,7 @@
  * }
  * }</pre>
  * @author Remi Forax, JSR 292 EG
+ * @since 1.7
  */
 public class SwitchPoint {
     private static final MethodHandle
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java	Wed Jul 05 23:09:40 2017 +0200
@@ -40,6 +40,7 @@
  * with {@code MutableCallSite}.
  * @see MutableCallSite
  * @author John Rose, JSR 292 EG
+ * @since 1.7
  */
 public class VolatileCallSite extends CallSite {
     /**
--- a/jdk/src/java.base/share/classes/java/lang/module/Configuration.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/Configuration.java	Wed Jul 05 23:09:40 2017 +0200
@@ -112,11 +112,9 @@
     // module constraints on target
     private final String osName;
     private final String osArch;
-    private final String osVersion;
 
     String osName() { return osName; }
     String osArch() { return osArch; }
-    String osVersion() { return osVersion; }
 
     private Configuration() {
         this.parents = Collections.emptyList();
@@ -125,7 +123,6 @@
         this.nameToModule = Collections.emptyMap();
         this.osName = null;
         this.osArch = null;
-        this.osVersion = null;
     }
 
     private Configuration(List<Configuration> parents,
@@ -152,7 +149,6 @@
 
         this.osName = resolver.osName();
         this.osArch = resolver.osArch();
-        this.osVersion = resolver.osVersion();
     }
 
     /**
@@ -281,6 +277,7 @@
      * <em>observability-related</em> reasons: </p>
      *
      * <ul>
+     *
      *     <li><p> A root module, or a direct or transitive dependency, is not
      *     found. </p></li>
      *
@@ -289,13 +286,6 @@
      *     descriptor ({@code module-info.class}) or two versions of the same
      *     module are found in the same directory. </p></li>
      *
-     *     <li><p> A module with the required name is found but the module
-     *     requires a different {@link ModuleDescriptor#osName() operating
-     *     system}, {@link ModuleDescriptor#osArch() architecture}, or {@link
-     *     ModuleDescriptor#osVersion() version} to other modules that have
-     *     been resolved for the new configuration or modules in the parent
-     *     configurations. </p></li>
-     *
      * </ul>
      *
      * <p> Post-resolution consistency checks may fail with {@code
@@ -306,6 +296,10 @@
      *     <li><p> A cycle is detected, say where module {@code m1} requires
      *     module {@code m2} and {@code m2} requires {@code m1}. </p></li>
      *
+     *     <li><p> A module reads two or more modules with the same name. This
+     *     includes the case where a module reads another with the same name as
+     *     itself. </p></li>
+     *
      *     <li><p> Two or more modules in the configuration export the same
      *     package to a module that reads both. This includes the case where a
      *     module {@code M} containing package {@code p} reads another module
@@ -319,8 +313,9 @@
      * </ul>
      *
      * @implNote In the implementation then observability of modules may depend
-     * on referential integrity checks that ensure different builds of tightly
-     * coupled modules are not combined in the same configuration.
+     * on referential integrity or other checks that ensure different builds of
+     * tightly coupled modules or modules for specific operating systems or
+     * architectures are not combined in the same configuration.
      *
      * @param  before
      *         The <em>before</em> module finder to find modules
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java	Wed Jul 05 23:09:40 2017 +0200
@@ -179,8 +179,10 @@
         private final Set<Modifier> mods;
         private final String name;
         private final Version compiledVersion;
+        private final String rawCompiledVersion;
 
-        private Requires(Set<Modifier> ms, String mn, Version v) {
+        private Requires(Set<Modifier> ms, String mn, Version v, String vs) {
+            assert v == null || vs == null;
             if (ms.isEmpty()) {
                 ms = Collections.emptySet();
             } else {
@@ -189,12 +191,14 @@
             this.mods = ms;
             this.name = mn;
             this.compiledVersion = v;
+            this.rawCompiledVersion = vs;
         }
 
         private Requires(Set<Modifier> ms, String mn, Version v, boolean unused) {
             this.mods = ms;
             this.name = mn;
             this.compiledVersion = v;
+            this.rawCompiledVersion = null;
         }
 
         /**
@@ -218,13 +222,34 @@
         /**
          * Returns the version of the module if recorded at compile-time.
          *
-         * @return The version of the module if recorded at compile-time
+         * @return The version of the module if recorded at compile-time,
+         *         or an empty {@code Optional} if no version was recorded or
+         *         the version string recorded is {@linkplain Version#parse(String)
+         *         unparseable}
          */
         public Optional<Version> compiledVersion() {
             return Optional.ofNullable(compiledVersion);
         }
 
         /**
+         * Returns the string with the possibly-unparseable version of the module
+         * if recorded at compile-time.
+         *
+         * @return The string containing the version of the module if recorded
+         *         at compile-time, or an empty {@code Optional} if no version
+         *         was recorded
+         *
+         * @see #compiledVersion()
+         */
+        public Optional<String> rawCompiledVersion() {
+            if (compiledVersion != null) {
+                return Optional.of(compiledVersion.toString());
+            } else {
+                return Optional.ofNullable(rawCompiledVersion);
+            }
+        }
+
+        /**
          * Compares this module dependence to another.
          *
          * <p> Two {@code Requires} objects are compared by comparing their
@@ -236,7 +261,10 @@
          * recorded at compile-time are compared. When comparing the versions
          * recorded at compile-time then a dependence that has a recorded
          * version is considered to succeed a dependence that does not have a
-         * recorded version. </p>
+         * recorded version. If both recorded versions are {@linkplain
+         * Version#parse(String) unparseable} then the {@linkplain
+         * #rawCompiledVersion() raw version strings} are compared
+         * lexicographically. </p>
          *
          * @param  that
          *         The module dependence to compare
@@ -262,6 +290,10 @@
             c = compare(this.compiledVersion, that.compiledVersion);
             if (c != 0) return c;
 
+            // rawCompiledVersion
+            c = compare(this.rawCompiledVersion, that.rawCompiledVersion);
+            if (c != 0) return c;
+
             return 0;
         }
 
@@ -289,7 +321,8 @@
                 return false;
             Requires that = (Requires)ob;
             return name.equals(that.name) && mods.equals(that.mods)
-                    && Objects.equals(compiledVersion, that.compiledVersion);
+                    && Objects.equals(compiledVersion, that.compiledVersion)
+                    && Objects.equals(rawCompiledVersion, that.rawCompiledVersion);
         }
 
         /**
@@ -306,6 +339,8 @@
             int hash = name.hashCode() * 43 + mods.hashCode();
             if (compiledVersion != null)
                 hash = hash * 43 + compiledVersion.hashCode();
+            if (rawCompiledVersion != null)
+                hash = hash * 43 + rawCompiledVersion.hashCode();
             return hash;
         }
 
@@ -774,7 +809,7 @@
         /**
          * Returns the fully qualified class name of the service type.
          *
-         * @return The fully qualified class name of the service type.
+         * @return The fully qualified class name of the service type
          */
         public String service() { return service; }
 
@@ -1199,6 +1234,7 @@
 
     private final String name;
     private final Version version;
+    private final String rawVersionString;
     private final Set<Modifier> modifiers;
     private final boolean open;  // true if modifiers contains OPEN
     private final boolean automatic;  // true if modifiers contains AUTOMATIC
@@ -1209,12 +1245,10 @@
     private final Set<Provides> provides;
     private final Set<String> packages;
     private final String mainClass;
-    private final String osName;
-    private final String osArch;
-    private final String osVersion;
 
     private ModuleDescriptor(String name,
                              Version version,
+                             String rawVersionString,
                              Set<Modifier> modifiers,
                              Set<Requires> requires,
                              Set<Exports> exports,
@@ -1222,13 +1256,12 @@
                              Set<String> uses,
                              Set<Provides> provides,
                              Set<String> packages,
-                             String mainClass,
-                             String osName,
-                             String osArch,
-                             String osVersion)
+                             String mainClass)
     {
+        assert version == null || rawVersionString == null;
         this.name = name;
         this.version = version;
+        this.rawVersionString = rawVersionString;
         this.modifiers = emptyOrUnmodifiableSet(modifiers);
         this.open = modifiers.contains(Modifier.OPEN);
         this.automatic = modifiers.contains(Modifier.AUTOMATIC);
@@ -1242,9 +1275,6 @@
 
         this.packages = emptyOrUnmodifiableSet(packages);
         this.mainClass = mainClass;
-        this.osName = osName;
-        this.osArch = osArch;
-        this.osVersion = osVersion;
     }
 
     /**
@@ -1261,13 +1291,11 @@
                      Set<Provides> provides,
                      Set<String> packages,
                      String mainClass,
-                     String osName,
-                     String osArch,
-                     String osVersion,
                      int hashCode,
                      boolean unused) {
         this.name = name;
         this.version = version;
+        this.rawVersionString = null;
         this.modifiers = modifiers;
         this.open = modifiers.contains(Modifier.OPEN);
         this.automatic = modifiers.contains(Modifier.AUTOMATIC);
@@ -1278,9 +1306,6 @@
         this.provides = provides;
         this.packages = packages;
         this.mainClass = mainClass;
-        this.osName = osName;
-        this.osArch = osArch;
-        this.osVersion = osVersion;
         this.hash = hashCode;
     }
 
@@ -1394,18 +1419,37 @@
     /**
      * <p> Returns the module version. </p>
      *
-     * @return This module's version
+     * @return This module's version, or an empty {@code Optional} if the
+     *         module does not have a version or the version is
+     *         {@linkplain Version#parse(String) unparseable}
      */
     public Optional<Version> version() {
         return Optional.ofNullable(version);
     }
 
     /**
+     * <p> Returns the string with the possibly-unparseable version of the
+     * module </p>
+     *
+     * @return The string containing the version of the module or an empty
+     *         {@code Optional} if the module does not have a version
+     *
+     * @see #version()
+     */
+    public Optional<String> rawVersion() {
+        if (version != null) {
+            return Optional.of(version.toString());
+        } else {
+            return Optional.ofNullable(rawVersionString);
+        }
+    }
+
+    /**
      * <p> Returns a string containing the module name and, if present, its
      * version. </p>
      *
      * @return A string containing the module name and, if present, its
-     *         version.
+     *         version
      */
     public String toNameAndVersion() {
         if (version != null) {
@@ -1425,40 +1469,11 @@
     }
 
     /**
-     * Returns the operating system name if the module is operating system
-     * specific.
-     *
-     * @return The operating system name or an empty {@code Optional}
-     *         if the module is not operating system specific
-     */
-    public Optional<String> osName() {
-        return Optional.ofNullable(osName);
-    }
-
-    /**
-     * Returns the operating system architecture if the module is operating
-     * system architecture specific.
+     * Returns the set of packages in the module.
      *
-     * @return The operating system architecture or an empty {@code Optional}
-     *         if the module is not operating system architecture specific
-     */
-    public Optional<String> osArch() {
-        return Optional.ofNullable(osArch);
-    }
-
-    /**
-     * Returns the operating system version if the module is operating
-     * system version specific.
-     *
-     * @return The operating system version or an empty {@code Optional}
-     *         if the module is not operating system version specific
-     */
-    public Optional<String> osVersion() {
-        return Optional.ofNullable(osVersion);
-    }
-
-    /**
-     * Returns the set of packages in the module.
+     * <p> The set of packages includes all exported and open packages, as well
+     * as the packages of any service providers, and the package for the main
+     * class. </p>
      *
      * @return A possibly-empty unmodifiable set of the packages in the module
      */
@@ -1518,9 +1533,7 @@
         final Set<String> uses = new HashSet<>();
         final Map<String, Provides> provides = new HashMap<>();
         Version version;
-        String osName;
-        String osArch;
-        String osVersion;
+        String rawVersionString;
         String mainClass;
 
         /**
@@ -1604,24 +1617,21 @@
             Objects.requireNonNull(compiledVersion);
             if (strict)
                 mn = requireModuleName(mn);
-            return requires(new Requires(ms, mn, compiledVersion));
+            return requires(new Requires(ms, mn, compiledVersion, null));
         }
 
         /* package */Builder requires(Set<Requires.Modifier> ms,
                                       String mn,
-                                      String compiledVersion) {
-            Version v = null;
+                                      String rawCompiledVersion) {
+            Requires r;
             try {
-                v = Version.parse(compiledVersion);
+                Version v = Version.parse(rawCompiledVersion);
+                r = new Requires(ms, mn, v, null);
             } catch (IllegalArgumentException e) {
-                // for now, drop un-parsable version when non-strict
                 if (strict) throw e;
+                r = new Requires(ms, mn, null, rawCompiledVersion);
             }
-            if (v == null) {
-                return requires(ms, mn);
-            } else {
-                return requires(ms, mn, v);
-            }
+            return requires(r);
         }
 
         /**
@@ -1646,7 +1656,7 @@
         public Builder requires(Set<Requires.Modifier> ms, String mn) {
             if (strict)
                 mn = requireModuleName(mn);
-            return requires(new Requires(ms, mn, null));
+            return requires(new Requires(ms, mn, null, null));
         }
 
         /**
@@ -1952,7 +1962,7 @@
          *         a class in a named package
          * @throws IllegalStateException
          *         If a dependency on the service type has already been declared
-         *         or this is a builder for an an automatic module
+         *         or this is a builder for an automatic module
          */
         public Builder uses(String service) {
             if (automatic)
@@ -2068,6 +2078,7 @@
          */
         public Builder version(Version v) {
             version = requireNonNull(v);
+            rawVersionString = null;
             return this;
         }
 
@@ -2086,18 +2097,15 @@
          * @see Version#parse(String)
          */
         public Builder version(String vs) {
-            Version v;
-            if (strict) {
-                v = Version.parse(vs);
-            } else {
-                try {
-                    v = Version.parse(vs);
-                } catch (IllegalArgumentException ignore) {
-                    // for now, ignore when non-strict
-                    return this;
-                }
+            try {
+                version = Version.parse(vs);
+                rawVersionString = null;
+            } catch (IllegalArgumentException e) {
+                if (strict) throw e;
+                version = null;
+                rawVersionString = vs;
             }
-            return version(v);
+            return this;
         }
 
         /**
@@ -2132,60 +2140,6 @@
         }
 
         /**
-         * Sets the operating system name.
-         *
-         * @param  name
-         *         The operating system name
-         *
-         * @return This builder
-         *
-         * @throws IllegalArgumentException
-         *         If {@code name} is {@code null} or the empty String
-         */
-        public Builder osName(String name) {
-            if (name == null || name.isEmpty())
-                throw new IllegalArgumentException("OS name is null or empty");
-            osName = name;
-            return this;
-        }
-
-        /**
-         * Sets the operating system architecture.
-         *
-         * @param  arch
-         *         The operating system architecture
-         *
-         * @return This builder
-         *
-         * @throws IllegalArgumentException
-         *         If {@code name} is {@code null} or the empty String
-         */
-        public Builder osArch(String arch) {
-            if (arch == null || arch.isEmpty())
-                throw new IllegalArgumentException("OS arch is null or empty");
-            osArch = arch;
-            return this;
-        }
-
-        /**
-         * Sets the operating system version.
-         *
-         * @param  version
-         *         The operating system version
-         *
-         * @return This builder
-         *
-         * @throws IllegalArgumentException
-         *         If {@code name} is {@code null} or the empty String
-         */
-        public Builder osVersion(String version) {
-            if (version == null || version.isEmpty())
-                throw new IllegalArgumentException("OS version is null or empty");
-            osVersion = version;
-            return this;
-        }
-
-        /**
          * Builds and returns a {@code ModuleDescriptor} from its components.
          *
          * <p> The module will require "{@code java.base}" even if the dependence
@@ -2208,6 +2162,7 @@
                     && !this.requires.containsKey("java.base")) {
                 requires.add(new Requires(Set.of(Requires.Modifier.MANDATED),
                                           "java.base",
+                                          null,
                                           null));
             }
 
@@ -2215,6 +2170,7 @@
 
             return new ModuleDescriptor(name,
                                         version,
+                                        rawVersionString,
                                         modifiers,
                                         requires,
                                         exports,
@@ -2222,10 +2178,7 @@
                                         uses,
                                         provides,
                                         packages,
-                                        mainClass,
-                                        osName,
-                                        osArch,
-                                        osVersion);
+                                        mainClass);
         }
 
     }
@@ -2237,9 +2190,11 @@
      * module names lexicographically. Where the module names are equal then the
      * module versions are compared. When comparing the module versions then a
      * module descriptor with a version is considered to succeed a module
-     * descriptor that does not have a version. Where the module names are equal
-     * and the versions are equal (or not present in both), then the set of
-     * modifiers are compared. Sets of modifiers are compared by comparing
+     * descriptor that does not have a version. If both versions are {@linkplain
+     * Version#parse(String) unparseable} then the {@linkplain #rawVersion()
+     * raw version strings} are compared lexicographically. Where the module names
+     * are equal and the versions are equal (or not present in both), then the
+     * set of modifiers are compared. Sets of modifiers are compared by comparing
      * a <em>binary value</em> computed for each set. If a modifier is present
      * in the set then the bit at the position of its ordinal is {@code 1}
      * in the binary value, otherwise {@code 0}. If the two set of modifiers
@@ -2263,6 +2218,9 @@
         c = compare(this.version, that.version);
         if (c != 0) return c;
 
+        c = compare(this.rawVersionString, that.rawVersionString);
+        if (c != 0) return c;
+
         long v1 = modsValue(this.modifiers());
         long v2 = modsValue(that.modifiers());
         c = Long.compare(v1, v2);
@@ -2289,15 +2247,6 @@
         c = compare(this.mainClass, that.mainClass);
         if (c != 0) return c;
 
-        c = compare(this.osName, that.osName);
-        if (c != 0) return c;
-
-        c = compare(this.osArch, that.osArch);
-        if (c != 0) return c;
-
-        c = compare(this.osVersion, that.osVersion);
-        if (c != 0) return c;
-
         return 0;
     }
 
@@ -2333,10 +2282,8 @@
                 && uses.equals(that.uses)
                 && provides.equals(that.provides)
                 && Objects.equals(version, that.version)
-                && Objects.equals(mainClass, that.mainClass)
-                && Objects.equals(osName, that.osName)
-                && Objects.equals(osArch, that.osArch)
-                && Objects.equals(osVersion, that.osVersion));
+                && Objects.equals(rawVersionString, that.rawVersionString)
+                && Objects.equals(mainClass, that.mainClass));
     }
 
     /**
@@ -2361,10 +2308,8 @@
             hc = hc * 43 + uses.hashCode();
             hc = hc * 43 + provides.hashCode();
             hc = hc * 43 + Objects.hashCode(version);
+            hc = hc * 43 + Objects.hashCode(rawVersionString);
             hc = hc * 43 + Objects.hashCode(mainClass);
-            hc = hc * 43 + Objects.hashCode(osName);
-            hc = hc * 43 + Objects.hashCode(osArch);
-            hc = hc * 43 + Objects.hashCode(osVersion);
             if (hc == 0)
                 hc = -1;
             hash = hc;
@@ -2713,8 +2658,8 @@
                 public void requires(ModuleDescriptor.Builder builder,
                                      Set<Requires.Modifier> ms,
                                      String mn,
-                                     String compiledVersion) {
-                    builder.requires(ms, mn, compiledVersion);
+                                     String rawCompiledVersion) {
+                    builder.requires(ms, mn, rawCompiledVersion);
                 }
 
                 @Override
@@ -2762,9 +2707,6 @@
                                                             Set<Provides> provides,
                                                             Set<String> packages,
                                                             String mainClass,
-                                                            String osName,
-                                                            String osArch,
-                                                            String osVersion,
                                                             int hashCode) {
                     return new ModuleDescriptor(name,
                                                 version,
@@ -2776,9 +2718,6 @@
                                                 provides,
                                                 packages,
                                                 mainClass,
-                                                osName,
-                                                osArch,
-                                                osVersion,
                                                 hashCode,
                                                 false);
                 }
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,8 +25,6 @@
 
 package java.lang.module;
 
-import java.io.File;
-import java.io.FilePermission;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -43,9 +41,9 @@
 import java.util.Set;
 
 import jdk.internal.module.ModuleBootstrap;
+import jdk.internal.module.ModulePatcher;
 import jdk.internal.module.ModulePath;
 import jdk.internal.module.SystemModuleFinder;
-import sun.security.action.GetPropertyAction;
 
 /**
  * A finder of modules. A {@code ModuleFinder} is used to find modules during
@@ -146,9 +144,9 @@
      *
      * <p> If there is a security manager set then its {@link
      * SecurityManager#checkPermission(Permission) checkPermission} method is
-     * invoked to check that the caller has been granted {@link FilePermission}
-     * to recursively read the directory that is the value of the system
-     * property {@code java.home}. </p>
+     * invoked to check that the caller has been granted
+     * {@link RuntimePermission RuntimePermission("accessSystemModules")}
+     * to access the system modules. </p>
      *
      * @return A {@code ModuleFinder} that locates the system modules
      *
@@ -156,26 +154,29 @@
      *         If denied by the security manager
      */
     static ModuleFinder ofSystem() {
-        String home;
-
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            PrivilegedAction<String> pa = new GetPropertyAction("java.home");
-            home = AccessController.doPrivileged(pa);
-            Permission p = new FilePermission(home + File.separator + "-", "read");
-            sm.checkPermission(p);
+            sm.checkPermission(new RuntimePermission("accessSystemModules"));
+            PrivilegedAction<ModuleFinder> pa = ModuleFinder::privilegedOfSystem;
+            return AccessController.doPrivileged(pa);
         } else {
-            home = System.getProperty("java.home");
+            return privilegedOfSystem();
         }
+    }
 
+    /**
+     * Returns a module finder that locates the system modules. This method
+     * assumes it has permissions to access the runtime image.
+     */
+    private static ModuleFinder privilegedOfSystem() {
+        String home = System.getProperty("java.home");
         Path modules = Paths.get(home, "lib", "modules");
         if (Files.isRegularFile(modules)) {
             return SystemModuleFinder.getInstance();
         } else {
-            Path mlib = Paths.get(home, "modules");
-            if (Files.isDirectory(mlib)) {
-                // exploded build may be patched
-                return ModulePath.of(ModuleBootstrap.patcher(), mlib);
+            Path dir = Paths.get(home, "modules");
+            if (Files.isDirectory(dir)) {
+                return privilegedOf(ModuleBootstrap.patcher(), dir);
             } else {
                 throw new InternalError("Unable to detect the run-time image");
             }
@@ -183,6 +184,26 @@
     }
 
     /**
+     * Returns a module finder that locates the system modules in an exploded
+     * image. The image may be patched.
+     */
+    private static ModuleFinder privilegedOf(ModulePatcher patcher, Path dir) {
+        ModuleFinder finder = ModulePath.of(patcher, dir);
+        return new ModuleFinder() {
+            @Override
+            public Optional<ModuleReference> find(String name) {
+                PrivilegedAction<Optional<ModuleReference>> pa = () -> finder.find(name);
+                return AccessController.doPrivileged(pa);
+            }
+            @Override
+            public Set<ModuleReference> findAll() {
+                PrivilegedAction<Set<ModuleReference>> pa = finder::findAll;
+                return AccessController.doPrivileged(pa);
+            }
+        };
+    }
+
+    /**
      * Returns a module finder that locates modules on the file system by
      * searching a sequence of directories and/or packaged modules.
      *
@@ -201,7 +222,7 @@
      *
      * <p> If an element is a path to a directory of modules then each entry in
      * the directory is a packaged module or the top-level directory of an
-     * exploded module. It it an error if a directory contains more than one
+     * exploded module. It is an error if a directory contains more than one
      * module with the same name. If an element is a path to a directory, and
      * that directory contains a file named {@code module-info.class}, then the
      * directory is treated as an exploded module rather than a directory of
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleReader.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleReader.java	Wed Jul 05 23:09:40 2017 +0200
@@ -48,7 +48,11 @@
  * <p> A resource in a module is identified by an abstract name that is a
  * '{@code /}'-separated path string. For example, module {@code java.base} may
  * have a resource "{@code java/lang/Object.class}" that, by convention, is the
- * class file for {@code java.lang.Object}. </p>
+ * class file for {@code java.lang.Object}. A module reader may treat
+ * directories in the module content as resources (whether it does or not is
+ * module reader specific). Where the module content contains a directory
+ * that can be located as a resource then its name ends with a slash ('/'). The
+ * directory can also be located with a name that drops the trailing slash. </p>
  *
  * <p> A {@code ModuleReader} is {@linkplain ModuleReference#open open} upon
  * creation and is closed by invoking the {@link #close close} method.  Failure
@@ -80,6 +84,9 @@
     /**
      * Finds a resource, returning a URI to the resource in the module.
      *
+     * <p> If the module reader can determine that the name locates a directory
+     * then the resulting URI will end with a slash ('/'). </p>
+     *
      * @param  name
      *         The name of the resource to open for reading
      *
@@ -140,7 +147,7 @@
      *
      * @apiNote This method is intended for high-performance class loading. It
      * is not capable (or intended) to read arbitrary large resources that
-     * could potentially be 2GB or larger. The rational for using this method
+     * could potentially be 2GB or larger. The rationale for using this method
      * in conjunction with the {@code release} method is to allow module reader
      * implementations manage buffers in an efficient manner.
      *
@@ -195,7 +202,9 @@
 
     /**
      * Lists the contents of the module, returning a stream of elements that
-     * are the names of all resources in the module.
+     * are the names of all resources in the module. Whether the stream of
+     * elements includes names corresponding to directories in the module is
+     * module reader specific.
      *
      * <p> In lazy implementations then an {@code IOException} may be thrown
      * when using the stream to list the module contents. If this occurs then
--- a/jdk/src/java.base/share/classes/java/lang/module/Resolver.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/Resolver.java	Wed Jul 05 23:09:40 2017 +0200
@@ -47,6 +47,7 @@
 
 import jdk.internal.module.ModuleHashes;
 import jdk.internal.module.ModuleReferenceImpl;
+import jdk.internal.module.ModuleTarget;
 
 /**
  * The resolver used by {@link Configuration#resolve} and {@link
@@ -69,11 +70,9 @@
     // module constraints on target platform
     private String osName;
     private String osArch;
-    private String osVersion;
 
     String osName() { return osName; }
     String osArch() { return osArch; }
-    String osVersion() { return osVersion; }
 
     /**
      * @throws IllegalArgumentException if there are more than one parent and
@@ -110,16 +109,6 @@
                     }
                 }
             }
-            value = parent.osVersion();
-            if (value != null) {
-                if (osVersion == null) {
-                    osVersion  = value;
-                } else {
-                    if (!value.equals(osVersion)) {
-                        failParentConflict("OS version", osVersion, value);
-                    }
-                }
-            }
         }
     }
 
@@ -318,13 +307,15 @@
      * the target platform with the constraints of other modules.
      */
     private void addFoundModule(ModuleReference mref) {
-        ModuleDescriptor descriptor = mref.descriptor();
-        nameToReference.put(descriptor.name(), mref);
+        String mn = mref.descriptor().name();
 
-        if (descriptor.osName().isPresent()
-                || descriptor.osArch().isPresent()
-                || descriptor.osVersion().isPresent())
-            checkTargetConstraints(descriptor);
+        if (mref instanceof ModuleReferenceImpl) {
+            ModuleTarget target = ((ModuleReferenceImpl)mref).moduleTarget();
+            if (target != null)
+                checkTargetConstraints(mn, target);
+        }
+
+        nameToReference.put(mn, mref);
     }
 
     /**
@@ -332,58 +323,44 @@
      * conflict with the constraints of other modules resolved so far or
      * modules in parent configurations.
      */
-    private void checkTargetConstraints(ModuleDescriptor descriptor) {
-        String value = descriptor.osName().orElse(null);
+    private void checkTargetConstraints(String mn, ModuleTarget target) {
+        String value = target.osName();
         if (value != null) {
             if (osName == null) {
                 osName = value;
             } else {
                 if (!value.equals(osName)) {
-                    failTargetConstraint(descriptor);
+                    failTargetConstraint(mn, target);
                 }
             }
         }
-        value = descriptor.osArch().orElse(null);
+        value = target.osArch();
         if (value != null) {
             if (osArch == null) {
                 osArch = value;
             } else {
                 if (!value.equals(osArch)) {
-                    failTargetConstraint(descriptor);
-                }
-            }
-        }
-        value = descriptor.osVersion().orElse(null);
-        if (value != null) {
-            if (osVersion == null) {
-                osVersion = value;
-            } else {
-                if (!value.equals(osVersion)) {
-                    failTargetConstraint(descriptor);
+                    failTargetConstraint(mn, target);
                 }
             }
         }
     }
 
-    private void failTargetConstraint(ModuleDescriptor md) {
-        String s1 = targetAsString(osName, osArch, osVersion);
-        String s2 = targetAsString(md);
-        findFail("Module %s has constraints on target platform that conflict" +
-                 " with other modules: %s, %s", md.name(), s1, s2);
+    private void failTargetConstraint(String mn, ModuleTarget target) {
+        String s1 = targetAsString(osName, osArch);
+        String s2 = targetAsString(target.osName(), target.osArch());
+        findFail("Module %s has constraints on target platform (%s) that"
+                 + " conflict with other modules: %s", mn, s1, s2);
     }
 
-    private String targetAsString(ModuleDescriptor descriptor) {
-        String osName = descriptor.osName().orElse(null);
-        String osArch = descriptor.osArch().orElse(null);
-        String osVersion = descriptor.osVersion().orElse(null);
-        return targetAsString(osName, osArch, osVersion);
+    private String targetAsString(ModuleTarget target) {
+        return targetAsString(target.osName(), target.osArch());
     }
 
-    private String targetAsString(String osName, String osArch, String osVersion) {
+    private String targetAsString(String osName, String osArch) {
         return new StringJoiner("-")
                 .add(Objects.toString(osName, "*"))
                 .add(Objects.toString(osArch, "*"))
-                .add(Objects.toString(osVersion, "*"))
                 .toString();
     }
 
@@ -712,16 +689,30 @@
 
 
     /**
-     * Checks the readability graph to ensure that no two modules export the
-     * same package to a module. This includes the case where module M has
-     * a local package P and M reads another module that exports P to M.
-     * Also checks the uses/provides of module M to ensure that it reads a
-     * module that exports the package of the service type to M.
+     * Checks the readability graph to ensure that
+     * <ol>
+     *   <li><p> A module does not read two or more modules with the same name.
+     *   This includes the case where a module reads another another with the
+     *   same name as itself. </p></li>
+     *   <li><p> Two or more modules in the configuration don't export the same
+     *   package to a module that reads both. This includes the case where a
+     *   module {@code M} containing package {@code p} reads another module
+     *   that exports {@code p} to {@code M}. </p></li>
+     *   <li><p> A module {@code M} doesn't declare that it "{@code uses p.S}"
+     *   or "{@code provides p.S with ...}" but package {@code p} is neither
+     *   in module {@code M} nor exported to {@code M} by any module that
+     *   {@code M} reads. </p></li>
+     * </ol>
      */
     private void checkExportSuppliers(Map<ResolvedModule, Set<ResolvedModule>> graph) {
 
         for (Map.Entry<ResolvedModule, Set<ResolvedModule>> e : graph.entrySet()) {
             ModuleDescriptor descriptor1 = e.getKey().descriptor();
+            String name1 = descriptor1.name();
+
+            // the names of the modules that are read (including self)
+            Set<String> names = new HashSet<>();
+            names.add(name1);
 
             // the map of packages that are local or exported to descriptor1
             Map<String, ModuleDescriptor> packageToExporter = new HashMap<>();
@@ -737,9 +728,20 @@
             for (ResolvedModule endpoint : reads) {
                 ModuleDescriptor descriptor2 = endpoint.descriptor();
 
+                String name2 = descriptor2.name();
+                if (descriptor2 != descriptor1 && !names.add(name2)) {
+                    if (name2.equals(name1)) {
+                        resolveFail("Module %s reads another module named %s",
+                                    name1, name1);
+                    } else{
+                        resolveFail("Module %s reads more than one module named %s",
+                                     name1, name2);
+                    }
+                }
+
                 if (descriptor2.isAutomatic()) {
                     // automatic modules read self and export all packages
-                    if (descriptor2 != descriptor1){
+                    if (descriptor2 != descriptor1) {
                         for (String source : descriptor2.packages()) {
                             ModuleDescriptor supplier
                                 = packageToExporter.putIfAbsent(source, descriptor2);
--- a/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,9 +28,12 @@
 import java.lang.annotation.Annotation;
 import java.security.AccessController;
 
+import jdk.internal.misc.VM;
+import jdk.internal.module.IllegalAccessLogger;
 import jdk.internal.reflect.CallerSensitive;
 import jdk.internal.reflect.Reflection;
 import jdk.internal.reflect.ReflectionFactory;
+import sun.security.action.GetPropertyAction;
 
 /**
  * The {@code AccessibleObject} class is the base class for {@code Field},
@@ -288,27 +291,20 @@
         if (callerModule == Object.class.getModule()) return true;
         if (!declaringModule.isNamed()) return true;
 
-        // package is open to caller
-        String pn = packageName(declaringClass);
-        if (declaringModule.isOpen(pn, callerModule)) {
-            dumpStackIfOpenedReflectively(declaringModule, pn, callerModule);
-            return true;
-        }
-
-        // package is exported to caller
-        boolean isExported = declaringModule.isExported(pn, callerModule);
-        boolean isClassPublic = Modifier.isPublic(declaringClass.getModifiers());
+        String pn = declaringClass.getPackageName();
         int modifiers;
         if (this instanceof Executable) {
             modifiers = ((Executable) this).getModifiers();
         } else {
             modifiers = ((Field) this).getModifiers();
         }
-        if (isExported && isClassPublic) {
 
+        // class is public and package is exported to caller
+        boolean isClassPublic = Modifier.isPublic(declaringClass.getModifiers());
+        if (isClassPublic && declaringModule.isExported(pn, callerModule)) {
             // member is public
             if (Modifier.isPublic(modifiers)) {
-                dumpStackIfExportedReflectively(declaringModule, pn, callerModule);
+                logIfExportedByBackdoor(caller, declaringClass);
                 return true;
             }
 
@@ -316,11 +312,17 @@
             if (Modifier.isProtected(modifiers)
                 && Modifier.isStatic(modifiers)
                 && isSubclassOf(caller, declaringClass)) {
-                dumpStackIfExportedReflectively(declaringModule, pn, callerModule);
+                logIfExportedByBackdoor(caller, declaringClass);
                 return true;
             }
         }
 
+        // package is open to caller
+        if (declaringModule.isOpen(pn, callerModule)) {
+            logIfOpenedByBackdoor(caller, declaringClass);
+            return true;
+        }
+
         if (throwExceptionIfDenied) {
             // not accessible
             String msg = "Unable to make ";
@@ -333,7 +335,7 @@
                 msg += "opens";
             msg += " " + pn + "\" to " + callerModule;
             InaccessibleObjectException e = new InaccessibleObjectException(msg);
-            if (Reflection.printStackTraceWhenAccessFails()) {
+            if (printStackTraceWhenAccessFails()) {
                 e.printStackTrace(System.err);
             }
             throw e;
@@ -351,48 +353,35 @@
         return false;
     }
 
-    private void dumpStackIfOpenedReflectively(Module module,
-                                               String pn,
-                                               Module other) {
-        dumpStackIfExposedReflectively(module, pn, other, true);
-    }
-
-    private void dumpStackIfExportedReflectively(Module module,
-                                                 String pn,
-                                                 Module other) {
-        dumpStackIfExposedReflectively(module, pn, other, false);
+    private void logIfOpenedByBackdoor(Class<?> caller, Class<?> declaringClass) {
+        Module callerModule = caller.getModule();
+        Module targetModule = declaringClass.getModule();
+        // callerModule is null during early startup
+        if (callerModule != null && !callerModule.isNamed() && targetModule.isNamed()) {
+            IllegalAccessLogger logger = IllegalAccessLogger.illegalAccessLogger();
+            if (logger != null) {
+                logger.logIfOpenedByBackdoor(caller, declaringClass, this::toShortString);
+            }
+        }
     }
 
-    private void dumpStackIfExposedReflectively(Module module,
-                                                String pn,
-                                                Module other,
-                                                boolean open)
-    {
-        if (Reflection.printStackTraceWhenAccessSucceeds()
-                && !module.isStaticallyExportedOrOpen(pn, other, open))
-        {
-            String msg = other + " allowed to invoke setAccessible on ";
-            if (this instanceof Field)
-                msg += "field ";
-            msg += this;
-            new Exception(msg) {
-                private static final long serialVersionUID = 42L;
-                public String toString() {
-                    return "WARNING: " + getMessage();
-                }
-            }.printStackTrace(System.err);
+    private void logIfExportedByBackdoor(Class<?> caller, Class<?> declaringClass) {
+        Module callerModule = caller.getModule();
+        Module targetModule = declaringClass.getModule();
+        // callerModule is null during early startup
+        if (callerModule != null && !callerModule.isNamed() && targetModule.isNamed()) {
+            IllegalAccessLogger logger = IllegalAccessLogger.illegalAccessLogger();
+            if (logger != null) {
+                logger.logIfExportedByBackdoor(caller, declaringClass, this::toShortString);
+            }
         }
     }
 
     /**
-     * Returns the package name of the given class.
+     * Returns a short descriptive string to describe this object in log messages.
      */
-    private static String packageName(Class<?> c) {
-        while (c.isArray()) {
-            c = c.getComponentType();
-        }
-        String pn = c.getPackageName();
-        return (pn != null) ? pn : "";
+    String toShortString() {
+        return toString();
     }
 
     /**
@@ -409,6 +398,7 @@
      * it should use {@link #canAccess(Object)}.
      *
      * @revised 9
+     * @spec JPMS
      */
     @Deprecated(since="9")
     public boolean isAccessible() {
@@ -483,10 +473,7 @@
         } else {
             targetClass = Modifier.isStatic(modifiers) ? null : obj.getClass();
         }
-        return Reflection.verifyMemberAccess(caller,
-                                             declaringClass,
-                                             targetClass,
-                                             modifiers);
+        return verifyAccess(caller, declaringClass, targetClass, modifiers);
     }
 
     /**
@@ -527,7 +514,7 @@
         return AnnotatedElement.super.isAnnotationPresent(annotationClass);
     }
 
-   /**
+    /**
      * @throws NullPointerException {@inheritDoc}
      * @since 1.8
      */
@@ -598,8 +585,21 @@
                            Class<?> targetClass, int modifiers)
         throws IllegalAccessException
     {
+        if (!verifyAccess(caller, memberClass, targetClass, modifiers)) {
+            IllegalAccessException e = Reflection.newIllegalAccessException(
+                caller, memberClass, targetClass, modifiers);
+            if (printStackTraceWhenAccessFails()) {
+                e.printStackTrace(System.err);
+            }
+            throw e;
+        }
+    }
+
+    final boolean verifyAccess(Class<?> caller, Class<?> memberClass,
+                               Class<?> targetClass, int modifiers)
+    {
         if (caller == memberClass) {  // quick check
-            return;             // ACCESS IS OK
+            return true;             // ACCESS IS OK
         }
         Object cache = securityCheckCache;  // read volatile
         if (targetClass != null // instance member or constructor
@@ -610,26 +610,31 @@
                 Class<?>[] cache2 = (Class<?>[]) cache;
                 if (cache2[1] == targetClass &&
                     cache2[0] == caller) {
-                    return;     // ACCESS IS OK
+                    return true;     // ACCESS IS OK
                 }
                 // (Test cache[1] first since range check for [1]
                 // subsumes range check for [0].)
             }
         } else if (cache == caller) {
             // Non-protected case (or targetClass == memberClass or static member).
-            return;             // ACCESS IS OK
+            return true;             // ACCESS IS OK
         }
 
         // If no return, fall through to the slow path.
-        slowCheckMemberAccess(caller, memberClass, targetClass, modifiers);
+        return slowVerifyAccess(caller, memberClass, targetClass, modifiers);
     }
 
     // Keep all this slow stuff out of line:
-    void slowCheckMemberAccess(Class<?> caller, Class<?> memberClass,
-                               Class<?> targetClass, int modifiers)
-        throws IllegalAccessException
+    private boolean slowVerifyAccess(Class<?> caller, Class<?> memberClass,
+                                     Class<?> targetClass, int modifiers)
     {
-        Reflection.ensureMemberAccess(caller, memberClass, targetClass, modifiers);
+        if (!Reflection.verifyMemberAccess(caller, memberClass, targetClass, modifiers)) {
+            // access denied
+            return false;
+        }
+
+        // access okay
+        logIfExportedByBackdoor(caller, memberClass);
 
         // Success: Update the cache.
         Object cache = (targetClass != null
@@ -643,5 +648,27 @@
         // guarantees that the initializing stores for the cache
         // elements will occur before the volatile write.
         securityCheckCache = cache;         // write volatile
+        return true;
+    }
+
+    // true to print a stack trace when access fails
+    private static volatile boolean printStackWhenAccessFails;
+
+    // true if printStack* values are initialized
+    private static volatile boolean printStackPropertiesSet;
+
+    /**
+     * Returns true if a stack trace should be printed when access fails.
+     */
+    private static boolean printStackTraceWhenAccessFails() {
+        if (!printStackPropertiesSet && VM.initLevel() >= 1) {
+            String s = GetPropertyAction.privilegedGetProperty(
+                    "sun.reflect.debugModuleAccessChecks");
+            if (s != null) {
+                printStackWhenAccessFails = !s.equalsIgnoreCase("false");
+            }
+            printStackPropertiesSet = true;
+        }
+        return printStackWhenAccessFails;
     }
 }
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java	Wed Jul 05 23:09:40 2017 +0200
@@ -38,6 +38,7 @@
 import sun.reflect.generics.scope.ConstructorScope;
 import java.lang.annotation.Annotation;
 import java.lang.annotation.AnnotationFormatError;
+import java.util.StringJoiner;
 
 /**
  * {@code Constructor} provides information about, and access to, a single
@@ -173,7 +174,6 @@
      * @throws SecurityException if the request is denied by the security manager
      *         or this is a constructor for {@code java.lang.Class}
      *
-     * @since 9
      * @spec JPMS
      */
     @Override
@@ -360,6 +360,20 @@
         sb.append(getDeclaringClass().getTypeName());
     }
 
+    @Override
+    String toShortString() {
+        StringBuilder sb = new StringBuilder("constructor ");
+        sb.append(getDeclaringClass().getTypeName());
+        sb.append('(');
+        StringJoiner sj = new StringJoiner(",");
+        for (Class<?> parameterType : getParameterTypes()) {
+            sj.add(parameterType.getTypeName());
+        }
+        sb.append(sj);
+        sb.append(')');
+        return sb.toString();
+    }
+
     /**
      * Returns a string describing this {@code Constructor},
      * including type parameters.  The string is formatted as the
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Field.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Field.java	Wed Jul 05 23:09:40 2017 +0200
@@ -324,6 +324,11 @@
             + getName());
     }
 
+    @Override
+    String toShortString() {
+        return "field " + getDeclaringClass().getTypeName() + "." + getName();
+    }
+
     /**
      * Returns a string describing this {@code Field}, including
      * its generic type.  The format is the access modifiers for the
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -66,9 +66,7 @@
  * ResolvedModule} in the configuration. For each resolved module that is
  * {@link ResolvedModule#reads() read}, the {@code Module} {@link
  * Module#canRead reads} the corresponding run-time {@code Module}, which may
- * be in the same layer or a {@link #parents() parent} layer. The {@code Module}
- * {@link Module#isExported(String) exports} and {@link Module#isOpen(String)
- * opens} the packages described by its {@link ModuleDescriptor}. </p>
+ * be in the same layer or a {@link #parents() parent} layer. </p>
  *
  * <p> The {@link #defineModulesWithOneLoader defineModulesWithOneLoader} and
  * {@link #defineModulesWithManyLoaders defineModulesWithManyLoaders} methods
@@ -91,6 +89,28 @@
  * built-in</a> into the Java virtual machine. The boot layer will often be
  * the {@link #parents() parent} when creating additional layers. </p>
  *
+ * <p> Each {@code Module} in a layer is created so that it {@link
+ * Module#isExported(String) exports} and {@link Module#isOpen(String) opens}
+ * the packages described by its {@link ModuleDescriptor}. Qualified exports
+ * (where a package is exported to a set of target modules rather than all
+ * modules) are reified when creating the layer as follows: </p>
+ * <ul>
+ *     <li> If module {@code X} exports a package to {@code Y}, and if the
+ *     runtime {@code Module} {@code X} reads {@code Module} {@code Y}, then
+ *     the package is exported to {@code Module} {@code Y} (which may be in
+ *     the same layer as {@code X} or a parent layer). </li>
+ *
+ *     <li> If module {@code X} exports a package to {@code Y}, and if the
+ *     runtime {@code Module} {@code X} does not read {@code Y} then target
+ *     {@code Y} is located as if by invoking {@link #findModule(String)
+ *     findModule} to find the module in the layer or its parent layers. If
+ *     {@code Y} is found then the package is exported to the instance of
+ *     {@code Y} that was found. If {@code Y} is not found then the qualified
+ *     export is ignored. </li>
+ * </ul>
+ *
+ * <p> Qualified opens are handled in same way as qualified exports. </p>
+ *
  * <p> As when creating a {@code Configuration},
  * {@link ModuleDescriptor#isAutomatic() automatic} modules receive special
  * treatment when creating a layer. An automatic module is created in the
@@ -193,7 +213,7 @@
         }
 
         private void ensureInLayer(Module source) {
-            if (!layer.modules().contains(source))
+            if (source.getLayer() != layer)
                 throw new IllegalArgumentException(source + " not in layer");
         }
 
@@ -220,9 +240,8 @@
          * @see Module#addReads
          */
         public Controller addReads(Module source, Module target) {
-            Objects.requireNonNull(source);
+            ensureInLayer(source);
             Objects.requireNonNull(target);
-            ensureInLayer(source);
             Modules.addReads(source, target);
             return this;
         }
@@ -248,9 +267,9 @@
          * @see Module#addOpens
          */
         public Controller addOpens(Module source, String pn, Module target) {
-            Objects.requireNonNull(source);
+            ensureInLayer(source);
+            Objects.requireNonNull(pn);
             Objects.requireNonNull(target);
-            ensureInLayer(source);
             Modules.addOpens(source, pn, target);
             return this;
         }
@@ -408,8 +427,8 @@
      * </ul>
      *
      * <p> In addition, a layer cannot be created if the configuration contains
-     * a module named "{@code java.base}" or a module with a package name
-     * starting with "{@code java.}". </p>
+     * a module named "{@code java.base}", or a module contains a package named
+     * "{@code java}" or a package with a name starting with "{@code java.}". </p>
      *
      * <p> If there is a security manager then the class loader created by
      * this method will load classes and resources with privileges that are
@@ -418,7 +437,7 @@
      * @param  cf
      *         The configuration for the layer
      * @param  parentLayers
-     *         The list parent layers in search order
+     *         The list of parent layers in search order
      * @param  parentLoader
      *         The parent class loader for the class loader created by this
      *         method; may be {@code null} for the bootstrap class loader
@@ -485,7 +504,7 @@
      * @param  cf
      *         The configuration for the layer
      * @param  parentLayers
-     *         The list parent layers in search order
+     *         The list of parent layers in search order
      * @param  parentLoader
      *         The parent class loader for each of the class loaders created by
      *         this method; may be {@code null} for the bootstrap class loader
@@ -497,8 +516,10 @@
      *         the parent layers, including order
      * @throws LayerInstantiationException
      *         If the layer cannot be created because the configuration contains
-     *         a module named "{@code java.base}" or a module with a package
-     *         name starting with "{@code java.}"
+     *         a module named "{@code java.base}" or a module contains a package
+     *         named "{@code java}" or a package with a name starting with
+     *         "{@code java.}"
+     *
      * @throws SecurityException
      *         If {@code RuntimePermission("createClassLoader")} or
      *         {@code RuntimePermission("getClassLoader")} is denied by
@@ -558,10 +579,11 @@
      *
      * <p> In addition, a layer cannot be created if the configuration contains
      * a module named "{@code java.base}", a configuration contains a module
-     * with a package name starting with "{@code java.}" is mapped to a class
-     * loader other than the {@link ClassLoader#getPlatformClassLoader()
-     * platform class loader}, or the function to map a module name to a class
-     * loader returns {@code null}. </p>
+     * with a package named "{@code java}" or a package name starting with
+     * "{@code java.}" and the module is mapped to a class loader other than
+     * the {@link ClassLoader#getPlatformClassLoader() platform class loader},
+     * or the function to map a module name to a class loader returns
+     * {@code null}. </p>
      *
      * <p> If the function to map a module name to class loader throws an error
      * or runtime exception then it is propagated to the caller of this method.
@@ -575,7 +597,7 @@
      * @param  cf
      *         The configuration for the layer
      * @param  parentLayers
-     *         The list parent layers in search order
+     *         The list of parent layers in search order
      * @param  clf
      *         The function to map a module name to a class loader
      *
@@ -754,10 +776,16 @@
      * @return A possibly-empty unmodifiable set of the modules in this layer
      */
     public Set<Module> modules() {
-        return Collections.unmodifiableSet(
-                nameToModule.values().stream().collect(Collectors.toSet()));
+        Set<Module> modules = this.modules;
+        if (modules == null) {
+            this.modules = modules =
+                Collections.unmodifiableSet(new HashSet<>(nameToModule.values()));
+        }
+        return modules;
     }
 
+    private volatile Set<Module> modules;
+
 
     /**
      * Returns the module with the given name in this layer, or if not in this
@@ -776,6 +804,8 @@
      */
     public Optional<Module> findModule(String name) {
         Objects.requireNonNull(name);
+        if (this == EMPTY_LAYER)
+            return Optional.empty();
         Module m = nameToModule.get(name);
         if (m != null)
             return Optional.of(m);
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Method.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Method.java	Wed Jul 05 23:09:40 2017 +0200
@@ -42,6 +42,7 @@
 import java.lang.annotation.Annotation;
 import java.lang.annotation.AnnotationFormatError;
 import java.nio.ByteBuffer;
+import java.util.StringJoiner;
 
 /**
  * A {@code Method} provides information about, and access to, a single method
@@ -416,6 +417,21 @@
         sb.append(getName());
     }
 
+    @Override
+    String toShortString() {
+        StringBuilder sb = new StringBuilder("method ");
+        sb.append(getDeclaringClass().getTypeName()).append('.');
+        sb.append(getName());
+        sb.append('(');
+        StringJoiner sj = new StringJoiner(",");
+        for (Class<?> parameterType : getParameterTypes()) {
+            sj.add(parameterType.getTypeName());
+        }
+        sb.append(sj);
+        sb.append(')');
+        return sb.toString();
+    }
+
     /**
      * Returns a string describing this {@code Method}, including
      * type parameters.  The string is formatted as the method access
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Module.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Module.java	Wed Jul 05 23:09:40 2017 +0200
@@ -39,8 +39,10 @@
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
@@ -51,11 +53,11 @@
 
 import jdk.internal.loader.BuiltinClassLoader;
 import jdk.internal.loader.BootLoader;
-import jdk.internal.loader.ResourceHelper;
 import jdk.internal.misc.JavaLangAccess;
 import jdk.internal.misc.JavaLangReflectModuleAccess;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.module.ServicesCatalog;
+import jdk.internal.module.Resources;
 import jdk.internal.org.objectweb.asm.AnnotationVisitor;
 import jdk.internal.org.objectweb.asm.Attribute;
 import jdk.internal.org.objectweb.asm.ClassReader;
@@ -369,28 +371,19 @@
      * If {@code syncVM} is {@code true} then the VM is notified.
      */
     private void implAddReads(Module other, boolean syncVM) {
-        Objects.requireNonNull(other);
-
-        // nothing to do
-        if (other == this || !this.isNamed())
-            return;
-
-        // check if we already read this module
-        Set<Module> reads = this.reads;
-        if (reads != null && reads.contains(other))
-            return;
+        if (!canRead(other)) {
+            // update VM first, just in case it fails
+            if (syncVM) {
+                if (other == ALL_UNNAMED_MODULE) {
+                    addReads0(this, null);
+                } else {
+                    addReads0(this, other);
+                }
+            }
 
-        // update VM first, just in case it fails
-        if (syncVM) {
-            if (other == ALL_UNNAMED_MODULE) {
-                addReads0(this, null);
-            } else {
-                addReads0(this, other);
-            }
+            // add reflective read
+            reflectivelyReads.putIfAbsent(this, other, Boolean.TRUE);
         }
-
-        // add reflective read
-        reflectivelyReads.putIfAbsent(this, other, Boolean.TRUE);
     }
 
 
@@ -553,7 +546,7 @@
      * Returns {@code true} if this module exports or opens a package to
      * the given module via its module declaration.
      */
-    boolean isStaticallyExportedOrOpen(String pn, Module other, boolean open) {
+    private boolean isStaticallyExportedOrOpen(String pn, Module other, boolean open) {
         // package is open to everyone or <other>
         Map<String, Set<Module>> openPackages = this.openPackages;
         if (openPackages != null) {
@@ -909,9 +902,7 @@
      * Returns an array of the package names of the packages in this module.
      *
      * <p> For named modules, the returned array contains an element for each
-     * package in the module. It may contain elements corresponding to packages
-     * added to the module, <a href="Proxy.html#dynamicmodule">dynamic modules</a>
-     * for example, after it was loaded.
+     * package in the module. </p>
      *
      * <p> For unnamed modules, this method is the equivalent to invoking the
      * {@link ClassLoader#getDefinedPackages() getDefinedPackages} method of
@@ -950,15 +941,6 @@
     }
 
     /**
-     * Add a package to this module.
-     *
-     * @apiNote This method is for Proxy use.
-     */
-    void addPackage(String pn) {
-        implAddPackage(pn, true);
-    }
-
-    /**
      * Add a package to this module without notifying the VM.
      *
      * @apiNote This method is VM white-box testing.
@@ -1080,20 +1062,28 @@
 
             // reads
             Set<Module> reads = new HashSet<>();
+
+            // name -> source Module when in parent layer
+            Map<String, Module> nameToSource = Collections.emptyMap();
+
             for (ResolvedModule other : resolvedModule.reads()) {
                 Module m2 = null;
                 if (other.configuration() == cf) {
-                    String dn = other.reference().descriptor().name();
-                    m2 = nameToModule.get(dn);
+                    // this configuration
+                    m2 = nameToModule.get(other.name());
+                    assert m2 != null;
                 } else {
+                    // parent layer
                     for (Layer parent: layer.parents()) {
                         m2 = findModule(parent, other);
                         if (m2 != null)
                             break;
                     }
+                    assert m2 != null;
+                    if (nameToSource.isEmpty())
+                        nameToSource = new HashMap<>();
+                    nameToSource.put(other.name(), m2);
                 }
-                assert m2 != null;
-
                 reads.add(m2);
 
                 // update VM view
@@ -1107,7 +1097,7 @@
             }
 
             // exports and opens
-            initExportsAndOpens(descriptor, nameToModule, m);
+            initExportsAndOpens(m, nameToSource, nameToModule, layer.parents());
         }
 
         // register the modules in the boot layer
@@ -1159,15 +1149,17 @@
                 .orElse(null);
     }
 
+
     /**
      * Initialize the maps of exported and open packages for module m.
      */
-    private static void initExportsAndOpens(ModuleDescriptor descriptor,
+    private static void initExportsAndOpens(Module m,
+                                            Map<String, Module> nameToSource,
                                             Map<String, Module> nameToModule,
-                                            Module m)
-    {
+                                            List<Layer> parents) {
         // The VM doesn't special case open or automatic modules so need to
         // export all packages
+        ModuleDescriptor descriptor = m.getDescriptor();
         if (descriptor.isOpen() || descriptor.isAutomatic()) {
             assert descriptor.opens().isEmpty();
             for (String source : descriptor.packages()) {
@@ -1187,8 +1179,7 @@
                 // qualified opens
                 Set<Module> targets = new HashSet<>();
                 for (String target : opens.targets()) {
-                    // only open to modules that are in this configuration
-                    Module m2 = nameToModule.get(target);
+                    Module m2 = findModule(target, nameToSource, nameToModule, parents);
                     if (m2 != null) {
                         addExports0(m, source, m2);
                         targets.add(m2);
@@ -1217,8 +1208,7 @@
                 // qualified exports
                 Set<Module> targets = new HashSet<>();
                 for (String target : exports.targets()) {
-                    // only export to modules that are in this configuration
-                    Module m2 = nameToModule.get(target);
+                    Module m2 = findModule(target, nameToSource, nameToModule, parents);
                     if (m2 != null) {
                         // skip qualified export if already open to m2
                         if (openToTargets == null || !openToTargets.contains(m2)) {
@@ -1244,6 +1234,32 @@
             m.exportedPackages = exportedPackages;
     }
 
+    /**
+     * Find the runtime Module with the given name. The module name is the
+     * name of a target module in a qualified exports or opens directive.
+     *
+     * @param target The target module to find
+     * @param nameToSource The modules in parent layers that are read
+     * @param nameToModule The modules in the layer under construction
+     * @param parents The parent layers
+     */
+    private static Module findModule(String target,
+                                     Map<String, Module> nameToSource,
+                                     Map<String, Module> nameToModule,
+                                     List<Layer> parents) {
+        Module m = nameToSource.get(target);
+        if (m == null) {
+            m = nameToModule.get(target);
+            if (m == null) {
+                for (Layer parent : parents) {
+                    m = parent.findModule(target).orElse(null);
+                    if (m != null) break;
+                }
+            }
+        }
+        return m;
+    }
+
 
     // -- annotations --
 
@@ -1428,12 +1444,12 @@
             name = name.substring(1);
         }
 
-        if (isNamed() && !ResourceHelper.isSimpleResource(name)) {
+        if (isNamed() && Resources.canEncapsulate(name)) {
             Module caller = Reflection.getCallerClass().getModule();
             if (caller != this && caller != Object.class.getModule()) {
                 // ignore packages added for proxies via addPackage
                 Set<String> packages = getDescriptor().packages();
-                String pn = ResourceHelper.getPackageName(name);
+                String pn = Resources.toPackageName(name);
                 if (packages.contains(pn) && !isOpen(pn, caller)) {
                     // resource is in package not open to caller
                     return null;
@@ -1531,26 +1547,26 @@
                     m.implAddReads(Module.ALL_UNNAMED_MODULE);
                 }
                 @Override
+                public void addExports(Module m, String pn) {
+                    m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, false, true);
+                }
+                @Override
                 public void addExports(Module m, String pn, Module other) {
                     m.implAddExportsOrOpens(pn, other, false, true);
                 }
                 @Override
+                public void addExportsToAllUnnamed(Module m, String pn) {
+                    m.implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, false, true);
+                }
+                @Override
+                public void addOpens(Module m, String pn) {
+                    m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, true, true);
+                }
+                @Override
                 public void addOpens(Module m, String pn, Module other) {
                     m.implAddExportsOrOpens(pn, other, true, true);
                 }
                 @Override
-                public void addExportsToAll(Module m, String pn) {
-                    m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, false, true);
-                }
-                @Override
-                public void addOpensToAll(Module m, String pn) {
-                    m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, true, true);
-                }
-                @Override
-                public void addExportsToAllUnnamed(Module m, String pn) {
-                    m.implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, false, true);
-                }
-                @Override
                 public void addOpensToAllUnnamed(Module m, String pn) {
                     m.implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, true, true);
                 }
@@ -1559,10 +1575,6 @@
                     m.implAddUses(service);
                 }
                 @Override
-                public void addPackage(Module m, String pn) {
-                    m.implAddPackage(pn, true);
-                }
-                @Override
                 public ServicesCatalog getServicesCatalog(Layer layer) {
                     return layer.getServicesCatalog();
                 }
@@ -1574,10 +1586,6 @@
                 public Stream<Layer> layers(ClassLoader loader) {
                     return Layer.layers(loader);
                 }
-                @Override
-                public boolean isStaticallyExported(Module module, String pn, Module other) {
-                    return module.isStaticallyExportedOrOpen(pn, other, false);
-                }
             });
     }
 }
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java	Wed Jul 05 23:09:40 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
@@ -359,10 +359,11 @@
      * @throws  NullPointerException if the {@code interfaces} array
      *          argument or any of its elements are {@code null}
      *
-     * @deprecated Proxy classes generated in a named module are encapsulated and not
-     *      accessible to code outside its module.
-     *      {@link Constructor#newInstance(Object...) Constructor.newInstance} will throw
-     *      {@code IllegalAccessException} when it is called on an inaccessible proxy class.
+     * @deprecated Proxy classes generated in a named module are encapsulated
+     *      and not accessible to code outside its module.
+     *      {@link Constructor#newInstance(Object...) Constructor.newInstance}
+     *      will throw {@code IllegalAccessException} when it is called on
+     *      an inaccessible proxy class.
      *      Use {@link #newProxyInstance(ClassLoader, Class[], InvocationHandler)}
      *      to create a proxy instance instead.
      *
@@ -511,17 +512,19 @@
                         "Unnamed package cannot be added to " + m);
             }
 
-            // add the package to the runtime module if not exists
             if (m.isNamed()) {
-                m.addPackage(proxyPkg);
+                if (!m.getDescriptor().packages().contains(proxyPkg)) {
+                    throw new InternalError(proxyPkg + " not exist in " + m.getName());
+                }
             }
 
             /*
              * Choose a name for the proxy class to generate.
              */
             long num = nextUniqueNumber.getAndIncrement();
-            String proxyName = proxyPkg.isEmpty() ? proxyClassNamePrefix + num
-                                                  : proxyPkg + "." + proxyClassNamePrefix + num;
+            String proxyName = proxyPkg.isEmpty()
+                                    ? proxyClassNamePrefix + num
+                                    : proxyPkg + "." + proxyClassNamePrefix + num;
 
             ClassLoader loader = getLoader(m);
             trace(proxyName, m, loader, interfaces);
@@ -581,9 +584,13 @@
                     c.getModule().getName(), c.getName(), access, ld);
         }
 
-        static void trace(String cn, Module module, ClassLoader loader, List<Class<?>> interfaces) {
+        static void trace(String cn,
+                          Module module,
+                          ClassLoader loader,
+                          List<Class<?>> interfaces) {
             if (isDebug()) {
-                System.out.format("PROXY: %s/%s defined by %s%n", module.getName(), cn, loader);
+                System.err.format("PROXY: %s/%s defined by %s%n",
+                                  module.getName(), cn, loader);
             }
             if (isDebug("debug")) {
                 interfaces.stream()
@@ -592,7 +599,7 @@
         }
 
         private static final String DEBUG =
-                GetPropertyAction.privilegedGetProperty("jdk.proxy.debug", "");
+            GetPropertyAction.privilegedGetProperty("jdk.proxy.debug", "");
 
         private static boolean isDebug() {
             return !DEBUG.isEmpty();
@@ -603,15 +610,16 @@
 
         // ProxyBuilder instance members start here....
 
-        private final ClassLoader loader;
         private final List<Class<?>> interfaces;
         private final Module module;
         ProxyBuilder(ClassLoader loader, List<Class<?>> interfaces) {
             if (!VM.isModuleSystemInited()) {
-                throw new InternalError("Proxy is not supported until module system is fully initialized");
+                throw new InternalError("Proxy is not supported until "
+                        + "module system is fully initialized");
             }
             if (interfaces.size() > 65535) {
-                throw new IllegalArgumentException("interface limit exceeded: " + interfaces.size());
+                throw new IllegalArgumentException("interface limit exceeded: "
+                        + interfaces.size());
             }
 
             Set<Class<?>> refTypes = referencedTypes(loader, interfaces);
@@ -619,7 +627,6 @@
             // IAE if violates any restrictions specified in newProxyInstance
             validateProxyInterfaces(loader, interfaces, refTypes);
 
-            this.loader = loader;
             this.interfaces = interfaces;
             this.module = mapToModule(loader, interfaces, refTypes);
             assert getLoader(module) == loader;
@@ -659,8 +666,8 @@
          * Validate the given proxy interfaces and the given referenced types
          * are visible to the defining loader.
          *
-         * @throws IllegalArgumentException if it violates the restrictions specified
-         *         in {@link Proxy#newProxyInstance}
+         * @throws IllegalArgumentException if it violates the restrictions
+         *         specified in {@link Proxy#newProxyInstance}
          */
         private static void validateProxyInterfaces(ClassLoader loader,
                                                     List<Class<?>> interfaces,
@@ -731,9 +738,9 @@
          * is in the same module of the package-private interface.
          *
          * If all proxy interfaces are public and at least one in a non-exported
-         * package, then the proxy class is in a dynamic module in a non-exported
-         * package.  Reads edge and qualified exports are added for
-         * dynamic module to access.
+         * package, then the proxy class is in a dynamic module in a
+         * non-exported package.  Reads edge and qualified exports are added
+         * for dynamic module to access.
          */
         private static Module mapToModule(ClassLoader loader,
                                           List<Class<?>> interfaces,
@@ -752,11 +759,12 @@
                 }
             }
 
-            // all proxy interfaces are public and exported, the proxy class is in unnamed module
-            // Such proxy class is accessible to any unnamed module and named module that
-            // can read unnamed module
+            // all proxy interfaces are public and exported, the proxy class
+            // is in unnamed module.  Such proxy class is accessible to
+            // any unnamed module and named module that can read unnamed module
             if (packagePrivateTypes.isEmpty() && modulePrivateTypes.isEmpty()) {
-                return loader != null ? loader.getUnnamedModule() : BootLoader.getUnnamedModule();
+                return loader != null ? loader.getUnnamedModule()
+                                      : BootLoader.getUnnamedModule();
             }
 
             if (packagePrivateTypes.size() > 0) {
@@ -778,7 +786,8 @@
                 Module target = null;
                 for (Module m : packagePrivateTypes.values()) {
                     if (getLoader(m) != loader) {
-                        // the specified loader is not the same class loader of the non-public interface
+                        // the specified loader is not the same class loader
+                        // of the non-public interface
                         throw new IllegalArgumentException(
                                 "non-public interface is not defined by the given loader");
                     }
@@ -799,8 +808,9 @@
                 return target;
             }
 
-            // all proxy interfaces are public and at least one in a non-exported package
-            // map to dynamic proxy module and add reads edge and qualified exports, if necessary
+            // All proxy interfaces are public and at least one in a non-exported
+            // package.  So maps to a dynamic proxy module and add reads edge
+            // and qualified exports, if necessary
             Module target = getDynamicModule(loader);
 
             // set up proxy class access to proxy interfaces and types
@@ -856,8 +866,8 @@
         private static final AtomicInteger counter = new AtomicInteger();
 
         /*
-         * Define a dynamic module for the generated proxy classes in a non-exported package
-         * named com.sun.proxy.$MODULE.
+         * Define a dynamic module for the generated proxy classes in
+         * a non-exported package named com.sun.proxy.$MODULE.
          *
          * Each class loader will have one dynamic module.
          */
--- a/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -213,7 +213,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public final MappedByteBuffer position(int newPosition) {
@@ -223,7 +222,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public final MappedByteBuffer limit(int newLimit) {
@@ -233,7 +231,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public final MappedByteBuffer mark() {
@@ -243,7 +240,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public final MappedByteBuffer reset() {
@@ -253,7 +249,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public final MappedByteBuffer clear() {
@@ -263,7 +258,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public final MappedByteBuffer flip() {
@@ -273,7 +267,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public final MappedByteBuffer rewind() {
--- a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template	Wed Jul 05 23:09:40 2017 +0200
@@ -1069,7 +1069,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public
@@ -1083,7 +1082,6 @@
     
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public
@@ -1097,7 +1095,6 @@
     
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public 
@@ -1111,7 +1108,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public 
@@ -1125,7 +1121,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public 
@@ -1139,7 +1134,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public 
@@ -1153,7 +1147,6 @@
 
     /**
      * {@inheritDoc}
-     * @since 9
      */
     @Override
     public 
--- a/jdk/src/java.base/share/classes/java/nio/file/ClosedFileSystemException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/file/ClosedFileSystemException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,8 @@
 /**
  * Unchecked exception thrown when an attempt is made to invoke an operation on
  * a file and the file system is closed.
+ *
+ * @since 1.7
  */
 
 public class ClosedFileSystemException
--- a/jdk/src/java.base/share/classes/java/nio/file/ClosedWatchServiceException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/file/ClosedWatchServiceException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,8 @@
 /**
  * Unchecked exception thrown when an attempt is made to invoke an operation on
  * a watch service that is closed.
+ *
+ * @since 1.7
  */
 
 public class ClosedWatchServiceException
--- a/jdk/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,8 @@
 /**
  * Runtime exception thrown when an attempt is made to create a file system that
  * already exists.
+ *
+ * @since 1.7
  */
 
 public class FileSystemAlreadyExistsException
--- a/jdk/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,8 @@
 
 /**
  * Runtime exception thrown when a file system cannot be found.
+ *
+ * @since 1.7
  */
 
 public class FileSystemNotFoundException
--- a/jdk/src/java.base/share/classes/java/nio/file/InvalidPathException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/file/InvalidPathException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,6 +29,8 @@
  * Unchecked exception thrown when path string cannot be converted into a
  * {@link Path} because the path string contains invalid characters, or
  * the path string is invalid for other file system specific reasons.
+ *
+ * @since 1.7
  */
 
 public class InvalidPathException
--- a/jdk/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,6 +29,8 @@
  * Unchecked exception thrown when an attempt is made to invoke a method on an
  * object created by one file system provider with a parameter created by a
  * different file system provider.
+ *
+ * @since 1.7
  */
 public class ProviderMismatchException
     extends java.lang.IllegalArgumentException
--- a/jdk/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,8 @@
 
 /**
  * Runtime exception thrown when a provider of the required type cannot be found.
+ *
+ * @since 1.7
  */
 
 public class ProviderNotFoundException
--- a/jdk/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,8 @@
 /**
  * Unchecked exception thrown when an attempt is made to update an object
  * associated with a {@link FileSystem#isReadOnly() read-only} {@code FileSystem}.
+ *
+ * @since 1.7
  */
 
 public class ReadOnlyFileSystemException
--- a/jdk/src/java.base/share/classes/java/security/SecureRandom.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/security/SecureRandom.java	Wed Jul 05 23:09:40 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
@@ -40,7 +40,7 @@
  *
  * <p>A cryptographically strong random number minimally complies with the
  * statistical random number generator tests specified in
- * <a href="http://csrc.nist.gov/publications/fips/fips140-2/fips1402.pdf">
+ * <a href="http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf">
  * <i>FIPS 140-2, Security Requirements for Cryptographic Modules</i></a>,
  * section 4.9.1.
  * Additionally, {@code SecureRandom} must produce non-deterministic output.
@@ -651,8 +651,6 @@
      * {@code SecureRandom}.
      *
      * @return the string representation
-     *
-     * @since 9
      */
     @Override
     public String toString() {
--- a/jdk/src/java.base/share/classes/java/security/SecureRandomSpi.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/security/SecureRandomSpi.java	Wed Jul 05 23:09:40 2017 +0200
@@ -211,8 +211,6 @@
      * {@code SecureRandom}.
      *
      * @return the string representation
-     *
-     * @since 9
      */
     @Override
     public String toString() {
--- a/jdk/src/java.base/share/classes/java/security/cert/X509CRL.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/security/cert/X509CRL.java	Wed Jul 05 23:09:40 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	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/security/cert/X509Certificate.java	Wed Jul 05 23:09:40 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/time/Duration.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/time/Duration.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1370,6 +1370,7 @@
      * @return a {@code Duration} based on this duration with the time truncated, not null
      * @throws DateTimeException if the unit is invalid for truncation
      * @throws UnsupportedTemporalTypeException if the unit is not supported
+     * @since 9
      */
     public Duration truncatedTo(TemporalUnit unit) {
         Objects.requireNonNull(unit, "unit");
--- a/jdk/src/java.base/share/classes/java/time/chrono/Era.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/time/chrono/Era.java	Wed Jul 05 23:09:40 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
@@ -310,8 +310,8 @@
      * The parameters control the style of the returned text and the locale.
      * <p>
      * If no textual mapping is found then the {@link #getValue() numeric value} is returned.
-     * <p>
-     * This default implementation is suitable for all implementations.
+     *
+     * @apiNote This default implementation is suitable for most implementations.
      *
      * @param style  the style of the text required, not null
      * @param locale  the locale to use, not null
--- a/jdk/src/java.base/share/classes/java/time/chrono/JapaneseEra.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/time/chrono/JapaneseEra.java	Wed Jul 05 23:09:40 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
@@ -240,19 +240,10 @@
     }
 
     /**
-     * Gets the textual representation of this era.
-     * <p>
-     * This returns the textual name used to identify the era,
-     * suitable for presentation to the user.
-     * The parameters control the style of the returned text and the locale.
-     * <p>
-     * If no textual mapping is found then the {@link #getValue() numeric value}
-     * is returned.
+     * {@inheritDoc}
      *
-     * @param style  the style of the text required, not null
-     * @param locale  the locale to use, not null
-     * @return the text value of the era, not null
-     * @since 9
+     * @param style {@inheritDoc}
+     * @param locale {@inheritDoc}
      */
     @Override
     public String getDisplayName(TextStyle style, Locale locale) {
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1278,6 +1278,7 @@
      *
      * @param textStyle  the text style to use, not null
      * @return this, for chaining, not null
+     * @since 9
      */
     public DateTimeFormatterBuilder appendGenericZoneText(TextStyle textStyle) {
         appendInternal(new ZoneTextPrinterParser(textStyle, null, true));
@@ -1303,6 +1304,7 @@
      * @param textStyle  the text style to use, not null
      * @param preferredZones  the set of preferred zone ids, not null
      * @return this, for chaining, not null
+     * @since 9
      */
     public DateTimeFormatterBuilder appendGenericZoneText(TextStyle textStyle,
                                                           Set<ZoneId> preferredZones) {
--- a/jdk/src/java.base/share/classes/java/util/Date.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Date.java	Wed Jul 05 23:09:40 2017 +0200
@@ -728,7 +728,6 @@
      * @see     java.util.Calendar
      * @deprecated As of JDK version 1.1,
      * replaced by {@code Calendar.get(Calendar.DAY_OF_MONTH)}.
-     * @deprecated
      */
     @Deprecated
     public int getDate() {
--- a/jdk/src/java.base/share/classes/java/util/Iterator.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Iterator.java	Wed Jul 05 23:09:40 2017 +0200
@@ -109,7 +109,8 @@
      * Exceptions thrown by the action are relayed to the caller.
      * <p>
      * The behavior of an iterator is unspecified if the action modifies the
-     * collection in any way (even by calling the {@link #remove remove} method),
+     * collection in any way (even by calling the {@link #remove remove} method
+     * or other mutator methods of {@code Iterator} subtypes),
      * unless an overriding class has specified a concurrent modification policy.
      * <p>
      * Subsequent behavior of an iterator is unspecified if the action throws an
--- a/jdk/src/java.base/share/classes/java/util/Observable.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/Observable.java	Wed Jul 05 23:09:40 2017 +0200
@@ -69,6 +69,8 @@
  * {@link java.beans} package.  For reliable and ordered
  * messaging among threads, consider using one of the concurrent data
  * structures in the {@link java.util.concurrent} package.
+ * For reactive streams style programming, see the
+ * {@link java.util.concurrent.Flow} API.
  */
 @Deprecated(since="9")
 public class Observable {
--- a/jdk/src/java.base/share/classes/java/util/ServiceLoader.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/ServiceLoader.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1007,6 +1007,7 @@
     {
         static final String PREFIX = "META-INF/services/";
 
+        Set<String> providerNames = new HashSet<>();  // to avoid duplicates
         Enumeration<URL> configs;
         Iterator<String> pending;
         Class<?> nextClass;
@@ -1016,7 +1017,7 @@
 
         /**
          * Parse a single line from the given configuration file, adding the
-         * name on the line to the names list.
+         * name on the line to set of names if not already seen.
          */
         private int parseLine(URL u, BufferedReader r, int lc, Set<String> names)
             throws IOException
@@ -1041,7 +1042,9 @@
                     if (!Character.isJavaIdentifierPart(cp) && (cp != '.'))
                         fail(service, u, lc, "Illegal provider-class name: " + ln);
                 }
-                names.add(ln);
+                if (providerNames.add(ln)) {
+                    names.add(ln);
+                }
             }
             return lc + 1;
         }
@@ -1072,7 +1075,7 @@
                 return true;
             }
 
-            Class<?> clazz = null;
+            Class<?> clazz;
             do {
                 if (configs == null) {
                     try {
--- a/jdk/src/java.base/share/classes/java/util/jar/Pack200.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/jar/Pack200.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, 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
@@ -452,13 +452,13 @@
         String CODE_ATTRIBUTE_PFX       = "pack.code.attribute.";
 
         /**
-         * The unpacker's progress as a percentage, as periodically
-         * updated by the unpacker.
+         * The packer's progress as a percentage, as periodically
+         * updated by the packer.
          * Values of 0 - 100 are normal, and -1 indicates a stall.
          * Progress can be monitored by polling the value of this
          * property.
          * <p>
-         * At a minimum, the unpacker must set progress to 0
+         * At a minimum, the packer must set progress to 0
          * at the beginning of a packing operation, and to 100
          * at the end.
          */
@@ -623,7 +623,7 @@
          * property.
          * <p>
          * At a minimum, the unpacker must set progress to 0
-         * at the beginning of a packing operation, and to 100
+         * at the beginning of an unpacking operation, and to 100
          * at the end.
          */
         String PROGRESS         = "unpack.progress";
@@ -631,7 +631,7 @@
         /**
          * Get the set of this engine's properties. This set is
          * a "live view", so that changing its
-         * contents immediately affects the Packer engine, and
+         * contents immediately affects the Unpacker engine, and
          * changes from the engine (such as progress indications)
          * are immediately visible in the map.
          *
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -32,7 +32,7 @@
  *
  * @author  unascribed
  * @see     java.io.IOException
- * @since   1.0
+ * @since   1.1
  */
 
 public
--- a/jdk/src/java.base/share/classes/jdk/internal/jmod/JmodFile.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/jmod/JmodFile.java	Wed Jul 05 23:09:40 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
@@ -59,7 +59,7 @@
             bis.read(magic);
             if (magic[0] != JMOD_MAGIC_NUMBER[0] ||
                 magic[1] != JMOD_MAGIC_NUMBER[1]) {
-                throw new IOException("Invalid jmod file: " + file.toString());
+                throw new IOException("Invalid JMOD file: " + file.toString());
             }
             if (magic[2] > JMOD_MAJOR_VERSION ||
                 (magic[2] == JMOD_MAJOR_VERSION && magic[3] > JMOD_MINOR_VERSION)) {
@@ -131,6 +131,13 @@
         }
 
         /**
+         * Returns true if the entry is a directory in the JMOD file.
+         */
+        public boolean isDirectory() {
+            return zipEntry.isDirectory();
+        }
+
+        /**
          * Returns the size of this entry.
          */
         public long size() {
@@ -186,12 +193,12 @@
     public Entry getEntry(Section section, String name) {
         String entry = section.jmodDir() + "/" + name;
         ZipEntry ze = zipfile.getEntry(entry);
-        return (ze == null || ze.isDirectory()) ? null : new Entry(ze);
+        return (ze != null) ? new Entry(ze) : null;
     }
 
     /**
      * Opens an {@code InputStream} for reading the named entry of the given
-     * section in this jmod file.
+     * section in this JMOD file.
      *
      * @throws IOException if the named entry is not found, or I/O error
      *         occurs when reading it
@@ -201,7 +208,7 @@
     {
         String entry = section.jmodDir() + "/" + name;
         ZipEntry e = zipfile.getEntry(entry);
-        if (e == null || e.isDirectory()) {
+        if (e == null) {
             throw new IOException(name + " not found: " + file);
         }
         return zipfile.getInputStream(e);
@@ -217,11 +224,10 @@
     }
 
     /**
-     * Returns a stream of non-directory entries in this jmod file.
+     * Returns a stream of entries in this JMOD file.
      */
     public Stream<Entry> stream() {
         return zipfile.stream()
-                      .filter(e -> !e.isDirectory())
                       .map(Entry::new);
     }
 
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java	Wed Jul 05 23:09:40 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
@@ -65,14 +65,12 @@
     }
 
     /**
-     * Need FilePermission ${java.home}/-", "read" to create or get jrt:/
+     * Need RuntimePermission "accessSystemModules" to create or get jrt:/
      */
     private void checkPermission() {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            String home = SystemImage.RUNTIME_HOME;
-            FilePermission perm
-                    = new FilePermission(home + File.separator + "-", "read");
+            RuntimePermission perm = new RuntimePermission("accessSystemModules");
             sm.checkPermission(perm);
         }
     }
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java	Wed Jul 05 23:09:40 2017 +0200
@@ -96,6 +96,14 @@
     }
 
     /**
+     * Returns {@code true} if there is a class path associated with the
+     * BootLoader.
+     */
+    public static boolean hasClassPath() {
+        return ClassLoaders.bootLoader().hasClassPath();
+    }
+
+    /**
      * Register a module with this class loader so that its classes (and
      * resources) become visible via this class loader.
      */
@@ -188,14 +196,6 @@
     }
 
     /**
-     * Returns {@code true} if there is a class path associated with the
-     * BootLoader.
-     */
-    public static boolean hasClassPath() {
-        return ClassLoaders.bootLoader().hasClassPath();
-    }
-
-    /**
      * Helper class to define {@code Package} objects for packages in modules
      * defined to the boot loader.
      */
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java	Wed Jul 05 23:09:40 2017 +0200
@@ -60,6 +60,7 @@
 import jdk.internal.misc.VM;
 import jdk.internal.module.ModulePatcher.PatchedModuleReader;
 import jdk.internal.module.SystemModules;
+import jdk.internal.module.Resources;
 
 
 /**
@@ -163,6 +164,14 @@
     }
 
     /**
+     * Returns {@code true} if there is a class path associated with this
+     * class loader.
+     */
+    boolean hasClassPath() {
+        return ucp != null;
+    }
+
+    /**
      * Register a module this this class loader. This has the effect of making
      * the types in the module visible.
      */
@@ -248,18 +257,24 @@
      */
     @Override
     public URL findResource(String name) {
-        String pn = ResourceHelper.getPackageName(name);
+        String pn = Resources.toPackageName(name);
         LoadedModule module = packageToModule.get(pn);
         if (module != null) {
 
             // resource is in a package of a module defined to this loader
-            if (module.loader() == this
-                && (name.endsWith(".class") || isOpen(module.mref(), pn))) {
+            if (module.loader() == this) {
+                URL url;
                 try {
-                    return findResource(module.name(), name); // checks URL
+                    url = findResource(module.name(), name); // checks URL
                 } catch (IOException ioe) {
                     return null;
                 }
+                if (url != null
+                    && (name.endsWith(".class")
+                        || url.toString().endsWith("/")
+                        || isOpen(module.mref(), pn))) {
+                    return url;
+                }
             }
 
         } else {
@@ -293,15 +308,17 @@
     public Enumeration<URL> findResources(String name) throws IOException {
         List<URL> checked = new ArrayList<>();  // list of checked URLs
 
-        String pn = ResourceHelper.getPackageName(name);
+        String pn = Resources.toPackageName(name);
         LoadedModule module = packageToModule.get(pn);
         if (module != null) {
 
             // resource is in a package of a module defined to this loader
-            if (module.loader() == this
-                && (name.endsWith(".class") || isOpen(module.mref(), pn))) {
-                URL url = findResource(module.name(), name);  // checks URL
-                if (url != null) {
+            if (module.loader() == this) {
+                URL url = findResource(module.name(), name); // checks URL
+                if (url != null
+                    && (name.endsWith(".class")
+                        || url.toString().endsWith("/")
+                        || isOpen(module.mref(), pn))) {
                     checked.add(url);
                 }
             }
@@ -351,11 +368,13 @@
                 new PrivilegedExceptionAction<>() {
                     @Override
                     public List<URL> run() throws IOException {
-                        List<URL> result = new ArrayList<>();
+                        List<URL> result = null;
                         for (ModuleReference mref : nameToModule.values()) {
                             URI u = moduleReaderFor(mref).find(name).orElse(null);
                             if (u != null) {
                                 try {
+                                    if (result == null)
+                                        result = new ArrayList<>();
                                     result.add(u.toURL());
                                 } catch (MalformedURLException |
                                          IllegalArgumentException e) {
@@ -375,7 +394,7 @@
                 map = new ConcurrentHashMap<>();
                 this.resourceCache = new SoftReference<>(map);
             }
-            if (urls.isEmpty())
+            if (urls == null)
                 urls = Collections.emptyList();
             map.putIfAbsent(name, urls);
         }
@@ -870,14 +889,6 @@
     }
 
     /**
-     * Returns {@code true} if there is a class path associated with this
-     * class loader.
-     */
-    boolean hasClassPath() {
-        return ucp != null;
-    }
-
-    /**
      * Returns {@code true} if the specified package name is sealed according to
      * the given manifest.
      */
@@ -975,7 +986,7 @@
      */
     private boolean isOpen(ModuleReference mref, String pn) {
         ModuleDescriptor descriptor = mref.descriptor();
-        if (descriptor.isOpen())
+        if (descriptor.isOpen() || descriptor.isAutomatic())
             return true;
         for (ModuleDescriptor.Opens opens : descriptor.opens()) {
             String source = opens.source();
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java	Wed Jul 05 23:09:40 2017 +0200
@@ -60,6 +60,7 @@
 import java.util.stream.Stream;
 
 import jdk.internal.misc.SharedSecrets;
+import jdk.internal.module.Resources;
 
 
 /**
@@ -356,45 +357,52 @@
 
     @Override
     public URL findResource(String name) {
-        URL url = null;
-        String pn = ResourceHelper.getPackageName(name);
+        String pn = Resources.toPackageName(name);
         LoadedModule module = localPackageToModule.get(pn);
+
         if (module != null) {
-            if (name.endsWith(".class") || isOpen(module.mref(), pn)) {
-                try {
-                    url = findResource(module.name(), name);
-                } catch (IOException ioe) {
-                    // ignore
+            try {
+                URL url = findResource(module.name(), name);
+                if (url != null
+                    && (name.endsWith(".class")
+                        || url.toString().endsWith("/")
+                        || isOpen(module.mref(), pn))) {
+                    return url;
                 }
+            } catch (IOException ioe) {
+                // ignore
             }
+
         } else {
             for (ModuleReference mref : nameToModule.values()) {
                 try {
-                    url = findResource(mref.descriptor().name(), name);
-                    if (url != null)
-                        break;
+                    URL url = findResource(mref.descriptor().name(), name);
+                    if (url != null) return url;
                 } catch (IOException ioe) {
                     // ignore
                 }
             }
         }
-        return url;
+
+        return null;
     }
 
     @Override
     public Enumeration<URL> findResources(String name) throws IOException {
         List<URL> urls = new ArrayList<>();
-        String pn = ResourceHelper.getPackageName(name);
+        String pn = Resources.toPackageName(name);
         LoadedModule module = localPackageToModule.get(pn);
         if (module != null) {
-            if (name.endsWith(".class") || isOpen(module.mref(), pn)) {
-                try {
-                    URL url = findResource(module.name(), name);
-                    if (url != null)
-                        urls.add(url);
-                } catch (IOException ioe) {
-                    // ignore
+            try {
+                URL url = findResource(module.name(), name);
+                if (url != null
+                    && (name.endsWith(".class")
+                        || url.toString().endsWith("/")
+                        || isOpen(module.mref(), pn))) {
+                    urls.add(url);
                 }
+            } catch (IOException ioe) {
+                // ignore
             }
         } else {
             for (ModuleReference mref : nameToModule.values()) {
@@ -643,7 +651,7 @@
      */
     private boolean isOpen(ModuleReference mref, String pn) {
         ModuleDescriptor descriptor = mref.descriptor();
-        if (descriptor.isOpen())
+        if (descriptor.isOpen() || descriptor.isAutomatic())
             return true;
         for (ModuleDescriptor.Opens opens : descriptor.opens()) {
             String source = opens.source();
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ResourceHelper.java	Sat Apr 08 03:25:14 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
- * 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.  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.internal.loader;
-
-import java.io.File;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import jdk.internal.module.Checks;
-
-/**
- * Helper class for Class#getResource, Module#getResourceAsStream, and other
- * methods that locate a resource in a module.
- */
-public final class ResourceHelper {
-    private ResourceHelper() { }
-
-    /**
-     * Returns the <em>package name</em> for a resource or the empty package if
-     * the resource name does not contain a slash.
-     */
-    public static String getPackageName(String name) {
-        int index = name.lastIndexOf('/');
-        if (index != -1) {
-            return name.substring(0, index).replace("/", ".");
-        } else {
-            return "";
-        }
-    }
-
-    /**
-     * Returns true if the resource is a <em>simple resource</em>. Simple
-     * resources can never be encapsulated. Resources ending in "{@code .class}"
-     * or where the package name is not a legal package name can not be
-     * encapsulated.
-     */
-    public static boolean isSimpleResource(String name) {
-        int len = name.length();
-        if (len > 6 && name.endsWith(".class")) {
-            return true;
-        }
-        if (!Checks.isPackageName(getPackageName(name))) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * Converts a resource name to a file path. Returns {@code null} if the
-     * resource name cannot be converted into a file path. Resource names
-     * with empty elements, or elements that are "." or ".." are rejected,
-     * as is a resource name that translates to a file path with a root
-     * component.
-     */
-    public static Path toFilePath(String name) {
-        // scan the resource name to eagerly reject obviously invalid names
-        int next;
-        int off = 0;
-        while ((next = name.indexOf('/', off)) != -1) {
-            int len = next - off;
-            if (!mayTranslate(name, off, len)) {
-                return null;
-            }
-            off = next + 1;
-        }
-        int rem = name.length() - off;
-        if (!mayTranslate(name, off, rem)) {
-            return null;
-        }
-
-        // convert to file path
-        Path path;
-        if (File.separatorChar == '/') {
-            path = Paths.get(name);
-        } else {
-            // not allowed to embed file separators
-            if (name.contains(File.separator))
-                return null;
-            path = Paths.get(name.replace('/', File.separatorChar));
-        }
-
-        // file path not allowed to have root component
-        return (path.getRoot() == null) ? path : null;
-    }
-
-    /**
-     * Returns {@code true} if the element in a resource name is a candidate
-     * to translate to the element of a file path.
-     */
-    private static boolean mayTranslate(String name, int off, int len) {
-        if (len <= 2) {
-            if (len == 0)
-                return false;
-            boolean starsWithDot = (name.charAt(off) == '.');
-            if (len == 1 && starsWithDot)
-                return false;
-            if (len == 2 && starsWithDot && (name.charAt(off+1) == '.'))
-                return false;
-        }
-        return true;
-    }
-
-}
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,6 +30,7 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.function.Function;
+import java.util.Objects;
 import java.lang.System.LoggerFinder;
 import java.lang.System.Logger;
 import java.lang.ref.ReferenceQueue;
@@ -155,6 +156,8 @@
 
     @Override
     public final Logger getLogger(String name,  Module module) {
+        Objects.requireNonNull(name, "name");
+        Objects.requireNonNull(module, "module");
         checkPermission();
         return demandLoggerFor(name, module);
     }
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Wed Jul 05 23:09:40 2017 +0200
@@ -33,6 +33,7 @@
 import java.lang.reflect.Module;
 import java.net.URL;
 import java.security.AccessControlContext;
+import java.security.ProtectionDomain;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Stream;
@@ -150,6 +151,11 @@
     ConcurrentHashMap<?, ?> createOrGetClassLoaderValueMap(ClassLoader cl);
 
     /**
+     * Defines a class with the given name to a class loader.
+     */
+    Class<?> defineClass(ClassLoader cl, String name, byte[] b, ProtectionDomain pd, String source);
+
+    /**
      * Returns a class loaded by the bootstrap class loader.
      */
     Class<?> findBootstrapClassOrNull(ClassLoader cl, String name);
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangModuleAccess.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangModuleAccess.java	Wed Jul 05 23:09:40 2017 +0200
@@ -73,7 +73,7 @@
     void requires(ModuleDescriptor.Builder builder,
                   Set<Requires.Modifier> ms,
                   String mn,
-                  String compiledVersion);
+                  String rawCompiledVersion);
 
     /**
      * Returns a {@code ModuleDescriptor.Requires} of the given modifiers
@@ -127,9 +127,6 @@
                                          Set<Provides> provides,
                                          Set<String> packages,
                                          String mainClass,
-                                         String osName,
-                                         String osArch,
-                                         String osVersion,
                                          int hashCode);
 
     /**
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java	Wed Jul 05 23:09:40 2017 +0200
@@ -66,33 +66,33 @@
     void addReadsAllUnnamed(Module m);
 
     /**
+     * Update module m to export a package to all modules.
+     */
+    void addExports(Module m, String pn);
+
+    /**
      * Updates module m1 to export a package to module m2. The export does
      * not result in a strong reference to m2 (m2 can be GC'ed).
      */
     void addExports(Module m1, String pkg, Module m2);
 
     /**
+     * Updates a module m to export a package to all unnamed modules.
+     */
+    void addExportsToAllUnnamed(Module m, String pkg);
+
+    /**
+     * Updates a module m to open a package to all modules.
+     */
+    void addOpens(Module m, String pkg);
+
+    /**
      * Updates module m1 to open a package to module m2. Opening the
      * package does not result in a strong reference to m2 (m2 can be GC'ed).
      */
     void addOpens(Module m1, String pkg, Module m2);
 
     /**
-     * Updates a module m to export a package to all modules.
-     */
-    void addExportsToAll(Module m, String pkg);
-
-    /**
-     * Updates a module m to open a package to all modules.
-     */
-    void addOpensToAll(Module m, String pkg);
-
-    /**
-     * Updates a module m to export a package to all unnamed modules.
-     */
-    void addExportsToAllUnnamed(Module m, String pkg);
-
-    /**
      * Updates a module m to open a package to all unnamed modules.
      */
     void addOpensToAllUnnamed(Module m, String pkg);
@@ -103,11 +103,6 @@
     void addUses(Module m, Class<?> service);
 
     /**
-     * Add a package to the given module.
-     */
-    void addPackage(Module m, String pkg);
-
-    /**
      * Returns the ServicesCatalog for the given Layer.
      */
     ServicesCatalog getServicesCatalog(Layer layer);
@@ -123,12 +118,4 @@
      * given class loader.
      */
     Stream<Layer> layers(ClassLoader loader);
-
-    /**
-     * Tests if a module exports a package at least {@code other} via its
-     * module declaration.
-     *
-     * @apiNote This is a temporary method for debugging features.
-     */
-    boolean isStaticallyExported(Module module, String pn, Module other);
 }
\ No newline at end of file
--- a/jdk/src/java.base/share/classes/jdk/internal/module/Builder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/Builder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -145,9 +145,6 @@
     Set<Provides> provides;
     Version version;
     String mainClass;
-    String osName;
-    String osArch;
-    String osVersion;
 
     Builder(String name) {
         this.name = name;
@@ -248,30 +245,6 @@
     }
 
     /**
-     * Sets the OS name.
-     */
-    public Builder osName(String name) {
-        this.osName = name;
-        return this;
-    }
-
-    /**
-     * Sets the OS arch.
-     */
-    public Builder osArch(String arch) {
-        this.osArch = arch;
-        return this;
-    }
-
-    /**
-     * Sets the OS version.
-     */
-    public Builder osVersion(String version) {
-        this.osVersion = version;
-        return this;
-    }
-
-    /**
      * Returns an immutable set of the module modifiers derived from the flags.
      */
     private Set<ModuleDescriptor.Modifier> modifiers() {
@@ -305,9 +278,6 @@
                                         provides,
                                         packages,
                                         mainClass,
-                                        osName,
-                                        osArch,
-                                        osVersion,
                                         hashCode);
     }
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/Checks.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/Checks.java	Wed Jul 05 23:09:40 2017 +0200
@@ -180,41 +180,38 @@
     }
 
     /**
-     * Returns {@code true} if the last character of the given name is legal
-     * as the last character of a module name.
-     *
-     * @throws IllegalArgumentException if name is empty
+     * Returns {@code true} if a given legal module name contains an identifier
+     * that doesn't end with a Java letter.
      */
-    public static boolean hasLegalModuleNameLastCharacter(String name) {
-        if (name.isEmpty())
-            throw new IllegalArgumentException("name is empty");
-        int len = name.length();
-        if (isASCIIString(name)) {
-            char c = name.charAt(len-1);
-            return Character.isJavaIdentifierStart(c);
-        } else {
-            int i = 0;
-            int cp = -1;
-            while (i < len) {
-                cp = name.codePointAt(i);
-                i += Character.charCount(cp);
+    public static boolean hasJavaIdentifierWithTrailingDigit(String name) {
+        // quick scan to allow names that are just ASCII without digits
+        boolean needToParse = false;
+        int i = 0;
+        while (i < name.length()) {
+            int c = name.charAt(i);
+            if (c > 0x7F || (c >= '0' && c <= '9')) {
+                needToParse = true;
+                break;
             }
-            return Character.isJavaIdentifierStart(cp);
-        }
-    }
-
-    /**
-     * Returns true if the given string only contains ASCII characters.
-     */
-    private static boolean isASCIIString(String s) {
-        int i = 0;
-        while (i < s.length()) {
-            int c = s.charAt(i);
-            if (c > 0x7F)
-                return false;
             i++;
         }
-        return true;
+        if (!needToParse)
+            return false;
+
+        // slow path
+        int next;
+        int off = 0;
+        while ((next = name.indexOf('.', off)) != -1) {
+            int last = isJavaIdentifier(name, off, (next - off));
+            if (!Character.isJavaIdentifierStart(last))
+                return true;
+            off = next+1;
+        }
+        int last = isJavaIdentifier(name, off, name.length() - off);
+        if (!Character.isJavaIdentifierStart(last))
+            return true;
+        return false;
+
     }
 
     /**
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileAttributes.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileAttributes.java	Wed Jul 05 23:09:40 2017 +0200
@@ -292,11 +292,11 @@
             attr.putShort(module_flags);
 
             // module_version
-            Version v = descriptor.version().orElse(null);
-            if (v == null) {
+            String vs = descriptor.rawVersion().orElse(null);
+            if (vs == null) {
                 attr.putShort(0);
             } else {
-                int module_version_index = cw.newUTF8(v.toString());
+                int module_version_index = cw.newUTF8(vs);
                 attr.putShort(module_version_index);
             }
 
@@ -320,11 +320,11 @@
                 attr.putShort(requires_flags);
 
                 int requires_version_index;
-                v = r.compiledVersion().orElse(null);
-                if (v == null) {
+                vs = r.rawCompiledVersion().orElse(null);
+                if (vs == null) {
                     requires_version_index = 0;
                 } else {
-                    requires_version_index = cw.newUTF8(v.toString());
+                    requires_version_index = cw.newUTF8(vs);
                 }
                 attr.putShort(requires_version_index);
             }
@@ -553,8 +553,6 @@
      *   u2 os_name_index;
      *   // index to CONSTANT_utf8_info structure with the OS arch
      *   u2 os_arch_index
-     *   // index to CONSTANT_utf8_info structure with the OS version
-     *   u2 os_version_index;
      * }
      *
      * } </pre>
@@ -562,17 +560,23 @@
     public static class ModuleTargetAttribute extends Attribute {
         private final String osName;
         private final String osArch;
-        private final String osVersion;
 
-        public ModuleTargetAttribute(String osName, String osArch, String osVersion) {
+        public ModuleTargetAttribute(String osName, String osArch) {
             super(MODULE_TARGET);
             this.osName = osName;
             this.osArch = osArch;
-            this.osVersion = osVersion;
         }
 
         public ModuleTargetAttribute() {
-            this(null, null, null);
+            this(null, null);
+        }
+
+        public String osName() {
+            return osName;
+        }
+
+        public String osArch() {
+            return osArch;
         }
 
         @Override
@@ -586,7 +590,6 @@
 
             String osName = null;
             String osArch = null;
-            String osVersion = null;
 
             int name_index = cr.readUnsignedShort(off);
             if (name_index != 0)
@@ -598,12 +601,7 @@
                 osArch = cr.readUTF8(off, buf);
             off += 2;
 
-            int version_index = cr.readUnsignedShort(off);
-            if (version_index != 0)
-                osVersion = cr.readUTF8(off, buf);
-            off += 2;
-
-            return new ModuleTargetAttribute(osName, osArch, osVersion);
+            return new ModuleTargetAttribute(osName, osArch);
         }
 
         @Override
@@ -625,11 +623,6 @@
                 arch_index = cw.newUTF8(osArch);
             attr.putShort(arch_index);
 
-            int version_index = 0;
-            if (osVersion != null && osVersion.length() > 0)
-                version_index = cw.newUTF8(osVersion);
-            attr.putShort(version_index);
-
             return attr;
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,345 @@
+/*
+ * 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 jdk.internal.module;
+
+import java.io.PrintStream;
+import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Module;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+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.WeakHashMap;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+import jdk.internal.loader.BootLoader;
+import sun.security.action.GetPropertyAction;
+
+/**
+ * Supports logging of access to members of API packages that are exported or
+ * opened via backdoor mechanisms to code in unnamed modules.
+ */
+
+public final class IllegalAccessLogger {
+
+    /**
+     * Holder class to lazily create the StackWalker object and determine
+     * if the stack trace should be printed
+     */
+    static class Holder {
+        static final StackWalker STACK_WALKER;
+        static final boolean PRINT_STACK_TRACE;
+
+        static {
+            PrivilegedAction<StackWalker> pa = () ->
+                StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
+            STACK_WALKER = AccessController.doPrivileged(pa);
+
+            String name = "sun.reflect.debugModuleAccessChecks";
+            String value = GetPropertyAction.privilegedGetProperty(name, null);
+            PRINT_STACK_TRACE = "access" .equals(value);
+        }
+    }
+
+    // the maximum number of frames to capture
+    private static final int MAX_STACK_FRAMES = 32;
+
+    // lock to avoid interference when printing stack traces
+    private static final Object OUTPUT_LOCK = new Object();
+
+    // caller -> usages
+    private final Map<Class<?>, Set<Usage>> callerToUsages = new WeakHashMap<>();
+
+    // module -> (package name -> CLI option)
+    private final Map<Module, Map<String, String>> exported;
+    private final Map<Module, Map<String, String>> opened;
+
+    // the print stream to send the warnings
+    private final PrintStream warningStream;
+
+    private IllegalAccessLogger(Map<Module, Map<String, String>> exported,
+                                Map<Module, Map<String, String>> opened,
+                                PrintStream warningStream) {
+        this.exported = deepCopy(exported);
+        this.opened = deepCopy(opened);
+        this.warningStream = warningStream;
+    }
+
+    /**
+     * Returns that a Builder that is seeded with the packages known to this logger.
+     */
+    public Builder toBuilder() {
+        return new Builder(exported, opened);
+    }
+
+    /**
+     * Logs access to the member of a target class by a caller class if the class
+     * is in a package that is exported via a backdoor mechanism.
+     *
+     * The {@code whatSupplier} supplies the message that describes the member.
+     */
+    public void logIfExportedByBackdoor(Class<?> caller,
+                                        Class<?> target,
+                                        Supplier<String> whatSupplier) {
+        Map<String, String> packages = exported.get(target.getModule());
+        if (packages != null) {
+            String how = packages.get(target.getPackageName());
+            if (how != null) {
+                log(caller, whatSupplier.get(), how);
+            }
+        }
+    }
+
+    /**
+     * Logs access to the member of a target class by a caller class if the class
+     * is in a package that is opened via a backdoor mechanism.
+     *
+     * The {@code what} parameter supplies the message that describes the member.
+     */
+    public void logIfOpenedByBackdoor(Class<?> caller,
+                                      Class<?> target,
+                                      Supplier<String> whatSupplier) {
+        Map<String, String> packages = opened.get(target.getModule());
+        if (packages != null) {
+            String how = packages.get(target.getPackageName());
+            if (how != null) {
+                log(caller, whatSupplier.get(), how);
+            }
+        }
+    }
+
+    /**
+     * Logs access by a caller class. The {@code what} parameter describes
+     * the member is accessed, the {@code how} parameter is the means by which
+     * access is allocated (CLI option for example).
+     */
+    private void log(Class<?> caller, String what, String how) {
+        log(caller, what, () -> {
+            PrivilegedAction<ProtectionDomain> pa = caller::getProtectionDomain;
+            CodeSource cs = AccessController.doPrivileged(pa).getCodeSource();
+            URL url = (cs != null) ? cs.getLocation() : null;
+            String source = caller.getName();
+            if (url != null)
+                source += " (" + url + ")";
+            return "WARNING: Illegal access by " + source + " to " + what
+                    + " (permitted by " + how + ")";
+        });
+    }
+
+
+    /**
+     * Logs access to caller class if the class is in a package that is opened via
+     * a backdoor mechanism.
+     */
+    public void logIfOpenedByBackdoor(MethodHandles.Lookup caller, Class<?> target) {
+        Map<String, String> packages = opened.get(target.getModule());
+        if (packages != null) {
+            String how = packages.get(target.getPackageName());
+            if (how != null) {
+                log(caller.lookupClass(), target.getName(), () ->
+                    "WARNING: Illegal access using Lookup on " + caller.lookupClass()
+                    + " to " + target + " (permitted by " + how + ")");
+            }
+        }
+    }
+
+    /**
+     * Log access by a caller. The {@code what} parameter describes the class or
+     * member that is being accessed. The {@code msgSupplier} supplies the log
+     * message.
+     *
+     * To reduce output, this method only logs the access if it hasn't been seen
+     * previously. "Seen previously" is implemented as a map of caller class -> Usage,
+     * where a Usage is the "what" and a hash of the stack trace. The map has weak
+     * keys so it can be expunged when the caller is GC'ed/unloaded.
+     */
+    private void log(Class<?> caller, String what, Supplier<String> msgSupplier) {
+        // stack trace without the top-most frames in java.base
+        List<StackWalker.StackFrame> stack = Holder.STACK_WALKER.walk(s ->
+            s.dropWhile(this::isJavaBase)
+             .limit(MAX_STACK_FRAMES)
+             .collect(Collectors.toList())
+        );
+
+        // check if the access has already been recorded
+        Usage u = new Usage(what, hash(stack));
+        boolean firstUsage;
+        synchronized (this) {
+            firstUsage = callerToUsages.computeIfAbsent(caller, k -> new HashSet<>()).add(u);
+        }
+
+        // log message if first usage
+        if (firstUsage) {
+            String msg = msgSupplier.get();
+            if (Holder.PRINT_STACK_TRACE) {
+                synchronized (OUTPUT_LOCK) {
+                    warningStream.println(msg);
+                    stack.forEach(f -> warningStream.println("\tat " + f));
+                }
+            } else {
+                warningStream.println(msg);
+            }
+        }
+    }
+
+    private static class Usage {
+        private final String what;
+        private final int stack;
+        Usage(String what, int stack) {
+            this.what = what;
+            this.stack = stack;
+        }
+        @Override
+        public int hashCode() {
+            return what.hashCode() ^ stack;
+        }
+        @Override
+        public boolean equals(Object ob) {
+            if (ob instanceof Usage) {
+                Usage that = (Usage)ob;
+                return what.equals(that.what) && stack == (that.stack);
+            } else {
+                return false;
+            }
+        }
+    }
+
+    /**
+     * Returns true if the stack frame is for a class in java.base.
+     */
+    private boolean isJavaBase(StackWalker.StackFrame frame) {
+        Module caller = frame.getDeclaringClass().getModule();
+        return "java.base".equals(caller.getName());
+    }
+
+    /**
+     * Computes a hash code for the give stack frames. The hash code is based
+     * on the class, method name, and BCI.
+     */
+    private int hash(List<StackWalker.StackFrame> stack) {
+        int hash = 0;
+        for (StackWalker.StackFrame frame : stack) {
+            hash = (31 * hash) + Objects.hash(frame.getDeclaringClass(),
+                                              frame.getMethodName(),
+                                              frame.getByteCodeIndex());
+        }
+        return hash;
+    }
+
+    // system-wide IllegalAccessLogger
+    private static volatile IllegalAccessLogger logger;
+
+    /**
+     * Sets the system-wide IllegalAccessLogger
+     */
+    public static void setIllegalAccessLogger(IllegalAccessLogger l) {
+        if (l.exported.isEmpty() && l.opened.isEmpty()) {
+            logger = null;
+        } else {
+            logger = l;
+        }
+    }
+
+    /**
+     * Returns the system-wide IllegalAccessLogger or {@code null} if there is
+     * no logger.
+     */
+    public static IllegalAccessLogger illegalAccessLogger() {
+        return logger;
+    }
+
+    /**
+     * A builder for IllegalAccessLogger objects.
+     */
+    public static class Builder {
+        private final Module UNNAMED = BootLoader.getUnnamedModule();
+        private Map<Module, Map<String, String>> exported;
+        private Map<Module, Map<String, String>> opened;
+        private PrintStream warningStream = System.err;
+
+        public Builder() { }
+
+        public Builder(Map<Module, Map<String, String>> exported,
+                       Map<Module, Map<String, String>> opened) {
+            this.exported = deepCopy(exported);
+            this.opened = deepCopy(opened);
+        }
+
+        public Builder logAccessToExportedPackage(Module m, String pn, String how) {
+            if (!m.isExported(pn, UNNAMED)) {
+                if (exported == null)
+                    exported = new HashMap<>();
+                exported.computeIfAbsent(m, k -> new HashMap<>()).putIfAbsent(pn, how);
+            }
+            return this;
+        }
+
+        public Builder logAccessToOpenPackage(Module m, String pn, String how) {
+            // opens implies exported at run-time.
+            logAccessToExportedPackage(m, pn, how);
+
+            if (!m.isOpen(pn, UNNAMED)) {
+                if (opened == null)
+                    opened = new HashMap<>();
+                opened.computeIfAbsent(m, k -> new HashMap<>()).putIfAbsent(pn, how);
+            }
+            return this;
+        }
+
+        public Builder warningStream(PrintStream warningStream) {
+            this.warningStream = Objects.requireNonNull(warningStream);
+            return this;
+        }
+
+        /**
+         * Builds the logger.
+         */
+        public IllegalAccessLogger build() {
+            return new IllegalAccessLogger(exported, opened, warningStream);
+        }
+    }
+
+
+    static Map<Module, Map<String, String>> deepCopy(Map<Module, Map<String, String>> map) {
+        if (map == null || map.isEmpty()) {
+            return new HashMap<>();
+        } else {
+            Map<Module, Map<String, String>> newMap = new HashMap<>();
+            for (Map.Entry<Module, Map<String, String>> e : map.entrySet()) {
+                newMap.put(e.getKey(), new HashMap<>(e.getValue()));
+            }
+            return newMap;
+        }
+    }
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Wed Jul 05 23:09:40 2017 +0200
@@ -33,6 +33,7 @@
 import java.lang.module.ModuleReference;
 import java.lang.module.ResolvedModule;
 import java.lang.reflect.Layer;
+import java.lang.reflect.LayerInstantiationException;
 import java.lang.reflect.Module;
 import java.net.URI;
 import java.nio.file.Path;
@@ -46,7 +47,6 @@
 import java.util.Optional;
 import java.util.Set;
 import java.util.function.Function;
-import java.util.stream.Stream;
 
 import jdk.internal.loader.BootLoader;
 import jdk.internal.loader.BuiltinClassLoader;
@@ -327,8 +327,9 @@
                 for (String p : descriptor.packages()) {
                     String other = packageToModule.putIfAbsent(p, name);
                     if (other != null) {
-                        fail("Package " + p + " in both module "
-                             + name + " and module " + other);
+                        String msg = "Package " + p + " in both module "
+                                     + name + " and module " + other;
+                        throw new LayerInstantiationException(msg);
                     }
                 }
             }
@@ -359,7 +360,7 @@
         PerfCounters.loadModulesTime.addElapsedTimeFrom(t5);
 
 
-        // --add-reads, -add-exports/-add-opens
+        // --add-reads, --add-exports/--add-opens
         addExtraReads(bootLayer);
         addExtraExportsAndOpens(bootLayer);
 
@@ -514,7 +515,6 @@
      * additional packages specified on the command-line.
      */
     private static void addExtraExportsAndOpens(Layer bootLayer) {
-
         // --add-exports
         String prefix = "jdk.module.addexports.";
         Map<String, List<String>> extraExports = decode(prefix);
@@ -529,6 +529,23 @@
             addExtraExportsOrOpens(bootLayer, extraOpens, true);
         }
 
+        // --permit-illegal-access
+        if (getAndRemoveProperty("jdk.module.permitIllegalAccess") != null) {
+            warn("--permit-illegal-access will be removed in the next major release");
+            IllegalAccessLogger.Builder builder = new IllegalAccessLogger.Builder();
+            Module unnamed = BootLoader.getUnnamedModule();
+            bootLayer.modules().stream().forEach(m -> {
+                m.getDescriptor()
+                 .packages()
+                 .stream()
+                 .filter(pn -> !m.isOpen(pn, unnamed))  // skip if opened by --add-opens
+                 .forEach(pn -> {
+                     builder.logAccessToOpenPackage(m, pn, "--permit-illegal-access");
+                     Modules.addOpensToAllUnnamed(m, pn);
+                 });
+            });
+            IllegalAccessLogger.setIllegalAccessLogger(builder.build());
+        }
     }
 
     private static void addExtraExportsOrOpens(Layer bootLayer,
@@ -542,12 +559,12 @@
             String key = e.getKey();
             String[] s = key.split("/");
             if (s.length != 2)
-                fail(unableToParse(option,  "<module>/<package>", key));
+                fail(unableToParse(option, "<module>/<package>", key));
 
             String mn = s[0];
             String pn = s[1];
             if (mn.isEmpty() || pn.isEmpty())
-                fail(unableToParse(option,  "<module>/<package>", key));
+                fail(unableToParse(option, "<module>/<package>", key));
 
             // The exporting module is in the boot layer
             Module m;
@@ -632,7 +649,7 @@
 
             // value is <module>(,<module>)* or <file>(<pathsep><file>)*
             if (!allowDuplicates && map.containsKey(key))
-                fail(key + " specified more than once in " + option(prefix));
+                fail(key + " specified more than once to " + option(prefix));
             List<String> values = map.computeIfAbsent(key, k -> new ArrayList<>());
             int ntargets = 0;
             for (String s : rhs.split(regex)) {
@@ -676,10 +693,6 @@
             ModuleReference mref = rm.reference();
             String mn = mref.descriptor().name();
 
-            // emit warning if module name ends with a non-Java letter
-            if (!Checks.hasLegalModuleNameLastCharacter(mn))
-                warn("Module name \"" + mn + "\" may soon be illegal");
-
             // emit warning if the WARN_INCUBATING module resolution bit set
             if (ModuleResolution.hasIncubatingWarning(mref)) {
                 if (incubating == null) {
@@ -705,7 +718,7 @@
     }
 
     static void warnUnknownModule(String option, String mn) {
-        warn("Unknown module: " + mn + " specified in " + option);
+        warn("Unknown module: " + mn + " specified to " + option);
     }
 
     static String unableToParse(String option, String text, String value) {
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java	Wed Jul 05 23:09:40 2017 +0200
@@ -89,18 +89,24 @@
      */
     public static final class Attributes {
         private final ModuleDescriptor descriptor;
+        private final ModuleTarget target;
         private final ModuleHashes recordedHashes;
         private final ModuleResolution moduleResolution;
         Attributes(ModuleDescriptor descriptor,
+                   ModuleTarget target,
                    ModuleHashes recordedHashes,
                    ModuleResolution moduleResolution) {
             this.descriptor = descriptor;
+            this.target = target;
             this.recordedHashes = recordedHashes;
             this.moduleResolution = moduleResolution;
         }
         public ModuleDescriptor descriptor() {
             return descriptor;
         }
+        public ModuleTarget target() {
+            return target;
+        }
         public ModuleHashes recordedHashes() {
             return recordedHashes;
         }
@@ -221,8 +227,8 @@
         Builder builder = null;
         Set<String> allPackages = null;
         String mainClass = null;
-        String[] osValues = null;
-        ModuleHashes hashes = null;
+        ModuleTarget moduleTarget = null;
+        ModuleHashes moduelHashes = null;
         ModuleResolution moduleResolution = null;
 
         for (int i = 0; i < attributes_count ; i++) {
@@ -251,12 +257,12 @@
                     break;
 
                 case MODULE_TARGET :
-                    osValues = readModuleTargetAttribute(in, cpool);
+                    moduleTarget = readModuleTargetAttribute(in, cpool);
                     break;
 
                 case MODULE_HASHES :
                     if (parseHashes) {
-                        hashes = readModuleHashesAttribute(in, cpool);
+                        moduelHashes = readModuleHashesAttribute(in, cpool);
                     } else {
                         in.skipBytes(length);
                     }
@@ -282,15 +288,10 @@
             throw invalidModuleDescriptor(MODULE + " attribute not found");
         }
 
-        // ModuleMainClass and ModuleTarget attributes
+        // ModuleMainClass  attribute
         if (mainClass != null) {
             builder.mainClass(mainClass);
         }
-        if (osValues != null) {
-            if (osValues[0] != null) builder.osName(osValues[0]);
-            if (osValues[1] != null) builder.osArch(osValues[1]);
-            if (osValues[2] != null) builder.osVersion(osValues[2]);
-        }
 
         // If the ModulePackages attribute is not present then the packageFinder
         // is used to find the set of packages
@@ -323,7 +324,10 @@
         }
 
         ModuleDescriptor descriptor = builder.build();
-        return new Attributes(descriptor, hashes, moduleResolution);
+        return new Attributes(descriptor,
+                              moduleTarget,
+                              moduelHashes,
+                              moduleResolution);
     }
 
     /**
@@ -422,7 +426,11 @@
                     Set<String> targets = new HashSet<>(exports_to_count);
                     for (int j=0; j<exports_to_count; j++) {
                         int exports_to_index = in.readUnsignedShort();
-                        targets.add(cpool.getModuleName(exports_to_index));
+                        String target = cpool.getModuleName(exports_to_index);
+                        if (!targets.add(target)) {
+                            throw invalidModuleDescriptor(pkg + " exported to "
+                                                          + target + " more than once");
+                        }
                     }
                     builder.exports(mods, pkg, targets);
                 } else {
@@ -458,7 +466,11 @@
                     Set<String> targets = new HashSet<>(open_to_count);
                     for (int j=0; j<open_to_count; j++) {
                         int opens_to_index = in.readUnsignedShort();
-                        targets.add(cpool.getModuleName(opens_to_index));
+                        String target = cpool.getModuleName(opens_to_index);
+                        if (!targets.add(target)) {
+                            throw invalidModuleDescriptor(pkg + " opened to "
+                                                          + target + " more than once");
+                        }
                     }
                     builder.opens(mods, pkg, targets);
                 } else {
@@ -486,7 +498,10 @@
                 for (int j=0; j<with_count; j++) {
                     index = in.readUnsignedShort();
                     String pn = cpool.getClassName(index);
-                    providers.add(pn);
+                    if (!providers.add(pn)) {
+                        throw invalidModuleDescriptor(sn + " provides " + pn
+                                                      + " more than once");
+                    }
                 }
                 builder.provides(sn, providers);
             }
@@ -528,24 +543,21 @@
     /**
      * Reads the ModuleTarget attribute
      */
-    private String[] readModuleTargetAttribute(DataInput in, ConstantPool cpool)
+    private ModuleTarget readModuleTargetAttribute(DataInput in, ConstantPool cpool)
         throws IOException
     {
-        String[] values = new String[3];
+        String osName = null;
+        String osArch = null;
 
         int name_index = in.readUnsignedShort();
         if (name_index != 0)
-            values[0] = cpool.getUtf8(name_index);
+            osName = cpool.getUtf8(name_index);
 
         int arch_index = in.readUnsignedShort();
         if (arch_index != 0)
-            values[1] = cpool.getUtf8(arch_index);
+            osArch = cpool.getUtf8(arch_index);
 
-        int version_index = in.readUnsignedShort();
-        if (version_index != 0)
-            values[2] = cpool.getUtf8(version_index);
-
-        return values;
+        return new ModuleTarget(osName, osArch);
     }
 
 
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java	Wed Jul 05 23:09:40 2017 +0200
@@ -65,7 +65,6 @@
     // the values for the ModuleTarget attribute
     private String osName;
     private String osArch;
-    private String osVersion;
 
     // the hashes for the ModuleHashes attribute
     private ModuleHashes hashes;
@@ -111,12 +110,9 @@
     /**
      * Sets the values for the ModuleTarget attribute.
      */
-    public ModuleInfoExtender targetPlatform(String osName,
-                                             String osArch,
-                                             String osVersion) {
+    public ModuleInfoExtender targetPlatform(String osName, String osArch) {
         this.osName = osName;
         this.osArch = osArch;
-        this.osVersion = osVersion;
         return this;
     }
 
@@ -203,8 +199,8 @@
             cv.addAttribute(new ModulePackagesAttribute(packages));
         if (mainClass != null)
             cv.addAttribute(new ModuleMainClassAttribute(mainClass));
-        if (osName != null || osArch != null || osVersion != null)
-            cv.addAttribute(new ModuleTargetAttribute(osName, osArch, osVersion));
+        if (osName != null || osArch != null)
+            cv.addAttribute(new ModuleTargetAttribute(osName, osArch));
         if (hashes != null)
             cv.addAttribute(new ModuleHashesAttribute(hashes));
         if (moduleResolution != null)
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java	Wed Jul 05 23:09:40 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
@@ -48,7 +48,7 @@
      * Writes the given module descriptor to a module-info.class file,
      * returning it in a byte array.
      */
-    private static byte[] toModuleInfo(ModuleDescriptor md) {
+    private static byte[] toModuleInfo(ModuleDescriptor md, ModuleTarget target) {
         ClassWriter cw = new ClassWriter(0);
         cw.visit(Opcodes.V1_9, ACC_MODULE, "module-info", null, null, null);
         cw.visitAttribute(new ModuleAttribute(md));
@@ -66,12 +66,10 @@
         // write ModuleMainClass if the module has a main class
         md.mainClass().ifPresent(mc -> cw.visitAttribute(new ModuleMainClassAttribute(mc)));
 
-        // write ModuleTarget attribute if have any of OS name/arch/version
-        String osName = md.osName().orElse(null);
-        String osArch = md.osArch().orElse(null);
-        String osVersion = md.osVersion().orElse(null);
-        if (osName != null || osArch != null || osVersion != null) {
-            cw.visitAttribute(new ModuleTargetAttribute(osName, osArch, osVersion));
+        // write ModuleTarget if there is a platform OS/arch
+        if (target != null) {
+            cw.visitAttribute(new ModuleTargetAttribute(target.osName(),
+                                                        target.osArch()));
         }
 
         cw.visitEnd();
@@ -82,11 +80,23 @@
      * Writes a module descriptor to the given output stream as a
      * module-info.class.
      */
+    public static void write(ModuleDescriptor descriptor,
+                             ModuleTarget target,
+                             OutputStream out)
+        throws IOException
+    {
+        byte[] bytes = toModuleInfo(descriptor, target);
+        out.write(bytes);
+    }
+
+    /**
+     * Writes a module descriptor to the given output stream as a
+     * module-info.class.
+     */
     public static void write(ModuleDescriptor descriptor, OutputStream out)
         throws IOException
     {
-        byte[] bytes = toModuleInfo(descriptor);
-        out.write(bytes);
+        write(descriptor, null, out);
     }
 
     /**
@@ -94,8 +104,7 @@
      * in module-info.class format.
      */
     public static ByteBuffer toByteBuffer(ModuleDescriptor descriptor) {
-        byte[] bytes = toModuleInfo(descriptor);
+        byte[] bytes = toModuleInfo(descriptor, null);
         return ByteBuffer.wrap(bytes);
     }
-
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Wed Jul 05 23:09:40 2017 +0200
@@ -55,7 +55,6 @@
 import java.util.stream.Stream;
 
 import jdk.internal.loader.Resource;
-import jdk.internal.loader.ResourceHelper;
 import jdk.internal.misc.JavaLangModuleAccess;
 import jdk.internal.misc.SharedSecrets;
 import sun.net.www.ParseUtil;
@@ -165,9 +164,6 @@
 
             descriptor.version().ifPresent(builder::version);
             descriptor.mainClass().ifPresent(builder::mainClass);
-            descriptor.osName().ifPresent(builder::osName);
-            descriptor.osArch().ifPresent(builder::osArch);
-            descriptor.osVersion().ifPresent(builder::osVersion);
 
             // original + new packages
             builder.packages(descriptor.packages());
@@ -179,10 +175,12 @@
         // return a module reference to the patched module
         URI location = mref.location().orElse(null);
 
+        ModuleTarget target = null;
         ModuleHashes recordedHashes = null;
         ModuleResolution mres = null;
         if (mref instanceof ModuleReferenceImpl) {
             ModuleReferenceImpl impl = (ModuleReferenceImpl)mref;
+            target = impl.moduleTarget();
             recordedHashes = impl.recordedHashes();
             mres = impl.moduleResolution();
         }
@@ -191,6 +189,7 @@
                                        location,
                                        () -> new PatchedModuleReader(paths, mref),
                                        this,
+                                       target,
                                        recordedHashes,
                                        null,
                                        mres);
@@ -226,7 +225,7 @@
         private volatile ModuleReader delegate;
 
         /**
-         * Creates the ModuleReader to reads resources a patched module.
+         * Creates the ModuleReader to reads resources in a patched module.
          */
         PatchedModuleReader(List<Path> patches, ModuleReference mref) {
             List<ResourceFinder> finders = new ArrayList<>();
@@ -291,13 +290,16 @@
         }
 
         /**
-         * Finds a resources in the patch locations. Returns null if not found.
+         * Finds a resources in the patch locations. Returns null if not found
+         * or the name is "module-info.class" as that cannot be overridden.
          */
         private Resource findResourceInPatch(String name) throws IOException {
-            for (ResourceFinder finder : finders) {
-                Resource r = finder.find(name);
-                if (r != null)
-                    return r;
+            if (!name.equals("module-info.class")) {
+                for (ResourceFinder finder : finders) {
+                    Resource r = finder.find(name);
+                    if (r != null)
+                        return r;
+                }
             }
             return null;
         }
@@ -478,9 +480,7 @@
 
         @Override
         public Stream<String> list() throws IOException {
-            return jf.stream()
-                    .filter(e -> !e.isDirectory())
-                    .map(JarEntry::getName);
+            return jf.stream().map(JarEntry::getName);
         }
     }
 
@@ -500,14 +500,12 @@
 
         @Override
         public Resource find(String name) throws IOException {
-            Path path = ResourceHelper.toFilePath(name);
-            if (path != null) {
-                Path file = dir.resolve(path);
-                if (Files.isRegularFile(file)) {
-                    return newResource(name, dir, file);
-                }
+            Path file = Resources.toFilePath(dir, name);
+            if (file != null) {
+                return  newResource(name, dir, file);
+            } else {
+                return null;
             }
-            return null;
         }
 
         private Resource newResource(String name, Path top, Path file) {
@@ -550,11 +548,9 @@
 
         @Override
         public Stream<String> list() throws IOException {
-            return Files.find(dir, Integer.MAX_VALUE,
-                              (path, attrs) -> attrs.isRegularFile())
-                    .map(f -> dir.relativize(f)
-                                 .toString()
-                                 .replace(File.separatorChar, '/'));
+            return Files.walk(dir, Integer.MAX_VALUE)
+                        .map(f -> Resources.toResourceName(dir, f))
+                        .filter(s -> s.length() > 0);
         }
     }
 
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java	Wed Jul 05 23:09:40 2017 +0200
@@ -513,7 +513,7 @@
                         String pn = packageName(cn);
                         if (!packages.contains(pn)) {
                             String msg = "Provider class " + cn + " not in module";
-                            throw new IOException(msg);
+                            throw new InvalidModuleDescriptorException(msg);
                         }
                         providerClasses.add(cn);
                     }
@@ -533,7 +533,7 @@
                 String pn = packageName(mainClass);
                 if (!packages.contains(pn)) {
                     String msg = "Main-Class " + mainClass + " not in module";
-                    throw new IOException(msg);
+                    throw new InvalidModuleDescriptorException(msg);
                 }
                 builder.mainClass(mainClass);
             }
@@ -609,11 +609,10 @@
                 // no module-info.class so treat it as automatic module
                 try {
                     ModuleDescriptor md = deriveModuleDescriptor(jf);
-                    attrs = new ModuleInfo.Attributes(md, null, null);
-                } catch (IllegalArgumentException e) {
-                    throw new FindException(
-                        "Unable to derive module descriptor for: "
-                        + jf.getName(), e);
+                    attrs = new ModuleInfo.Attributes(md, null, null, null);
+                } catch (RuntimeException e) {
+                    throw new FindException("Unable to derive module descriptor for "
+                                            + jf.getName(), e);
                 }
 
             } else {
@@ -672,18 +671,18 @@
     /**
      * Maps the name of an entry in a JAR or ZIP file to a package name.
      *
-     * @throws IllegalArgumentException if the name is a class file in
-     *         the top-level directory of the JAR/ZIP file (and it's
-     *         not module-info.class)
+     * @throws InvalidModuleDescriptorException if the name is a class file in
+     *         the top-level directory of the JAR/ZIP file (and it's not
+     *         module-info.class)
      */
     private Optional<String> toPackageName(String name) {
         assert !name.endsWith("/");
         int index = name.lastIndexOf("/");
         if (index == -1) {
             if (name.endsWith(".class") && !name.equals(MODULE_INFO)) {
-                throw new IllegalArgumentException(name
-                        + " found in top-level directory"
-                        + " (unnamed package not allowed in module)");
+                String msg = name + " found in top-level directory"
+                             + " (unnamed package not allowed in module)";
+                throw new InvalidModuleDescriptorException(msg);
             }
             return Optional.empty();
         }
@@ -701,8 +700,8 @@
      * Maps the relative path of an entry in an exploded module to a package
      * name.
      *
-     * @throws IllegalArgumentException if the name is a class file in
-     *          the top-level directory (and it's not module-info.class)
+     * @throws InvalidModuleDescriptorException if the name is a class file in
+     *         the top-level directory (and it's not module-info.class)
      */
     private Optional<String> toPackageName(Path file) {
         assert file.getRoot() == null;
@@ -711,9 +710,9 @@
         if (parent == null) {
             String name = file.toString();
             if (name.endsWith(".class") && !name.equals(MODULE_INFO)) {
-                throw new IllegalArgumentException(name
-                        + " found in top-level directory"
-                        + " (unnamed package not allowed in module)");
+                String msg = name + " found in top-level directory"
+                             + " (unnamed package not allowed in module)";
+                throw new InvalidModuleDescriptorException(msg);
             }
             return Optional.empty();
         }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferenceImpl.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferenceImpl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -46,6 +46,9 @@
     // non-null if the module is patched
     private final ModulePatcher patcher;
 
+    // ModuleTarget if the module is OS/architecture specific
+    private final ModuleTarget target;
+
     // the hashes of other modules recorded in this module
     private final ModuleHashes recordedHashes;
 
@@ -65,6 +68,7 @@
                         URI location,
                         Supplier<ModuleReader> readerSupplier,
                         ModulePatcher patcher,
+                        ModuleTarget target,
                         ModuleHashes recordedHashes,
                         ModuleHashes.HashSupplier hasher,
                         ModuleResolution moduleResolution)
@@ -72,6 +76,7 @@
         super(descriptor, Objects.requireNonNull(location));
         this.readerSupplier = readerSupplier;
         this.patcher = patcher;
+        this.target = target;
         this.recordedHashes = recordedHashes;
         this.hasher = hasher;
         this.moduleResolution = moduleResolution;
@@ -94,6 +99,13 @@
     }
 
     /**
+     * Returns the ModuleTarget or {@code null} if the no target platform.
+     */
+    public ModuleTarget moduleTarget() {
+        return target;
+    }
+
+    /**
      * Returns the hashes recorded in this module or {@code null} if there
      * are no hashes recorded.
      */
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,7 +25,6 @@
 
 package jdk.internal.module;
 
-import java.io.File;
 import java.io.IOError;
 import java.io.IOException;
 import java.io.InputStream;
@@ -50,7 +49,6 @@
 import java.util.zip.ZipFile;
 
 import jdk.internal.jmod.JmodFile;
-import jdk.internal.loader.ResourceHelper;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.module.ModuleHashes.HashSupplier;
 import jdk.internal.util.jar.VersionedStream;
@@ -78,6 +76,7 @@
                                                        uri,
                                                        supplier,
                                                        null,
+                                                       attrs.target(),
                                                        attrs.recordedHashes(),
                                                        hasher,
                                                        attrs.moduleResolution());
@@ -242,8 +241,7 @@
         }
 
         private JarEntry getEntry(String name) {
-            JarEntry entry = jf.getJarEntry(Objects.requireNonNull(name));
-            return (entry == null || entry.isDirectory()) ? null : entry;
+            return jf.getJarEntry(Objects.requireNonNull(name));
         }
 
         @Override
@@ -252,6 +250,8 @@
             if (je != null) {
                 if (jf.isMultiRelease())
                     name = SharedSecrets.javaUtilJarAccess().getRealName(jf, je);
+                if (je.isDirectory() && !name.endsWith("/"))
+                    name += "/";
                 String encodedPath = ParseUtil.encodePath(name, false);
                 String uris = "jar:" + uri + "!/" + encodedPath;
                 return Optional.of(URI.create(uris));
@@ -274,7 +274,6 @@
         Stream<String> implList() throws IOException {
             // take snapshot to avoid async close
             List<String> names = VersionedStream.stream(jf)
-                    .filter(e -> !e.isDirectory())
                     .map(JarEntry::getName)
                     .collect(Collectors.toList());
             return names.stream();
@@ -316,6 +315,8 @@
         Optional<URI> implFind(String name) {
             JmodFile.Entry je = getEntry(name);
             if (je != null) {
+                if (je.isDirectory() && !name.endsWith("/"))
+                    name += "/";
                 String encodedPath = ParseUtil.encodePath(name, false);
                 String uris = "jmod:" + uri + "!/" + encodedPath;
                 return Optional.of(URI.create(uris));
@@ -376,26 +377,10 @@
             if (closed) throw new IOException("ModuleReader is closed");
         }
 
-        /**
-         * Returns a Path to access the given resource. Returns null if the
-         * resource name does not convert to a file path that locates a regular
-         * file in the module.
-         */
-        private Path toFilePath(String name) {
-            Path path = ResourceHelper.toFilePath(name);
-            if (path != null) {
-                Path file = dir.resolve(path);
-                if (Files.isRegularFile(file)) {
-                    return file;
-                }
-            }
-            return null;
-        }
-
         @Override
         public Optional<URI> find(String name) throws IOException {
             ensureOpen();
-            Path path = toFilePath(name);
+            Path path = Resources.toFilePath(dir, name);
             if (path != null) {
                 try {
                     return Optional.of(path.toUri());
@@ -410,7 +395,7 @@
         @Override
         public Optional<InputStream> open(String name) throws IOException {
             ensureOpen();
-            Path path = toFilePath(name);
+            Path path = Resources.toFilePath(dir, name);
             if (path != null) {
                 return Optional.of(Files.newInputStream(path));
             } else {
@@ -421,7 +406,7 @@
         @Override
         public Optional<ByteBuffer> read(String name) throws IOException {
             ensureOpen();
-            Path path = toFilePath(name);
+            Path path = Resources.toFilePath(dir, name);
             if (path != null) {
                 return Optional.of(ByteBuffer.wrap(Files.readAllBytes(path)));
             } else {
@@ -432,12 +417,9 @@
         @Override
         public Stream<String> list() throws IOException {
             ensureOpen();
-            // sym links not followed
-            return Files.find(dir, Integer.MAX_VALUE,
-                              (path, attrs) -> attrs.isRegularFile())
-                    .map(f -> dir.relativize(f)
-                                 .toString()
-                                 .replace(File.separatorChar, '/'));
+            return Files.walk(dir, Integer.MAX_VALUE)
+                        .map(f -> Resources.toResourceName(dir, f))
+                        .filter(s -> s.length() > 0);
         }
 
         @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleTarget.java	Wed Jul 05 23:09:40 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.  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.internal.module;
+
+public final class ModuleTarget {
+
+    private final String osName;
+    private final String osArch;
+
+    public ModuleTarget(String osName, String osArch) {
+        this.osName = osName;
+        this.osArch = osArch;
+    }
+
+    public String osName() {
+        return osName;
+    }
+
+    public String osArch() {
+        return osArch;
+    }
+
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java	Wed Jul 05 23:09:40 2017 +0200
@@ -31,7 +31,6 @@
 import java.net.URI;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.util.Set;
 
 import jdk.internal.loader.BootLoader;
 import jdk.internal.loader.ClassLoaders;
@@ -39,10 +38,10 @@
 import jdk.internal.misc.SharedSecrets;
 
 /**
- * A helper class to allow JDK classes create dynamic modules and to update
- * modules, exports and the readability graph. It is also invoked by the VM
- * to add read edges when agents are instrumenting code that need to link
- * to supporting classes.
+ * A helper class for creating and updating modules. This class is intended to
+ * support command-line options, tests, and the instrumentation API. It is also
+ * used by the VM to add read edges when agents are instrumenting code that
+ * need to link to supporting classes.
  *
  * The parameters that are package names in this API are the fully-qualified
  * names of the packages as defined in section 6.5.3 of <cite>The Java&trade;
@@ -72,25 +71,7 @@
     }
 
     /**
-     * Define a new module to the VM. The module has the given set of
-     * packages and is defined to the given class loader.
-     *
-     * The resulting Module is in a larval state in that it does not not read
-     * any other module and does not have any exports.
-     */
-    public static Module defineModule(ClassLoader loader,
-                                      String name,
-                                      Set<String> packages)
-    {
-        ModuleDescriptor descriptor = ModuleDescriptor.newModule(name)
-                .packages(packages)
-                .build();
-
-        return JLRMA.defineModule(loader, descriptor, null);
-    }
-
-    /**
-     * Adds a read-edge so that module {@code m1} reads module {@code m1}.
+     * Updates m1 to read m2.
      * Same as m1.addReads(m2) but without a caller check.
      */
     public static void addReads(Module m1, Module m2) {
@@ -98,21 +79,46 @@
     }
 
     /**
-     * Update module {@code m} to read all unnamed modules.
+     * Update module m to read all unnamed modules.
      */
     public static void addReadsAllUnnamed(Module m) {
         JLRMA.addReadsAllUnnamed(m);
     }
 
     /**
+     * Update module m to export a package to all modules.
+     *
+     * This method is for intended for use by tests only.
+     */
+    public static void addExports(Module m, String pn) {
+        JLRMA.addExports(m, pn);
+    }
+
+    /**
      * Updates module m1 to export a package to module m2.
-     * Same as m1.addExports(pn, m2) but without a caller check.
+     * Same as m1.addExports(pn, m2) but without a caller check
      */
     public static void addExports(Module m1, String pn, Module m2) {
         JLRMA.addExports(m1, pn, m2);
     }
 
     /**
+     * Updates module m to export a package to all unnamed modules.
+     */
+    public static void addExportsToAllUnnamed(Module m, String pn) {
+        JLRMA.addExportsToAllUnnamed(m, pn);
+    }
+
+    /**
+     * Update module m to open a package to all modules.
+     *
+     * This method is for intended for use by tests only.
+     */
+    public static void addOpens(Module m, String pn) {
+        JLRMA.addOpens(m, pn);
+    }
+
+    /**
      * Updates module m1 to open a package to module m2.
      * Same as m1.addOpens(pn, m2) but without a caller check.
      */
@@ -121,27 +127,6 @@
     }
 
     /**
-     * Updates a module m to export a package to all modules.
-     */
-    public static void addExportsToAll(Module m, String pn) {
-        JLRMA.addExportsToAll(m, pn);
-    }
-
-    /**
-     * Updates a module m to open a package to all modules.
-     */
-    public static void addOpensToAll(Module m, String pn) {
-        JLRMA.addOpensToAll(m, pn);
-    }
-
-    /**
-     * Updates module m to export a package to all unnamed modules.
-     */
-    public static void addExportsToAllUnnamed(Module m, String pn) {
-        JLRMA.addExportsToAllUnnamed(m, pn);
-    }
-
-    /**
      * Updates module m to open a package to all unnamed modules.
      */
     public static void addOpensToAllUnnamed(Module m, String pn) {
@@ -149,7 +134,8 @@
     }
 
     /**
-     * Updates module m to use a service
+     * Updates module m to use a service.
+     * Same as m2.addUses(service) but without a caller check.
      */
     public static void addUses(Module m, Class<?> service) {
         JLRMA.addUses(m, service);
@@ -183,16 +169,6 @@
     }
 
     /**
-     * Adds a package to a module's content.
-     *
-     * This method is a no-op if the module already contains the package or the
-     * module is an unnamed module.
-     */
-    public static void addPackage(Module m, String pn) {
-        JLRMA.addPackage(m, pn);
-    }
-
-    /**
      * Called by the VM when code in the given Module has been transformed by
      * an agent and so may have been instrumented to call into supporting
      * classes on the boot class path or application class path.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/Resources.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,167 @@
+/*
+ * 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.  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.internal.module;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+
+/**
+ * A helper class to support working with resources in modules. Also provides
+ * support for translating resource names to file paths.
+ */
+public final class Resources {
+    private Resources() { }
+
+    /**
+     * Return true if a resource can be encapsulated. Resource with names
+     * ending in ".class" or "/" cannot be encapsulated. Resource names
+     * that map to a legal package name can be encapsulated.
+     */
+    public static boolean canEncapsulate(String name) {
+        int len = name.length();
+        if (len > 6 && name.endsWith(".class")) {
+            return false;
+        } else {
+            return Checks.isPackageName(toPackageName(name));
+        }
+    }
+
+    /**
+     * Derive a <em>package name</em> for a resource. The package name
+     * returned by this method may not be a legal package name. This method
+     * returns null if the the resource name ends with a "/" (a directory)
+     * or the resource name does not contain a "/".
+     */
+    public static String toPackageName(String name) {
+        int index = name.lastIndexOf('/');
+        if (index == -1 || index == name.length()-1) {
+            return "";
+        } else {
+            return name.substring(0, index).replace("/", ".");
+        }
+    }
+
+    /**
+     * Returns a resource name corresponding to the relative file path
+     * between {@code dir} and {@code file}. If the file is a directory
+     * then the name will end with a  "/", except the top-level directory
+     * where the empty string is returned.
+     */
+    public static String toResourceName(Path dir, Path file) {
+        String s = dir.relativize(file)
+                      .toString()
+                      .replace(File.separatorChar, '/');
+        if (s.length() > 0 && Files.isDirectory(file))
+            s += "/";
+        return s;
+    }
+
+    /**
+     * Returns a file path to a resource in a file tree. If the resource
+     * name has a trailing "/" then the file path will locate a directory.
+     * Returns {@code null} if the resource does not map to a file in the
+     * tree file.
+     */
+    public static Path toFilePath(Path dir, String name) throws IOException {
+        boolean expectDirectory = name.endsWith("/");
+        if (expectDirectory) {
+            name = name.substring(0, name.length() - 1);  // drop trailing "/"
+        }
+        Path path = toSafeFilePath(name);
+        if (path != null) {
+            Path file = dir.resolve(path);
+            try {
+                BasicFileAttributes attrs;
+                attrs = Files.readAttributes(file, BasicFileAttributes.class);
+                if (attrs.isDirectory()
+                    || (!attrs.isDirectory() && !expectDirectory))
+                    return file;
+            } catch (NoSuchFileException ignore) { }
+        }
+        return null;
+    }
+
+    /**
+     * Map a resource name to a "safe" file path. Returns {@code null} if
+     * the resource name cannot be converted into a "safe" file path.
+     *
+     * Resource names with empty elements, or elements that are "." or ".."
+     * are rejected, as are resource names that translates to a file path
+     * with a root component.
+     */
+    private static Path toSafeFilePath(String name) {
+        // scan elements of resource name
+        int next;
+        int off = 0;
+        while ((next = name.indexOf('/', off)) != -1) {
+            int len = next - off;
+            if (!mayTranslate(name, off, len)) {
+                return null;
+            }
+            off = next + 1;
+        }
+        int rem = name.length() - off;
+        if (!mayTranslate(name, off, rem)) {
+            return null;
+        }
+
+        // convert to file path
+        Path path;
+        if (File.separatorChar == '/') {
+            path = Paths.get(name);
+        } else {
+            // not allowed to embed file separators
+            if (name.contains(File.separator))
+                return null;
+            path = Paths.get(name.replace('/', File.separatorChar));
+        }
+
+        // file path not allowed to have root component
+        return (path.getRoot() == null) ? path : null;
+    }
+
+    /**
+     * Returns {@code true} if the element in a resource name is a candidate
+     * to translate to the element of a file path.
+     */
+    private static boolean mayTranslate(String name, int off, int len) {
+        if (len <= 2) {
+            if (len == 0)
+                return false;
+            boolean starsWithDot = (name.charAt(off) == '.');
+            if (len == 1 && starsWithDot)
+                return false;
+            if (len == 2 && starsWithDot && (name.charAt(off+1) == '.'))
+                return false;
+        }
+        return true;
+    }
+
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModuleFinder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModuleFinder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -150,18 +150,21 @@
             System.getProperty("jdk.system.module.finder.disabledFastPath") != null;
 
         ModuleDescriptor[] descriptors;
+        ModuleTarget[] targets;
         ModuleHashes[] recordedHashes;
         ModuleResolution[] moduleResolutions;
 
         // fast loading of ModuleDescriptor of system modules
         if (isFastPathSupported() && !disabled) {
             descriptors = SystemModules.descriptors();
+            targets = SystemModules.targets();
             recordedHashes = SystemModules.hashes();
             moduleResolutions = SystemModules.moduleResolutions();
         } else {
             // if fast loading of ModuleDescriptors is disabled
             // fallback to read module-info.class
             descriptors = new ModuleDescriptor[n];
+            targets = new ModuleTarget[n];
             recordedHashes = new ModuleHashes[n];
             moduleResolutions = new ModuleResolution[n];
             ImageReader imageReader = SystemImage.reader();
@@ -171,6 +174,7 @@
                 ModuleInfo.Attributes attrs =
                     ModuleInfo.read(imageReader.getResourceBuffer(loc), null);
                 descriptors[i] = attrs.descriptor();
+                targets[i] = attrs.target();
                 recordedHashes[i] = attrs.recordedHashes();
                 moduleResolutions[i] = attrs.moduleResolution();
             }
@@ -206,6 +210,7 @@
 
             // create the ModuleReference
             ModuleReference mref = toModuleReference(md,
+                                                     targets[i],
                                                      recordedHashes[i],
                                                      hashSupplier(names[i]),
                                                      moduleResolutions[i]);
@@ -233,6 +238,7 @@
     }
 
     private ModuleReference toModuleReference(ModuleDescriptor md,
+                                              ModuleTarget target,
                                               ModuleHashes recordedHashes,
                                               HashSupplier hasher,
                                               ModuleResolution mres) {
@@ -246,9 +252,14 @@
             }
         };
 
-        ModuleReference mref =
-            new ModuleReferenceImpl(md, uri, readerSupplier, null,
-                                    recordedHashes, hasher, mres);
+        ModuleReference mref = new ModuleReferenceImpl(md,
+                                                       uri,
+                                                       readerSupplier,
+                                                       null,
+                                                       target,
+                                                       recordedHashes,
+                                                       hasher,
+                                                       mres);
 
         // may need a reference to a patched module if --patch-module specified
         mref = ModuleBootstrap.patcher().patchIfNeeded(mref);
--- a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java	Wed Jul 05 23:09:40 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,7 +27,7 @@
 
 import java.lang.module.ModuleDescriptor;
 
-/*
+/**
  * SystemModules class will be generated at link time to create
  * ModuleDescriptor for the system modules directly to improve
  * the module descriptor reconstitution time.
@@ -65,7 +65,7 @@
     }
 
     /**
-     * Returns a non-empty array of ModuleDescriptors in the run-time image.
+     * Returns a non-empty array of ModuleDescriptor objects in the run-time image.
      *
      * When running an exploded image it returns an empty array.
      */
@@ -74,6 +74,15 @@
     }
 
     /**
+     * Returns a non-empty array of ModuleTarget objects in the run-time image.
+     *
+     * When running an exploded image it returns an empty array.
+     */
+    public static ModuleTarget[] targets() {
+        throw new InternalError("expected to be overridden at link time");
+    }
+
+    /**
      * Returns a non-empty array of ModuleHashes recorded in each module
      * in the run-time image.
      *
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java	Wed Jul 05 23:09:40 2017 +0200
@@ -2508,7 +2508,7 @@
     }
 
     /**
-     * Reads a CONSTANT_Pakcage_info item in {@code b}.  This method is
+     * Reads a CONSTANT_Package_info item in {@code b}.  This method is
      * intended for {@link Attribute} sub slasses, and is normally not needed
      * by class generators or adapters.</i>
      *
--- a/jdk/src/java.base/share/classes/jdk/internal/reflect/Reflection.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/Reflection.java	Wed Jul 05 23:09:40 2017 +0200
@@ -31,9 +31,7 @@
 import java.util.Map;
 import java.util.Objects;
 import jdk.internal.HotSpotIntrinsicCandidate;
-import jdk.internal.misc.SharedSecrets;
 import jdk.internal.misc.VM;
-import sun.security.action.GetPropertyAction;
 
 /** Common utility routines used by both java.lang and
     java.lang.reflect */
@@ -104,39 +102,40 @@
                                           int modifiers)
         throws IllegalAccessException
     {
-        if (currentClass == null || memberClass == null) {
-            throw new InternalError();
-        }
-
         if (!verifyMemberAccess(currentClass, memberClass, targetClass, modifiers)) {
-            throwIllegalAccessException(currentClass, memberClass, targetClass, modifiers);
+            throw newIllegalAccessException(currentClass, memberClass, targetClass, modifiers);
         }
     }
 
     /**
-     * Verify access to a member, returning {@code false} if no access
+     * Verify access to a member and return {@code true} if it is granted.
+     *
+     * @param currentClass the class performing the access
+     * @param memberClass the declaring class of the member being accessed
+     * @param targetClass the class of target object if accessing instance
+     *                    field or method;
+     *                    or the declaring class if accessing constructor;
+     *                    or null if accessing static field or method
+     * @param modifiers the member's access modifiers
+     * @return {@code true} if access to member is granted
      */
     public static boolean verifyMemberAccess(Class<?> currentClass,
                                              Class<?> memberClass,
                                              Class<?> targetClass,
                                              int modifiers)
     {
-        // Verify that currentClass can access a field, method, or
-        // constructor of memberClass, where that member's access bits are
-        // "modifiers".
-
-        boolean gotIsSameClassPackage = false;
-        boolean isSameClassPackage = false;
-
         if (currentClass == memberClass) {
             // Always succeeds
             return true;
         }
 
-        if (!verifyModuleAccess(currentClass, memberClass)) {
+        if (!verifyModuleAccess(currentClass.getModule(), memberClass)) {
             return false;
         }
 
+        boolean gotIsSameClassPackage = false;
+        boolean isSameClassPackage = false;
+
         if (!Modifier.isPublic(getClassAccessFlags(memberClass))) {
             isSameClassPackage = isSameClassPackage(currentClass, memberClass);
             gotIsSameClassPackage = true;
@@ -196,31 +195,20 @@
     }
 
     /**
-     * Returns {@code true} if memberClass's's module exports memberClass's
-     * package to currentClass's module.
+     * Returns {@code true} if memberClass's module exports memberClass's
+     * package to currentModule.
      */
-    public static boolean verifyModuleAccess(Class<?> currentClass,
-                                             Class<?> memberClass) {
-        return verifyModuleAccess(currentClass.getModule(), memberClass);
-    }
-
     public static boolean verifyModuleAccess(Module currentModule, Class<?> memberClass) {
         Module memberModule = memberClass.getModule();
-
-        // module may be null during startup (initLevel 0)
-        if (currentModule == memberModule)
-           return true;  // same module (named or unnamed)
-
-        String pkg = memberClass.getPackageName();
-        boolean allowed = memberModule.isExported(pkg, currentModule);
-        if (allowed && memberModule.isNamed() && printStackTraceWhenAccessSucceeds()) {
-            if (!SharedSecrets.getJavaLangReflectModuleAccess()
-                    .isStaticallyExported(memberModule, pkg, currentModule)) {
-                String msg = currentModule + " allowed access to member of " + memberClass;
-                new Exception(msg).printStackTrace(System.err);
-            }
+        if (currentModule == memberModule) {
+            // same module (named or unnamed) or both null if called
+            // before module system is initialized, which means we are
+            // dealing with java.base only.
+            return true;
+        } else {
+            String pkg = memberClass.getPackageName();
+            return memberModule.isExported(pkg, currentModule);
         }
-        return allowed;
     }
 
     /**
@@ -344,46 +332,14 @@
         return false;
     }
 
-
-    // true to print a stack trace when access fails
-    private static volatile boolean printStackWhenAccessFails;
-
-    // true to print a stack trace when access succeeds
-    private static volatile boolean printStackWhenAccessSucceeds;
-
-    // true if printStack* values are initialized
-    private static volatile boolean printStackPropertiesSet;
-
-    private static void ensurePrintStackPropertiesSet() {
-        if (!printStackPropertiesSet && VM.initLevel() >= 1) {
-            String s = GetPropertyAction.privilegedGetProperty(
-                    "sun.reflect.debugModuleAccessChecks");
-            if (s != null) {
-                printStackWhenAccessFails = !s.equalsIgnoreCase("false");
-                printStackWhenAccessSucceeds = s.equalsIgnoreCase("access");
-            }
-            printStackPropertiesSet = true;
-        }
-    }
-
-    public static boolean printStackTraceWhenAccessFails() {
-        ensurePrintStackPropertiesSet();
-        return printStackWhenAccessFails;
-    }
-
-    public static boolean printStackTraceWhenAccessSucceeds() {
-        ensurePrintStackPropertiesSet();
-        return printStackWhenAccessSucceeds;
-    }
-
     /**
-     * Throws IllegalAccessException with the an exception message based on
+     * Returns an IllegalAccessException with an exception message based on
      * the access that is denied.
      */
-    private static void throwIllegalAccessException(Class<?> currentClass,
-                                                    Class<?> memberClass,
-                                                    Object target,
-                                                    int modifiers)
+    public static IllegalAccessException newIllegalAccessException(Class<?> currentClass,
+                                                                   Class<?> memberClass,
+                                                                   Class<?> targetClass,
+                                                                   int modifiers)
         throws IllegalAccessException
     {
         String currentSuffix = "";
@@ -411,20 +367,6 @@
             if (m2.isNamed()) msg += " to " + m1;
         }
 
-        throwIllegalAccessException(msg);
-    }
-
-    /**
-     * Throws IllegalAccessException with the given exception message.
-     */
-    public static void throwIllegalAccessException(String msg)
-        throws IllegalAccessException
-    {
-        IllegalAccessException e = new IllegalAccessException(msg);
-        ensurePrintStackPropertiesSet();
-        if (printStackWhenAccessFails) {
-            e.printStackTrace(System.err);
-        }
-        throw e;
+        return new IllegalAccessException(msg);
     }
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Wed Jul 05 23:09:40 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
@@ -44,6 +44,7 @@
 import java.util.Objects;
 import java.util.Properties;
 
+import jdk.internal.misc.VM;
 import sun.reflect.misc.ReflectUtil;
 import sun.security.action.GetPropertyAction;
 
@@ -585,17 +586,10 @@
     private static void checkInitted() {
         if (initted) return;
 
-        // Tests to ensure the system properties table is fully
-        // initialized. This is needed because reflection code is
-        // called very early in the initialization process (before
-        // command-line arguments have been parsed and therefore
-        // these user-settable properties installed.) We assume that
-        // if System.out is non-null then the System class has been
-        // fully initialized and that the bulk of the startup code
-        // has been run.
-
-        if (System.out == null) {
-            // java.lang.System not yet fully initialized
+        // Defer initialization until module system is initialized so as
+        // to avoid inflation and spinning bytecode in unnamed modules
+        // during early startup.
+        if (!VM.isModuleSystemInited()) {
             return;
         }
 
--- a/jdk/src/java.base/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the foundational APIs of the Java SE Platform.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.base {
@@ -125,10 +126,9 @@
         jdk.jlink;
     exports jdk.internal.loader to
         java.instrument,
-        java.logging,
-        jdk.jlink;
+        java.logging;
     exports jdk.internal.jmod to
-        jdk.compiler,
+        jdk.compiler,   // reflective dependency
         jdk.jlink;
     exports jdk.internal.logger to
         java.logging;
@@ -140,10 +140,7 @@
     exports jdk.internal.org.objectweb.asm.tree to
         jdk.jlink;
     exports jdk.internal.org.objectweb.asm.util to
-        jdk.jlink,
         jdk.scripting.nashorn;
-    exports jdk.internal.org.objectweb.asm.tree.analysis to
-        jdk.jlink;
     exports jdk.internal.org.objectweb.asm.commons to
         jdk.scripting.nashorn;
     exports jdk.internal.org.objectweb.asm.signature to
@@ -157,7 +154,6 @@
         jdk.jlink;
     exports jdk.internal.misc to
         java.desktop,
-        jdk.incubator.httpclient,
         java.logging,
         java.management,
         java.naming,
@@ -166,8 +162,8 @@
         java.sql,
         java.xml,
         jdk.charsets,
-        jdk.compiler,
-        jdk.jartool,
+        jdk.compiler,   // reflective dependency
+        jdk.incubator.httpclient,
         jdk.jdeps,
         jdk.jlink,
         jdk.jshell,
@@ -210,11 +206,10 @@
         jdk.naming.dns;
     exports sun.net.util to
         java.desktop,
-        jdk.jconsole,
-        jdk.naming.dns;
+        jdk.jconsole;
     exports sun.net.www to
+        java.desktop,
         jdk.incubator.httpclient,
-        java.desktop,
         jdk.jartool;
     exports sun.net.www.protocol.http to
         java.security.jgss;
--- a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Wed Jul 05 23:09:40 2017 +0200
@@ -428,7 +428,7 @@
                 abort(null, "java.launcher.jar.error3", jarname);
             }
 
-            // Add-Exports and Add-Opens to break encapsulation
+            // Add-Exports and Add-Opens
             String exports = mainAttrs.getValue(ADD_EXPORTS);
             if (exports != null) {
                 addExportsOrOpens(exports, false);
@@ -466,6 +466,7 @@
             if (s.length == 2) {
                 String mn = s[0];
                 String pn = s[1];
+
                 Layer.boot().findModule(mn).ifPresent(m -> {
                     if (m.getDescriptor().packages().contains(pn)) {
                         if (open) {
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -24,12 +24,15 @@
 #
 
 # Translators please note do not translate the options themselves
-java.launcher.opt.header  =   Usage: {0} [options] class [args...]\n\
-\           (to execute a class)\n   or  {0} [options] -jar jarfile [args...]\n\
+java.launcher.opt.header  =   Usage: {0} [options] <mainclass> [args...]\n\
+\           (to execute a class)\n   or  {0} [options] -jar <jarfile> [args...]\n\
 \           (to execute a jar file)\n\
-\   or  {0} [options] -p <modulepath> -m <modulename>[/<mainclass>] [args...]\n\
+\   or  {0} [options] -m <module>[/<mainclass>] [args...]\n\
+\       {0} [options] --module <module>[/<mainclass>] [args...]\n\
 \           (to execute the main class in a module)\n\n\
-where options include:\n\n
+\ Arguments following the main class, -jar <jarfile>, -m or --module\n\
+\ <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
@@ -49,10 +52,6 @@
 \                  A {0} separated list of directories, each directory\n\
 \                  is a directory of modules that replace upgradeable\n\
 \                  modules in the runtime image\n\
-\    -m <module>[/<mainclass>]\n\
-\    --module <modulename>[/<mainclass>]\n\
-\                  the initial module to resolve, and the name of the main class\n\
-\                  to execute if not specified by the module\n\
 \    --add-modules <modulename>[,<modulename>...]\n\
 \                  root modules to resolve in addition to the initial module.\n\
 \                  <modulename> can also be ALL-DEFAULT, ALL-SYSTEM,\n\
@@ -129,7 +128,7 @@
 \    -Xms<size>        set initial Java heap size\n\
 \    -Xmx<size>        set maximum Java heap size\n\
 \    -Xnoclassgc       disable class garbage collection\n\
-\    -Xprof            output cpu profiling data\n\
+\    -Xprof            output cpu profiling data (deprecated)\n\
 \    -Xrs              reduce use of OS signals by Java/VM (see documentation)\n\
 \    -Xshare:auto      use shared class data if possible (default)\n\
 \    -Xshare:off       do not attempt to use shared class data\n\
@@ -157,6 +156,10 @@
 \    --add-opens <module>/<package>=<target-module>(,<target-module>)*\n\
 \                      updates <module> to open <package> to\n\
 \                      <target-module>, regardless of module declaration.\n\
+\    --permit-illegal-access\n\
+\                      permit illegal access to members of types in named modules\n\
+\                      by code in unnamed modules. This compatibility option will\n\
+\                      be removed in the next release.\n\
 \    --disable-@files  disable further argument file expansion\n\
 \    --patch-module <module>=<file>({0}<file>)*\n\
 \                      Override or augment a module with classes and resources\n\
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java	Wed Jul 05 23:09:40 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
@@ -26,8 +26,6 @@
 package sun.net.www.protocol.jrt;
 
 import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FilePermission;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -44,7 +42,6 @@
 import jdk.internal.loader.Resource;
 import sun.net.www.ParseUtil;
 import sun.net.www.URLConnection;
-import sun.security.action.GetPropertyAction;
 
 /**
  * URLConnection implementation that can be used to connect to resources
@@ -66,9 +63,6 @@
     // the Resource when connected
     private volatile Resource resource;
 
-    // the permission to access resources in the runtime image, created lazily
-    private static volatile Permission permission;
-
     JavaRuntimeURLConnection(URL url) throws IOException {
         super(url);
         String path = url.getPath();
@@ -164,14 +158,8 @@
     }
 
     @Override
-    public Permission getPermission() throws IOException {
-        Permission p = permission;
-        if (p == null) {
-            String home = GetPropertyAction.privilegedGetProperty("java.home");
-            p = new FilePermission(home + File.separator + "-", "read");
-            permission = p;
-        }
-        return p;
+    public Permission getPermission() {
+        return new RuntimePermission("accessSystemModules");
     }
 
     /**
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java	Wed Jul 05 23:09:40 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/rsa/RSAPrivateCrtKeyImpl.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, 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
@@ -191,14 +191,22 @@
             if (version != 0) {
                 throw new IOException("Version must be 0");
             }
-            n = getBigInteger(data);
-            e = getBigInteger(data);
-            d = getBigInteger(data);
-            p = getBigInteger(data);
-            q = getBigInteger(data);
-            pe = getBigInteger(data);
-            qe = getBigInteger(data);
-            coeff = getBigInteger(data);
+
+            /*
+             * Some implementations do not correctly encode ASN.1 INTEGER values
+             * in 2's complement format, resulting in a negative integer when
+             * decoded. Correct the error by converting it to a positive integer.
+             *
+             * See CR 6255949
+             */
+            n = data.getPositiveBigInteger();
+            e = data.getPositiveBigInteger();
+            d = data.getPositiveBigInteger();
+            p = data.getPositiveBigInteger();
+            q = data.getPositiveBigInteger();
+            pe = data.getPositiveBigInteger();
+            qe = data.getPositiveBigInteger();
+            coeff = data.getPositiveBigInteger();
             if (derValue.data.available() != 0) {
                 throw new IOException("Extra data available");
             }
@@ -206,23 +214,4 @@
             throw new InvalidKeyException("Invalid RSA private key", e);
         }
     }
-
-    /**
-     * Read a BigInteger from the DerInputStream.
-     */
-    static BigInteger getBigInteger(DerInputStream data) throws IOException {
-        BigInteger b = data.getBigInteger();
-
-        /*
-         * Some implementations do not correctly encode ASN.1 INTEGER values
-         * in 2's complement format, resulting in a negative integer when
-         * decoded. Correct the error by converting it to a positive integer.
-         *
-         * See CR 6255949
-         */
-        if (b.signum() < 0) {
-            b = new BigInteger(1, b.toByteArray());
-        }
-        return b;
-    }
 }
--- a/jdk/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, 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
@@ -111,8 +111,8 @@
                 throw new IOException("Not a SEQUENCE");
             }
             DerInputStream data = derValue.data;
-            n = RSAPrivateCrtKeyImpl.getBigInteger(data);
-            e = RSAPrivateCrtKeyImpl.getBigInteger(data);
+            n = data.getPositiveBigInteger();
+            e = data.getPositiveBigInteger();
             if (derValue.data.available() != 0) {
                 throw new IOException("Extra data available");
             }
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1025,6 +1025,13 @@
             cf = CertificateFactory.getInstance("X509");
         }
 
+        // -trustcacerts can only be specified on -importcert.
+        // Reset it so that warnings on CA cert will remain for
+        // -printcert, etc.
+        if (command != IMPORTCERT) {
+            trustcacerts = false;
+        }
+
         if (trustcacerts) {
             caks = KeyStoreUtil.getCacertsKeyStore();
         }
@@ -1758,9 +1765,8 @@
         if (keyPass == null) {
             keyPass = promptForKeyPass(alias, null, storePass);
         }
+        checkWeak(rb.getString("the.generated.certificate"), chain[0]);
         keyStore.setKeyEntry(alias, privKey, keyPass, chain);
-
-        checkWeak(rb.getString("the.generated.certificate"), chain[0]);
     }
 
     /**
@@ -2118,6 +2124,10 @@
         }
 
         try {
+            Certificate c = srckeystore.getCertificate(alias);
+            if (c != null) {
+                checkWeak("<" + newAlias + ">", c);
+            }
             keyStore.setEntry(newAlias, entry, pp);
             // Place the check so that only successful imports are blocked.
             // For example, we don't block a failed SecretEntry import.
@@ -2127,10 +2137,6 @@
                             "The.destination.pkcs12.keystore.has.different.storepass.and.keypass.Please.retry.with.destkeypass.specified."));
                 }
             }
-            Certificate c = srckeystore.getCertificate(alias);
-            if (c != null) {
-                checkWeak("<" + newAlias + ">", c);
-            }
             return 1;
         } catch (KeyStoreException kse) {
             Object[] source2 = {alias, kse.toString()};
@@ -2814,8 +2820,8 @@
         }
 
         if (noprompt) {
+            checkWeak(rb.getString("the.input"), cert);
             keyStore.setCertificateEntry(alias, cert);
-            checkWeak(rb.getString("the.input"), cert);
             return true;
         }
 
@@ -3049,6 +3055,11 @@
         MessageFormat form = new MessageFormat
                 (rb.getString(".PATTERN.printX509Cert.with.weak"));
         PublicKey pkey = cert.getPublicKey();
+        String sigName = cert.getSigAlgName();
+        // No need to warn about sigalg of a trust anchor
+        if (!isTrustedCert(cert)) {
+            sigName = withWeak(sigName);
+        }
         Object[] source = {cert.getSubjectDN().toString(),
                         cert.getIssuerDN().toString(),
                         cert.getSerialNumber().toString(16),
@@ -3056,7 +3067,7 @@
                         cert.getNotAfter().toString(),
                         getCertFingerPrint("SHA-1", cert),
                         getCertFingerPrint("SHA-256", cert),
-                        withWeak(cert.getSigAlgName()),
+                        sigName,
                         withWeak(pkey),
                         cert.getVersion()
                         };
@@ -3111,7 +3122,7 @@
      * or null otherwise. A label is added.
      */
     private static Pair<String,Certificate>
-            getTrustedSigner(Certificate cert, KeyStore ks) throws Exception {
+            getSigner(Certificate cert, KeyStore ks) throws Exception {
         if (ks.getCertificateAlias(cert) != null) {
             return new Pair<>("", cert);
         }
@@ -3467,9 +3478,9 @@
         // do we trust the cert at the top?
         Certificate topCert = replyCerts[replyCerts.length-1];
         boolean fromKeyStore = true;
-        Pair<String,Certificate> root = getTrustedSigner(topCert, keyStore);
+        Pair<String,Certificate> root = getSigner(topCert, keyStore);
         if (root == null && trustcacerts && caks != null) {
-            root = getTrustedSigner(topCert, caks);
+            root = getSigner(topCert, caks);
             fromKeyStore = false;
         }
         if (root == null) {
@@ -4301,9 +4312,19 @@
         return result;
     }
 
+    private boolean isTrustedCert(Certificate cert) throws KeyStoreException {
+        if (caks != null && caks.getCertificateAlias(cert) != null) {
+            return true;
+        } else {
+            String inKS = keyStore.getCertificateAlias(cert);
+            return inKS != null && keyStore.isCertificateEntry(inKS);
+        }
+    }
+
     private void checkWeak(String label, String sigAlg, Key key) {
 
-        if (!DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, sigAlg, null)) {
+        if (sigAlg != null && !DISABLED_CHECK.permits(
+                SIG_PRIMITIVE_SET, sigAlg, null)) {
             weakWarnings.add(String.format(
                     rb.getString("whose.sigalg.risk"), label, sigAlg));
         }
@@ -4316,7 +4337,8 @@
         }
     }
 
-    private void checkWeak(String label, Certificate[] certs) {
+    private void checkWeak(String label, Certificate[] certs)
+            throws KeyStoreException {
         for (int i = 0; i < certs.length; i++) {
             Certificate cert = certs[i];
             if (cert instanceof X509Certificate) {
@@ -4325,15 +4347,18 @@
                 if (certs.length > 1) {
                     fullLabel = oneInMany(label, i, certs.length);
                 }
-                checkWeak(fullLabel, xc.getSigAlgName(), xc.getPublicKey());
+                checkWeak(fullLabel, xc);
             }
         }
     }
 
-    private void checkWeak(String label, Certificate cert) {
+    private void checkWeak(String label, Certificate cert)
+            throws KeyStoreException {
         if (cert instanceof X509Certificate) {
             X509Certificate xc = (X509Certificate)cert;
-            checkWeak(label, xc.getSigAlgName(), xc.getPublicKey());
+            // No need to check the sigalg of a trust anchor
+            String sigAlg = isTrustedCert(cert) ? null : xc.getSigAlgName();
+            checkWeak(label, sigAlg, xc.getPublicKey());
         }
     }
 
--- a/jdk/src/java.base/share/classes/sun/security/util/DerInputBuffer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/DerInputBuffer.java	Wed Jul 05 23:09:40 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
@@ -44,16 +44,26 @@
  */
 class DerInputBuffer extends ByteArrayInputStream implements Cloneable {
 
-    DerInputBuffer(byte[] buf) { super(buf); }
+    boolean allowBER = true;
+
+    // used by sun/security/util/DerInputBuffer/DerInputBufferEqualsHashCode.java
+    DerInputBuffer(byte[] buf) {
+        this(buf, true);
+    }
 
-    DerInputBuffer(byte[] buf, int offset, int len) {
+    DerInputBuffer(byte[] buf, boolean allowBER) {
+        super(buf);
+        this.allowBER = allowBER;
+    }
+
+    DerInputBuffer(byte[] buf, int offset, int len, boolean allowBER) {
         super(buf, offset, len);
+        this.allowBER = allowBER;
     }
 
     DerInputBuffer dup() {
         try {
             DerInputBuffer retval = (DerInputBuffer)clone();
-
             retval.mark(Integer.MAX_VALUE);
             return retval;
         } catch (CloneNotSupportedException e) {
@@ -147,8 +157,8 @@
         System.arraycopy(buf, pos, bytes, 0, len);
         skip(len);
 
-        // check to make sure no extra leading 0s for DER
-        if (len >= 2 && (bytes[0] == 0) && (bytes[1] >= 0)) {
+        // BER allows leading 0s but DER does not
+        if (!allowBER && (len >= 2 && (bytes[0] == 0) && (bytes[1] >= 0))) {
             throw new IOException("Invalid encoding: redundant leading 0s");
         }
 
--- a/jdk/src/java.base/share/classes/sun/security/util/DerInputStream.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/DerInputStream.java	Wed Jul 05 23:09:40 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
@@ -81,6 +81,25 @@
     }
 
     /**
+     * Create a DER input stream from part of a data buffer with
+     * additional arg to control whether DER checks are enforced.
+     * The buffer is not copied, it is shared.  Accordingly, the
+     * buffer should be treated as read-only.
+     *
+     * @param data the buffer from which to create the string (CONSUMED)
+     * @param offset the first index of <em>data</em> which will
+     *          be read as DER input in the new stream
+     * @param len how long a chunk of the buffer to use,
+     *          starting at "offset"
+     * @param allowBER whether to allow constructed indefinite-length
+     *          encoding as well as tolerate leading 0s
+     */
+    public DerInputStream(byte[] data, int offset, int len,
+        boolean allowBER) throws IOException {
+        init(data, offset, len, allowBER);
+    }
+
+    /**
      * Create a DER input stream from part of a data buffer.
      * The buffer is not copied, it is shared.  Accordingly, the
      * buffer should be treated as read-only.
@@ -95,47 +114,27 @@
         init(data, offset, len, true);
     }
 
-    /**
-     * Create a DER input stream from part of a data buffer with
-     * additional arg to indicate whether to allow constructed
-     * indefinite-length encoding.
-     * The buffer is not copied, it is shared.  Accordingly, the
-     * buffer should be treated as read-only.
-     *
-     * @param data the buffer from which to create the string (CONSUMED)
-     * @param offset the first index of <em>data</em> which will
-     *          be read as DER input in the new stream
-     * @param len how long a chunk of the buffer to use,
-     *          starting at "offset"
-     * @param allowIndefiniteLength whether to allow constructed
-     *          indefinite-length encoding
-     */
-    public DerInputStream(byte[] data, int offset, int len,
-        boolean allowIndefiniteLength) throws IOException {
-        init(data, offset, len, allowIndefiniteLength);
-    }
-
     /*
      * private helper routine
      */
-    private void init(byte[] data, int offset, int len,
-        boolean allowIndefiniteLength) throws IOException {
+    private void init(byte[] data, int offset, int len, boolean allowBER) throws IOException {
         if ((offset+2 > data.length) || (offset+len > data.length)) {
             throw new IOException("Encoding bytes too short");
         }
         // check for indefinite length encoding
         if (DerIndefLenConverter.isIndefinite(data[offset+1])) {
-            if (!allowIndefiniteLength) {
+            if (!allowBER) {
                 throw new IOException("Indefinite length BER encoding found");
             } else {
                 byte[] inData = new byte[len];
                 System.arraycopy(data, offset, inData, 0, len);
 
                 DerIndefLenConverter derIn = new DerIndefLenConverter();
-                buffer = new DerInputBuffer(derIn.convert(inData));
+                buffer = new DerInputBuffer(derIn.convert(inData), allowBER);
             }
-        } else
-            buffer = new DerInputBuffer(data, offset, len);
+        } else {
+            buffer = new DerInputBuffer(data, offset, len, allowBER);
+        }
         buffer.mark(Integer.MAX_VALUE);
     }
 
@@ -156,7 +155,7 @@
      */
     public DerInputStream subStream(int len, boolean do_skip)
     throws IOException {
-        DerInputBuffer  newbuf = buffer.dup();
+        DerInputBuffer newbuf = buffer.dup();
 
         newbuf.truncate(len);
         if (do_skip) {
@@ -399,7 +398,8 @@
            dis.readFully(indefData, offset, readLen);
            dis.close();
            DerIndefLenConverter derIn = new DerIndefLenConverter();
-           buffer = new DerInputBuffer(derIn.convert(indefData));
+           buffer = new DerInputBuffer(derIn.convert(indefData), buffer.allowBER);
+
            if (tag != buffer.read())
                 throw new IOException("Indefinite length encoding" +
                         " not supported");
@@ -427,7 +427,7 @@
         DerValue value;
 
         do {
-            value = new DerValue(newstr.buffer);
+            value = new DerValue(newstr.buffer, buffer.allowBER);
             vec.addElement(value);
         } while (newstr.available() > 0);
 
--- a/jdk/src/java.base/share/classes/sun/security/util/DerValue.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/DerValue.java	Wed Jul 05 23:09:40 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
@@ -225,6 +225,16 @@
         data = init(stringTag, value);
     }
 
+    // Creates a DerValue from a tag and some DER-encoded data w/ additional
+    // arg to control whether DER checks are enforced.
+    DerValue(byte tag, byte[] data, boolean allowBER) {
+        this.tag = tag;
+        buffer = new DerInputBuffer(data.clone(), allowBER);
+        length = data.length;
+        this.data = new DerInputStream(buffer);
+        this.data.mark(Integer.MAX_VALUE);
+    }
+
     /**
      * Creates a DerValue from a tag and some DER-encoded data.
      *
@@ -232,20 +242,16 @@
      * @param data the DER-encoded data
      */
     public DerValue(byte tag, byte[] data) {
-        this.tag = tag;
-        buffer = new DerInputBuffer(data.clone());
-        length = data.length;
-        this.data = new DerInputStream(buffer);
-        this.data.mark(Integer.MAX_VALUE);
+        this(tag, data, true);
     }
 
     /*
      * package private
      */
     DerValue(DerInputBuffer in) throws IOException {
+
         // XXX must also parse BER-encoded constructed
         // values such as sequences, sets...
-
         tag = (byte)in.read();
         byte lenByte = (byte)in.read();
         length = DerInputStream.getLength(lenByte, in);
@@ -260,7 +266,7 @@
             dis.readFully(indefData, offset, readLen);
             dis.close();
             DerIndefLenConverter derIn = new DerIndefLenConverter();
-            inbuf = new DerInputBuffer(derIn.convert(indefData));
+            inbuf = new DerInputBuffer(derIn.convert(indefData), in.allowBER);
             if (tag != inbuf.read())
                 throw new IOException
                         ("Indefinite length encoding not supported");
@@ -282,6 +288,12 @@
         }
     }
 
+    // Get an ASN.1/DER encoded datum from a buffer w/ additional
+    // arg to control whether DER checks are enforced.
+    DerValue(byte[] buf, boolean allowBER) throws IOException {
+        data = init(true, new ByteArrayInputStream(buf), allowBER);
+    }
+
     /**
      * Get an ASN.1/DER encoded datum from a buffer.  The
      * entire buffer must hold exactly one datum, including
@@ -290,7 +302,14 @@
      * @param buf buffer holding a single DER-encoded datum.
      */
     public DerValue(byte[] buf) throws IOException {
-        data = init(true, new ByteArrayInputStream(buf));
+        this(buf, true);
+    }
+
+    // Get an ASN.1/DER encoded datum from part of a buffer w/ additional
+    // arg to control whether DER checks are enforced.
+    DerValue(byte[] buf, int offset, int len, boolean allowBER)
+        throws IOException {
+        data = init(true, new ByteArrayInputStream(buf, offset, len), allowBER);
     }
 
     /**
@@ -303,7 +322,13 @@
      * @param len how many bytes are in the encoded datum
      */
     public DerValue(byte[] buf, int offset, int len) throws IOException {
-        data = init(true, new ByteArrayInputStream(buf, offset, len));
+        this(buf, offset, len, true);
+    }
+
+    // Get an ASN1/DER encoded datum from an input stream w/ additional
+    // arg to control whether DER checks are enforced.
+    DerValue(InputStream in, boolean allowBER) throws IOException {
+        data = init(false, in, allowBER);
     }
 
     /**
@@ -316,10 +341,11 @@
      *  which may be followed by additional data
      */
     public DerValue(InputStream in) throws IOException {
-        data = init(false, in);
+        this(in, true);
     }
 
-    private DerInputStream init(byte stringTag, String value) throws IOException {
+    private DerInputStream init(byte stringTag, String value)
+        throws IOException {
         String enc = null;
 
         tag = stringTag;
@@ -347,7 +373,7 @@
 
         byte[] buf = value.getBytes(enc);
         length = buf.length;
-        buffer = new DerInputBuffer(buf);
+        buffer = new DerInputBuffer(buf, true);
         DerInputStream result = new DerInputStream(buffer);
         result.mark(Integer.MAX_VALUE);
         return result;
@@ -356,8 +382,8 @@
     /*
      * helper routine
      */
-    private DerInputStream init(boolean fullyBuffered, InputStream in)
-            throws IOException {
+    private DerInputStream init(boolean fullyBuffered, InputStream in,
+        boolean allowBER) throws IOException {
 
         tag = (byte)in.read();
         byte lenByte = (byte)in.read();
@@ -384,7 +410,7 @@
 
         byte[] bytes = IOUtils.readFully(in, length, true);
 
-        buffer = new DerInputBuffer(bytes);
+        buffer = new DerInputBuffer(bytes, allowBER);
         return new DerInputStream(buffer);
     }
 
@@ -479,7 +505,8 @@
         if (buffer.read(bytes) != length)
             throw new IOException("short read on DerValue buffer");
         if (isConstructed()) {
-            DerInputStream in = new DerInputStream(bytes);
+            DerInputStream in = new DerInputStream(bytes, 0, bytes.length,
+                buffer.allowBER);
             bytes = null;
             while (in.available() != 0) {
                 bytes = append(bytes, in.getOctetString());
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java	Wed Jul 05 23:09:40 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	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java	Wed Jul 05 23:09:40 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/conf/security/java.security	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/conf/security/java.security	Wed Jul 05 23:09:40 2017 +0200
@@ -598,8 +598,8 @@
 #   jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048
 #
 #
-jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \
-    DSA keySize < 1024, EC keySize < 224
+jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & usage TLSServer, \
+    RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224
 
 #
 # Algorithm restrictions for signed JAR files
--- a/jdk/src/java.base/share/legal/zlib.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/legal/zlib.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,9 +1,9 @@
-## zlib v1.2.8
+## zlib v1.2.11
 
 ### zlib License
 <pre>
 
-Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
+Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
 
 This software is provided 'as-is', without any express or implied
 warranty.  In no event will the authors be held liable for any damages
--- a/jdk/src/java.base/share/native/libjava/ClassLoader.c	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/native/libjava/ClassLoader.c	Wed Jul 05 23:09:40 2017 +0200
@@ -72,23 +72,9 @@
     return utfStr;
 }
 
-// The existence or signature of this method is not guaranteed since it
-// supports a private method.  This method will be changed in 1.7.
-JNIEXPORT jclass JNICALL
-Java_java_lang_ClassLoader_defineClass0(JNIEnv *env,
-                                        jobject loader,
-                                        jstring name,
-                                        jbyteArray data,
-                                        jint offset,
-                                        jint length,
-                                        jobject pd)
-{
-    return Java_java_lang_ClassLoader_defineClass1(env, loader, name, data, offset,
-                                                   length, pd, NULL);
-}
-
 JNIEXPORT jclass JNICALL
 Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
+                                        jclass cls,
                                         jobject loader,
                                         jstring name,
                                         jbyteArray data,
@@ -163,6 +149,7 @@
 
 JNIEXPORT jclass JNICALL
 Java_java_lang_ClassLoader_defineClass2(JNIEnv *env,
+                                        jclass cls,
                                         jobject loader,
                                         jstring name,
                                         jobject data,
--- a/jdk/src/java.base/share/native/libjava/Module.c	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/share/native/libjava/Module.c	Wed Jul 05 23:09:40 2017 +0200
@@ -73,30 +73,32 @@
                                             jstring location, jobjectArray packages)
 {
     char** pkgs = NULL;
-    jsize idx;
     jsize num_packages = (*env)->GetArrayLength(env, packages);
 
     if (num_packages != 0 && (pkgs = calloc(num_packages, sizeof(char*))) == NULL) {
         JNU_ThrowOutOfMemoryError(env, NULL);
         return;
-    } else {
-        int valid = 1;
+    } else if ((*env)->EnsureLocalCapacity(env, (jint)num_packages) == 0) {
+        jboolean failed = JNI_FALSE;
+        int idx;
         for (idx = 0; idx < num_packages; idx++) {
             jstring pkg = (*env)->GetObjectArrayElement(env, packages, idx);
-            pkgs[idx] = GetInternalPackageName(env, pkg, NULL, 0);
-            if (pkgs[idx] == NULL) {
-                valid = 0;
+            char* name = GetInternalPackageName(env, pkg, NULL, 0);
+            if (name != NULL) {
+                pkgs[idx] = name;
+            } else {
+                failed = JNI_TRUE;
                 break;
             }
         }
-
-        if (valid != 0) {
+        if (!failed) {
             JVM_DefineModule(env, module, is_open, version, location,
-                    (const char* const*)pkgs, num_packages);
+                             (const char* const*)pkgs, num_packages);
         }
     }
 
     if (num_packages > 0) {
+        int idx;
         for (idx = 0; idx < num_packages; idx++) {
             if (pkgs[idx] != NULL) {
                 free(pkgs[idx]);
--- a/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c	Wed Jul 05 23:09:40 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
@@ -244,7 +244,8 @@
         int status;
         while (waitpid(pid, &status, 0) < 0) {
             switch (errno) {
-                case ECHILD: return 0;
+                case ECHILD:
+                    return java_lang_ProcessHandleImpl_NOT_A_CHILD; // No child
                 case EINTR: break;
                 default: return -1;
             }
@@ -269,9 +270,10 @@
         memset(&siginfo, 0, sizeof siginfo);
         while (waitid(P_PID, pid, &siginfo, options) < 0) {
             switch (errno) {
-            case ECHILD: return 0;
-            case EINTR: break;
-            default: return -1;
+                case ECHILD:
+                    return java_lang_ProcessHandleImpl_NOT_A_CHILD; // No child
+                case EINTR: break;
+                default: return -1;
             }
         }
 
--- a/jdk/src/java.datatransfer/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.datatransfer/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,8 +24,9 @@
  */
 
 /**
- * Defines an API for transferring data between and within applications.
+ * Defines the API for transferring data between and within applications.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.datatransfer {
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonBorder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonBorder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -37,7 +37,7 @@
 import com.apple.laf.AquaUtils.*;
 
 public abstract class AquaButtonBorder extends AquaBorder implements Border, UIResource {
-    public static final RecyclableSingleton<Dynamic> fDynamic = new RecyclableSingletonFromDefaultConstructor<Dynamic>(Dynamic.class);
+    private static final RecyclableSingleton<Dynamic> fDynamic = new RecyclableSingletonFromDefaultConstructor<Dynamic>(Dynamic.class);
     public static AquaButtonBorder getDynamicButtonBorder() {
         return fDynamic.get();
     }
@@ -47,12 +47,12 @@
         return fToggle.get();
     }
 
-    public static final RecyclableSingleton<Toolbar> fToolBar = new RecyclableSingletonFromDefaultConstructor<Toolbar>(Toolbar.class);
+    private static final RecyclableSingleton<Toolbar> fToolBar = new RecyclableSingletonFromDefaultConstructor<Toolbar>(Toolbar.class);
     public static Border getToolBarButtonBorder() {
         return fToolBar.get();
     }
 
-    public static final RecyclableSingleton<Named> fBevel = new RecyclableSingleton<Named>() {
+    private static final RecyclableSingleton<Named> fBevel = new RecyclableSingleton<Named>() {
         protected Named getInstance() {
             return new Named(Widget.BUTTON_BEVEL, new SizeDescriptor(new SizeVariant().alterMargins(2, 4, 2, 4)));
         }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,8 +34,8 @@
 import com.apple.laf.AquaUtils.*;
 
 public class AquaButtonCheckBoxUI extends AquaButtonLabeledUI {
-    protected static final RecyclableSingleton<AquaButtonCheckBoxUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaButtonCheckBoxUI>(AquaButtonCheckBoxUI.class);
-    protected static final RecyclableSingleton<ImageIcon> sizingIcon = new RecyclableSingleton<ImageIcon>() {
+    private static final RecyclableSingleton<AquaButtonCheckBoxUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaButtonCheckBoxUI>(AquaButtonCheckBoxUI.class);
+    private static final RecyclableSingleton<ImageIcon> sizingIcon = new RecyclableSingleton<ImageIcon>() {
         protected ImageIcon getInstance() {
             return new ImageIcon(AquaNativeResources.getRadioButtonSizerImage());
         }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java	Wed Jul 05 23:09:40 2017 +0200
@@ -138,7 +138,7 @@
         return typeDefinitions.get().get(name);
     }
 
-    protected static final RecyclableSingleton<Map<String, TypeSpecifier>> typeDefinitions = new RecyclableSingleton<Map<String, TypeSpecifier>>() {
+    private static final RecyclableSingleton<Map<String, TypeSpecifier>> typeDefinitions = new RecyclableSingleton<Map<String, TypeSpecifier>>() {
         protected Map<String, TypeSpecifier> getInstance() {
             return getAllTypes();
         }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -42,9 +42,9 @@
 import com.apple.laf.AquaUtils.RecyclableSingleton;
 
 public abstract class AquaButtonLabeledUI extends AquaButtonToggleUI implements Sizeable {
-    protected static RecyclableSizingIcon regularIcon = new RecyclableSizingIcon(18);
-    protected static RecyclableSizingIcon smallIcon = new RecyclableSizingIcon(16);
-    protected static RecyclableSizingIcon miniIcon = new RecyclableSizingIcon(14);
+    private static final RecyclableSizingIcon regularIcon = new RecyclableSizingIcon(18);
+    private static final RecyclableSizingIcon smallIcon = new RecyclableSizingIcon(16);
+    private static final RecyclableSizingIcon miniIcon = new RecyclableSizingIcon(14);
 
     protected static class RecyclableSizingIcon extends RecyclableSingleton<Icon> {
         final int iconSize;
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,8 +34,8 @@
 import com.apple.laf.AquaUtils.*;
 
 public class AquaButtonRadioUI extends AquaButtonLabeledUI {
-    protected static final RecyclableSingleton<AquaButtonRadioUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaButtonRadioUI>(AquaButtonRadioUI.class);
-    protected static final RecyclableSingleton<ImageIcon> sizingIcon = new RecyclableSingleton<ImageIcon>() {
+    private static final RecyclableSingleton<AquaButtonRadioUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaButtonRadioUI>(AquaButtonRadioUI.class);
+    private static final RecyclableSingleton<ImageIcon> sizingIcon = new RecyclableSingleton<ImageIcon>() {
         protected ImageIcon getInstance() {
             return new ImageIcon(AquaNativeResources.getRadioButtonSizerImage());
         }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -32,7 +32,7 @@
 
 public class AquaButtonToggleUI extends AquaButtonUI {
     // Create PLAF
-    static final RecyclableSingleton<AquaButtonToggleUI> aquaToggleButtonUI = new RecyclableSingletonFromDefaultConstructor<AquaButtonToggleUI>(AquaButtonToggleUI.class);
+    private static final RecyclableSingleton<AquaButtonToggleUI> aquaToggleButtonUI = new RecyclableSingletonFromDefaultConstructor<AquaButtonToggleUI>(AquaButtonToggleUI.class);
     public static ComponentUI createUI(final JComponent b) {
         return aquaToggleButtonUI.get();
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -48,7 +48,7 @@
     private static final String BUTTON_TYPE = "JButton.buttonType";
     private static final String SEGMENTED_BUTTON_POSITION = "JButton.segmentPosition";
 
-    protected static final RecyclableSingleton<AquaButtonUI> buttonUI = new RecyclableSingletonFromDefaultConstructor<AquaButtonUI>(AquaButtonUI.class);
+    private static final RecyclableSingleton<AquaButtonUI> buttonUI = new RecyclableSingletonFromDefaultConstructor<AquaButtonUI>(AquaButtonUI.class);
     public static ComponentUI createUI(final JComponent c) {
         return buttonUI.get();
     }
@@ -462,7 +462,7 @@
         return d;
     }
 
-    static final RecyclableSingleton<AquaHierarchyButtonListener> fHierListener = new RecyclableSingletonFromDefaultConstructor<AquaHierarchyButtonListener>(AquaHierarchyButtonListener.class);
+    private static final RecyclableSingleton<AquaHierarchyButtonListener> fHierListener = new RecyclableSingletonFromDefaultConstructor<AquaHierarchyButtonListener>(AquaHierarchyButtonListener.class);
     static AquaHierarchyButtonListener getAquaHierarchyButtonListener() {
         return fHierListener.get();
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java	Wed Jul 05 23:09:40 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
@@ -25,18 +25,29 @@
 
 package com.apple.laf;
 
-import java.awt.*;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
 import java.awt.Insets;
+import java.awt.Point;
 import java.awt.Rectangle;
-import java.awt.event.*;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
 
-import javax.swing.*;
+import javax.swing.Box;
+import javax.swing.JComboBox;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+import javax.swing.SwingUtilities;
 import javax.swing.plaf.basic.BasicComboPopup;
 
 import sun.lwawt.macosx.CPlatformWindow;
 
 @SuppressWarnings("serial") // Superclass is not serializable across versions
-class AquaComboBoxPopup extends BasicComboPopup {
+final class AquaComboBoxPopup extends BasicComboPopup {
     static final int FOCUS_RING_PAD_LEFT = 6;
     static final int FOCUS_RING_PAD_RIGHT = 6;
     static final int FOCUS_RING_PAD_BOTTOM = 5;
@@ -201,9 +212,6 @@
         //System.err.println("GetBestScreenBounds p: "+ p.x + ", " + p.y);
         final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
         final GraphicsDevice[] gs = ge.getScreenDevices();
-        //System.err.println("  gs.length = " + gs.length);
-        final Rectangle comboBoxBounds = comboBox.getBounds();
-
         for (final GraphicsDevice gd : gs) {
             final GraphicsConfiguration[] gc = gd.getConfigurations();
             for (final GraphicsConfiguration element0 : gc) {
@@ -215,15 +223,14 @@
         }
 
         // Hmm.  Origin's off screen, but is any part on?
+        final Rectangle comboBoxBounds = comboBox.getBounds();
         comboBoxBounds.setLocation(p);
         for (final GraphicsDevice gd : gs) {
             final GraphicsConfiguration[] gc = gd.getConfigurations();
             for (final GraphicsConfiguration element0 : gc) {
                 final Rectangle gcBounds = element0.getBounds();
                 if (gcBounds.intersects(comboBoxBounds)) {
-                    if (gcBounds.contains(p)) {
-                        return getAvailableScreenArea(gcBounds, element0);
-                    }
+                    return getAvailableScreenArea(gcBounds, element0);
                 }
             }
         }
@@ -234,8 +241,15 @@
     private Rectangle getAvailableScreenArea(Rectangle bounds,
                                              GraphicsConfiguration gc) {
         Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
-        return new Rectangle(0, insets.top, bounds.width,
-                bounds.height - insets.top);
+        return new Rectangle(bounds.x + insets.left, bounds.y + insets.top,
+                             bounds.width - insets.left - insets.right,
+                             bounds.height - insets.top - insets.bottom);
+    }
+
+    private int getComboBoxEdge(int py, boolean bottom) {
+        int offset = bottom ? 9 : -9;
+        // if py is less than new y we have a clipped combo, so leave it alone.
+        return Math.min((py / 2) + offset, py);
     }
 
     @Override
@@ -246,7 +260,7 @@
         if (isPopdown && !isTableCellEditor) {
             // place the popup just below the button, which is
             // near the center of a large combo box
-            py = Math.min((py / 2) + 9, py); // if py is less than new y we have a clipped combo, so leave it alone.
+            py = getComboBoxEdge(py, true);
         }
 
         // px & py are relative to the combo box
@@ -291,8 +305,12 @@
         // Make sure it's all on the screen - shift it by the amount it's off
         p.x += px;
         p.y += py; // Screen location of px & py
-        if (p.x < scrBounds.x) px -= (p.x + scrBounds.x);
-        if (p.y < scrBounds.y) py -= (p.y + scrBounds.y);
+        if (p.x < scrBounds.x) {
+            px = px + (scrBounds.x - p.x);
+        }
+        if (p.y < scrBounds.y) {
+            py = py + (scrBounds.y - p.y);
+        }
 
         final Point top = new Point(0, 0);
         SwingUtilities.convertPointFromScreen(top, comboBox);
@@ -324,22 +342,27 @@
         }
 
         final Rectangle r = new Rectangle(px, py, pw, ph);
-        if (py + ph > scrBounds.y + scrBounds.height) {
-            if (ph <= -scrBounds.y ) {
-                // popup goes above
-                r.y = -ph ;
-            } else {
-                // a full screen height popup
-                r.y = scrBounds.y + Math.max(0, (scrBounds.height - ph) / 2 );
-                r.height = Math.min(scrBounds.height, ph);
-            }
+        if (r.y + r.height < top.y + scrBounds.y + scrBounds.height) {
+            return r;
+        }
+        // Check whether it goes below the bottom of the screen, if so flip it
+        int newY = getComboBoxEdge(comboBoxBounds.height, false) - ph - comboBoxInsets.top;
+        if (newY > top.y + scrBounds.y) {
+            return new Rectangle(px, newY, r.width, r.height);
+        } else {
+            // There are no place at top, move popup to the center of the screen
+            r.y = top.y + scrBounds.y + Math.max(0, (scrBounds.height - ph) / 2 );
+            r.height = Math.min(scrBounds.height, ph);
         }
         return r;
     }
 
     // The one to use when itemCount <= maxRowCount.  Size never adjusts for arrows
     // We want it positioned so the selected item is right above the combo box
-    protected Rectangle computePopupBoundsForMenu(final int px, final int py, final int pw, final int ph, final int itemCount, final Rectangle scrBounds) {
+    protected Rectangle computePopupBoundsForMenu(final int px, final int py,
+                                                  final int pw, final int ph,
+                                                  final int itemCount,
+                                                  final Rectangle scrBounds) {
         //System.err.println("computePopupBoundsForMenu: " + px + "," + py + " " +  pw + "," + ph);
         //System.err.println("itemCount: " +itemCount +" src: "+ scrBounds);
         int elementSize = 0; //kDefaultItemSize;
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -594,7 +594,7 @@
     }
 
     @SuppressWarnings("unchecked")
-    static final RecyclableSingleton<ClientPropertyApplicator<JComboBox<?>, AquaComboBoxUI>> APPLICATOR = new
+    private static final RecyclableSingleton<ClientPropertyApplicator<JComboBox<?>, AquaComboBoxUI>> APPLICATOR = new
             RecyclableSingleton<ClientPropertyApplicator<JComboBox<?>, AquaComboBoxUI>>() {
         @Override
         protected ClientPropertyApplicator<JComboBox<?>, AquaComboBoxUI> getInstance() {
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java	Wed Jul 05 23:09:40 2017 +0200
@@ -75,7 +75,7 @@
     private static native int getNativeLSInfo(final byte[] pathBytes, final boolean isDirectory);
     private static native String getNativePathForResolvedAlias(final byte[] absolutePath, final boolean isDirectory);
 
-    static final RecyclableSingleton<String> machineName = new RecyclableSingleton<String>() {
+    private static final RecyclableSingleton<String> machineName = new RecyclableSingleton<String>() {
         @Override
         protected String getInstance() {
             return getNativeMachineName();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -35,17 +35,17 @@
 import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
 
 public abstract class AquaGroupBorder extends AquaBorder {
-    static final RecyclableSingletonFromDefaultConstructor<? extends Border> tabbedPaneGroupBorder = new RecyclableSingletonFromDefaultConstructor<TabbedPane>(TabbedPane.class);
+    private static final RecyclableSingletonFromDefaultConstructor<? extends Border> tabbedPaneGroupBorder = new RecyclableSingletonFromDefaultConstructor<TabbedPane>(TabbedPane.class);
     public static Border getTabbedPaneGroupBorder() {
         return tabbedPaneGroupBorder.get();
     }
 
-    static final RecyclableSingletonFromDefaultConstructor<? extends Border> titleBorderGroupBorder = new RecyclableSingletonFromDefaultConstructor<Titled>(Titled.class);
+    private static final RecyclableSingletonFromDefaultConstructor<? extends Border> titleBorderGroupBorder = new RecyclableSingletonFromDefaultConstructor<Titled>(Titled.class);
     public static Border getBorderForTitledBorder() {
         return titleBorderGroupBorder.get();
     }
 
-    static final RecyclableSingletonFromDefaultConstructor<? extends Border> titlelessGroupBorder = new RecyclableSingletonFromDefaultConstructor<Titleless>(Titleless.class);
+    private static final RecyclableSingletonFromDefaultConstructor<? extends Border> titlelessGroupBorder = new RecyclableSingletonFromDefaultConstructor<Titleless>(Titleless.class);
     public static Border getTitlelessBorder() {
         return titlelessGroupBorder.get();
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java	Wed Jul 05 23:09:40 2017 +0200
@@ -37,7 +37,7 @@
 import com.apple.laf.AquaUtils.RecyclableSingleton;
 
 public class AquaHighlighter extends DefaultHighlighter implements UIResource {
-    static final RecyclableSingleton<LayerPainter> instance = new RecyclableSingleton<LayerPainter>() {
+    private static final RecyclableSingleton<LayerPainter> instance = new RecyclableSingleton<LayerPainter>() {
         protected LayerPainter getInstance() {
             return new AquaHighlightPainter(null);
         }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java	Wed Jul 05 23:09:40 2017 +0200
@@ -240,14 +240,14 @@
         }
     }
 
-    protected static final NamedImageSingleton northArrow = new NamedImageSingleton("NSMenuScrollUp");
-    protected static final IconUIResourceSingleton northArrowIcon = new IconUIResourceSingleton(northArrow);
-    protected static final NamedImageSingleton southArrow = new NamedImageSingleton("NSMenuScrollDown");
-    protected static final IconUIResourceSingleton southArrowIcon = new IconUIResourceSingleton(southArrow);
-    protected static final NamedImageSingleton westArrow = new NamedImageSingleton("NSMenuSubmenuLeft");
-    protected static final IconUIResourceSingleton westArrowIcon = new IconUIResourceSingleton(westArrow);
-    protected static final NamedImageSingleton eastArrow = new NamedImageSingleton("NSMenuSubmenu");
-    protected static final IconUIResourceSingleton eastArrowIcon = new IconUIResourceSingleton(eastArrow);
+    private static final NamedImageSingleton northArrow = new NamedImageSingleton("NSMenuScrollUp");
+    private static final IconUIResourceSingleton northArrowIcon = new IconUIResourceSingleton(northArrow);
+    private static final NamedImageSingleton southArrow = new NamedImageSingleton("NSMenuScrollDown");
+    private static final IconUIResourceSingleton southArrowIcon = new IconUIResourceSingleton(southArrow);
+    private static final NamedImageSingleton westArrow = new NamedImageSingleton("NSMenuSubmenuLeft");
+    private static final IconUIResourceSingleton westArrowIcon = new IconUIResourceSingleton(westArrow);
+    private static final NamedImageSingleton eastArrow = new NamedImageSingleton("NSMenuSubmenu");
+    private static final IconUIResourceSingleton eastArrowIcon = new IconUIResourceSingleton(eastArrow);
 
     static Image getArrowImageForDirection(final int direction) {
         switch(direction) {
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -55,7 +55,7 @@
 
     private static final int kContentTester = 100; // For getting region insets
 
-    static final RecyclableSingleton<AquaInternalFrameBorder> documentWindowFrame = new RecyclableSingleton<AquaInternalFrameBorder>() {
+    private static final RecyclableSingleton<AquaInternalFrameBorder> documentWindowFrame = new RecyclableSingleton<AquaInternalFrameBorder>() {
         protected AquaInternalFrameBorder getInstance() {
             return new AquaInternalFrameBorder(WindowType.DOCUMENT);
         }
@@ -64,7 +64,7 @@
         return documentWindowFrame.get();
     }
 
-    static final RecyclableSingleton<AquaInternalFrameBorder> utilityWindowFrame = new RecyclableSingleton<AquaInternalFrameBorder>() {
+    private static final RecyclableSingleton<AquaInternalFrameBorder> utilityWindowFrame = new RecyclableSingleton<AquaInternalFrameBorder>() {
         protected AquaInternalFrameBorder getInstance() {
             return new AquaInternalFrameBorder(WindowType.UTILITY);
         }
@@ -73,7 +73,7 @@
         return utilityWindowFrame.get();
     }
 
-    static final RecyclableSingleton<AquaInternalFrameBorder> dialogWindowFrame = new RecyclableSingleton<AquaInternalFrameBorder>() {
+    private static final RecyclableSingleton<AquaInternalFrameBorder> dialogWindowFrame = new RecyclableSingleton<AquaInternalFrameBorder>() {
         protected AquaInternalFrameBorder getInstance() {
             return new AquaInternalFrameBorder(WindowType.DOCUMENT);
         }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -147,7 +147,7 @@
         southPane = c;
     }
 
-    static final RecyclableSingleton<Icon> closeIcon = new RecyclableSingleton<Icon>() {
+    private static final RecyclableSingleton<Icon> closeIcon = new RecyclableSingleton<Icon>() {
         @Override
         protected Icon getInstance() {
             return new AquaInternalFrameButtonIcon(Widget.TITLE_BAR_CLOSE_BOX);
@@ -157,7 +157,7 @@
         return closeIcon.get();
     }
 
-    static final RecyclableSingleton<Icon> minimizeIcon = new RecyclableSingleton<Icon>() {
+    private static final RecyclableSingleton<Icon> minimizeIcon = new RecyclableSingleton<Icon>() {
         @Override
         protected Icon getInstance() {
             return new AquaInternalFrameButtonIcon(Widget.TITLE_BAR_COLLAPSE_BOX);
@@ -167,7 +167,7 @@
         return minimizeIcon.get();
     }
 
-    static final RecyclableSingleton<Icon> zoomIcon = new RecyclableSingleton<Icon>() {
+    private static final RecyclableSingleton<Icon> zoomIcon = new RecyclableSingleton<Icon>() {
         @Override
         protected Icon getInstance() {
             return new AquaInternalFrameButtonIcon(Widget.TITLE_BAR_ZOOM_BOX);
@@ -738,7 +738,7 @@
         }
     } // end class PaletteListener
 
-    static final InternalFrameShadow documentWindowShadow = new InternalFrameShadow() {
+    private static final InternalFrameShadow documentWindowShadow = new InternalFrameShadow() {
         @Override
         Border getForegroundShadowBorder() {
             return new AquaUtils.SlicedShadowBorder(new Painter() {
@@ -778,7 +778,7 @@
         }
     };
 
-    static final InternalFrameShadow paletteWindowShadow = new InternalFrameShadow() {
+    private static final InternalFrameShadow paletteWindowShadow = new InternalFrameShadow() {
         @Override
         Border getForegroundShadowBorder() {
             return new AquaUtils.SlicedShadowBorder(new Painter() {
@@ -834,7 +834,7 @@
         }
     }
 
-    static final RecyclableSingleton<Icon> RESIZE_ICON = new RecyclableSingleton<Icon>() {
+    private static final RecyclableSingleton<Icon> RESIZE_ICON = new RecyclableSingleton<Icon>() {
         @Override
         protected Icon getInstance() {
             return new AquaIcon.ScalingJRSUIIcon(11, 11) {
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java	Wed Jul 05 23:09:40 2017 +0200
@@ -37,7 +37,7 @@
 import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
 
 public class AquaKeyBindings {
-    static final RecyclableSingleton<AquaKeyBindings> instance = new RecyclableSingletonFromDefaultConstructor<AquaKeyBindings>(AquaKeyBindings.class);
+    private static final RecyclableSingleton<AquaKeyBindings> instance = new RecyclableSingletonFromDefaultConstructor<AquaKeyBindings>(AquaKeyBindings.class);
     static AquaKeyBindings instance() {
         return instance.get();
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -37,7 +37,7 @@
 import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
 
 public class AquaLabelUI extends BasicLabelUI {
-    protected static final  RecyclableSingleton<AquaLabelUI> aquaLabelUI = new RecyclableSingletonFromDefaultConstructor<AquaLabelUI>(AquaLabelUI.class);
+    private static final RecyclableSingleton<AquaLabelUI> aquaLabelUI = new RecyclableSingletonFromDefaultConstructor<AquaLabelUI>(AquaLabelUI.class);
 
     public static ComponentUI createUI(final JComponent c) {
         return aquaLabelUI.get();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java	Wed Jul 05 23:09:40 2017 +0200
@@ -125,7 +125,7 @@
         return buf.toString();
     }
 
-    static final RecyclableSingleton<AquaMenuPainter> sPainter = new RecyclableSingletonFromDefaultConstructor<AquaMenuPainter>(AquaMenuPainter.class);
+    private static final RecyclableSingleton<AquaMenuPainter> sPainter = new RecyclableSingletonFromDefaultConstructor<AquaMenuPainter>(AquaMenuPainter.class);
     static AquaMenuPainter instance() {
         return sPainter.get();
     }
@@ -139,9 +139,9 @@
         protected Border getInstance() { return UIManager.getBorder(borderName); }
     }
 
-    protected final RecyclableBorder menuBarPainter = new RecyclableBorder("MenuBar.backgroundPainter");
-    protected final RecyclableBorder selectedMenuBarItemPainter = new RecyclableBorder("MenuBar.selectedBackgroundPainter");
-    protected final RecyclableBorder selectedMenuItemPainter = new RecyclableBorder("MenuItem.selectedBackgroundPainter");
+    private static final RecyclableBorder menuBarPainter = new RecyclableBorder("MenuBar.backgroundPainter");
+    private static final RecyclableBorder selectedMenuBarItemPainter = new RecyclableBorder("MenuBar.selectedBackgroundPainter");
+    private static final RecyclableBorder selectedMenuItemPainter = new RecyclableBorder("MenuItem.selectedBackgroundPainter");
 
     public void paintMenuBarBackground(final Graphics g, final int width, final int height, final JComponent c) {
         g.setColor(c == null ? Color.white : c.getBackground());
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMnemonicHandler.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMnemonicHandler.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,7 +34,7 @@
 import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
 
 public class AquaMnemonicHandler {
-    static final RecyclableSingleton<AltProcessor> altProcessor = new RecyclableSingletonFromDefaultConstructor<AltProcessor>(AltProcessor.class);
+    private static final RecyclableSingleton<AltProcessor> altProcessor = new RecyclableSingletonFromDefaultConstructor<AltProcessor>(AltProcessor.class);
     public static KeyEventPostProcessor getInstance() {
         return altProcessor.get();
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java	Wed Jul 05 23:09:40 2017 +0200
@@ -54,7 +54,7 @@
         }
     }
 
-    static final RecyclableSingleton<Color> sBackgroundColor = new RecyclableSingleton<Color>() {
+    private static final RecyclableSingleton<Color> sBackgroundColor = new RecyclableSingleton<Color>() {
         @Override
         protected Color getInstance() {
             final long backgroundID = getWindowBackgroundColor();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -35,7 +35,7 @@
 import java.awt.Graphics;
 
 public class AquaPanelUI extends BasicPanelUI {
-    static RecyclableSingleton<AquaPanelUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaPanelUI>(AquaPanelUI.class);
+    private static final RecyclableSingleton<AquaPanelUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaPanelUI>(AquaPanelUI.class);
 
     public static ComponentUI createUI(final JComponent c) {
         return instance.get();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,7 +34,7 @@
 import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
 
 public class AquaPopupMenuSeparatorUI extends BasicSeparatorUI {
-    protected static RecyclableSingletonFromDefaultConstructor<AquaPopupMenuSeparatorUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaPopupMenuSeparatorUI>(AquaPopupMenuSeparatorUI.class);
+    private static final RecyclableSingletonFromDefaultConstructor<AquaPopupMenuSeparatorUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaPopupMenuSeparatorUI>(AquaPopupMenuSeparatorUI.class);
 
     public static ComponentUI createUI(final JComponent c) {
         return instance.get();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -46,7 +46,7 @@
 public class AquaProgressBarUI extends ProgressBarUI implements ChangeListener, PropertyChangeListener, AncestorListener, Sizeable {
     private static final boolean ADJUSTTIMER = true;
 
-    protected static final RecyclableSingleton<SizeDescriptor> sizeDescriptor = new RecyclableSingleton<SizeDescriptor>() {
+    private static final RecyclableSingleton<SizeDescriptor> sizeDescriptor = new RecyclableSingleton<SizeDescriptor>() {
         @Override
         protected SizeDescriptor getInstance() {
             return new SizeDescriptor(new SizeVariant(146, 20)) {
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -154,7 +154,7 @@
         return State.ACTIVE;
     }
 
-    static final RecyclableSingleton<Map<Hit, ScrollBarPart>> hitToPressedPartMap = new RecyclableSingleton<Map<Hit,ScrollBarPart>>(){
+    private static final RecyclableSingleton<Map<Hit, ScrollBarPart>> hitToPressedPartMap = new RecyclableSingleton<Map<Hit,ScrollBarPart>>(){
         @Override
         protected Map<Hit, ScrollBarPart> getInstance() {
             final Map<Hit, ScrollBarPart> map = new HashMap<Hit, ScrollBarPart>(7);
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -40,7 +40,7 @@
 import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
 
 public class AquaScrollRegionBorder extends AquaBorder {
-    static final RecyclableSingletonFromDefaultConstructor<AquaScrollRegionBorder> instance = new RecyclableSingletonFromDefaultConstructor<AquaScrollRegionBorder>(AquaScrollRegionBorder.class);
+    private static final RecyclableSingletonFromDefaultConstructor<AquaScrollRegionBorder> instance = new RecyclableSingletonFromDefaultConstructor<AquaScrollRegionBorder>(AquaScrollRegionBorder.class);
 
     public static AquaScrollRegionBorder getScrollRegionBorder() {
         return instance.get();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -45,7 +45,7 @@
 //    static final Dimension roundThumbSize = new Dimension(21 + 4, 21 + 4); // +2px on both sides for focus fuzz
 //    static final Dimension pointingThumbSize = new Dimension(19 + 4, 22 + 4);
 
-    protected static final RecyclableSingleton<SizeDescriptor> roundThumbDescriptor = new RecyclableSingleton<SizeDescriptor>() {
+    private static final RecyclableSingleton<SizeDescriptor> roundThumbDescriptor = new RecyclableSingleton<SizeDescriptor>() {
         protected SizeDescriptor getInstance() {
             return new SizeDescriptor(new SizeVariant(25, 25)) {
                 public SizeVariant deriveSmall(final SizeVariant v) {
@@ -57,7 +57,7 @@
             };
         }
     };
-    protected static final RecyclableSingleton<SizeDescriptor> pointingThumbDescriptor = new RecyclableSingleton<SizeDescriptor>() {
+    private static final RecyclableSingleton<SizeDescriptor> pointingThumbDescriptor = new RecyclableSingleton<SizeDescriptor>() {
         protected SizeDescriptor getInstance() {
             return new SizeDescriptor(new SizeVariant(23, 26)) {
                 public SizeVariant deriveSmall(final SizeVariant v) {
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -126,7 +126,7 @@
         return State.ACTIVE;
     }
 
-    static final RecyclableSingleton<Border> alternateBorder = new RecyclableSingleton<Border>() {
+    private static final RecyclableSingleton<Border> alternateBorder = new RecyclableSingleton<Border>() {
         @Override
         protected Border getInstance() {
             return BorderFactory.createRaisedBevelBorder();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -67,7 +67,7 @@
         super.uninstallDefaults();
     }
 
-    static final RecyclableSingleton<ClientPropertyApplicator<JTableHeader, JTableHeader>> TABLE_HEADER_APPLICATORS = new RecyclableSingleton<ClientPropertyApplicator<JTableHeader, JTableHeader>>() {
+    private static final RecyclableSingleton<ClientPropertyApplicator<JTableHeader, JTableHeader>> TABLE_HEADER_APPLICATORS = new RecyclableSingleton<ClientPropertyApplicator<JTableHeader, JTableHeader>>() {
         @Override
         @SuppressWarnings("unchecked")
         protected ClientPropertyApplicator<JTableHeader, JTableHeader> getInstance() {
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -36,7 +36,7 @@
 import com.apple.laf.AquaUtils.*;
 
 public class AquaTextFieldBorder extends AquaBorder {
-    protected static final RecyclableSingleton<AquaTextFieldBorder> instance = new RecyclableSingletonFromDefaultConstructor<AquaTextFieldBorder>(AquaTextFieldBorder.class);
+    private static final RecyclableSingleton<AquaTextFieldBorder> instance = new RecyclableSingletonFromDefaultConstructor<AquaTextFieldBorder>(AquaTextFieldBorder.class);
     public static AquaTextFieldBorder getTextFieldBorder() {
         return instance.get();
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java	Wed Jul 05 23:09:40 2017 +0200
@@ -90,7 +90,7 @@
         return (c.getClientProperty(FIND_POPUP_KEY) instanceof JPopupMenu);
     }
 
-    protected static final RecyclableSingleton<SearchFieldBorder> instance = new RecyclableSingletonFromDefaultConstructor<SearchFieldBorder>(SearchFieldBorder.class);
+    private static final RecyclableSingleton<SearchFieldBorder> instance = new RecyclableSingletonFromDefaultConstructor<SearchFieldBorder>(SearchFieldBorder.class);
     public static SearchFieldBorder getSearchTextFieldBorder() {
         return instance.get();
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -38,7 +38,7 @@
 import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
 
 public class AquaTextPasswordFieldUI extends AquaTextFieldUI {
-    static final RecyclableSingleton<CapsLockSymbolPainter> capsLockPainter = new RecyclableSingletonFromDefaultConstructor<CapsLockSymbolPainter>(CapsLockSymbolPainter.class);
+    private static final RecyclableSingleton<CapsLockSymbolPainter> capsLockPainter = new RecyclableSingletonFromDefaultConstructor<CapsLockSymbolPainter>(CapsLockSymbolPainter.class);
     static CapsLockSymbolPainter getCapsLockPainter() {
         return capsLockPainter.get();
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,7 +34,7 @@
 import com.apple.laf.AquaUtils.*;
 
 public class AquaToolBarSeparatorUI extends BasicToolBarSeparatorUI {
-    protected static RecyclableSingleton<AquaToolBarSeparatorUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaToolBarSeparatorUI>(AquaToolBarSeparatorUI.class);
+    private static final RecyclableSingleton<AquaToolBarSeparatorUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaToolBarSeparatorUI>(AquaToolBarSeparatorUI.class);
 
     public static ComponentUI createUI(final JComponent c) {
         return instance.get();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -35,7 +35,7 @@
 import com.apple.laf.AquaUtils.*;
 
 public class AquaToolBarUI extends BasicToolBarUI implements SwingConstants {
-    private static RecyclableSingleton<ToolBarBorder> toolBarBorder = new RecyclableSingletonFromDefaultConstructor<ToolBarBorder>(ToolBarBorder.class);
+    private static final RecyclableSingleton<ToolBarBorder> toolBarBorder = new RecyclableSingletonFromDefaultConstructor<ToolBarBorder>(ToolBarBorder.class);
     public static Border getToolBarBorder() {
         return toolBarBorder.get();
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,7 +34,7 @@
 import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
 
 public class AquaToolTipUI extends BasicToolTipUI {
-    static final RecyclableSingletonFromDefaultConstructor<AquaToolTipUI> sharedAquaInstance = new RecyclableSingletonFromDefaultConstructor<AquaToolTipUI>(AquaToolTipUI.class);
+    private static final RecyclableSingletonFromDefaultConstructor<AquaToolTipUI> sharedAquaInstance = new RecyclableSingletonFromDefaultConstructor<AquaToolTipUI>(AquaToolTipUI.class);
 
     public static ComponentUI createUI(final JComponent c) {
         return sharedAquaInstance.get();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java	Wed Jul 05 23:09:40 2017 +0200
@@ -49,7 +49,7 @@
         void applySizeFor(final JComponent c, final Size size);
     }
 
-    protected static final RecyclableSingleton<PropertySizeListener> sizeListener
+    private static final RecyclableSingleton<PropertySizeListener> sizeListener
             = new RecyclableSingletonFromDefaultConstructor<>(PropertySizeListener.class);
     protected static PropertySizeListener getSizeListener() {
         return sizeListener.get();
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m	Wed Jul 05 23:09:40 2017 +0200
@@ -284,28 +284,21 @@
     CGFloat components[component_size];
     CGGradientRef gradient = NULL;
 
-    for (int i = 0; i < num_locations; i++) {
+    for (i = 0; i < num_locations; i++) {
         locations[i] = gradientInfo->fractionsdata[i];
-//fprintf(stderr, "locations[%d] %f\n", i, locations[i]);
     }
     for (i = 0; i < component_size; i++) {
         components[i] = gradientInfo->colordata[i];
-//fprintf(stderr, "components[%d] %f, gradientInfo->colordata[%d] %f\n",
-//                  i, components[i], i, gradientInfo->colordata[i]);
     } 
     CGContextSaveGState(cgRef);
     gradient = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations);
-//fprintf(stderr, "gradientInfo->start.x %f, gradientInfo->start.y %f\n", 
-//                 gradientInfo->start.x, gradientInfo->start.y);
-//fprintf(stderr, "gradientInfo->end.x %f, gradientInfo->end.y %f\n", 
-//                 gradientInfo->end.x, gradientInfo->end.y);
     if (qsdo->isEvenOddFill) {
         CGContextEOClip(cgRef);
     } else {
         CGContextClip(cgRef);
     }
     CGContextDrawLinearGradient(cgRef, gradient, gradientInfo->start, gradientInfo->end, kCGGradientDrawsAfterEndLocation);    
-    
+
     CGContextRestoreGState(cgRef);
     CGColorSpaceRelease(colorspace);
     CGGradientRelease(gradient);
@@ -332,27 +325,19 @@
     CGFloat startRadius = gradientInfo->radius;
     CGFloat endRadius = gradientInfo->radius;
 
-    for (int i = 0; i < num_locations; i++) {
+    for (i = 0; i < num_locations; i++) {
         locations[i] = gradientInfo->fractionsdata[i];
-//fprintf(stderr, "locations[%d] %f\n", i, locations[i]);
     }
     for (i = 0; i < component_size; i++) {
         components[i] = gradientInfo->colordata[i];
-//fprintf(stderr, "components[%d] %f, gradientInfo->colordata[%d] %f\n",
-//                  i, components[i], i, gradientInfo->colordata[i]);
     } 
     CGContextSaveGState(cgRef);
     gradient = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations);
-//fprintf(stderr, "gradientInfo->start.x %f, gradientInfo->start.y %f\n", 
-//                 gradientInfo->start.x, gradientInfo->start.y);
-//fprintf(stderr, "gradientInfo->end.x %f, gradientInfo->end.y %f\n", 
-//                 gradientInfo->end.x, gradientInfo->end.y);
     if (qsdo->isEvenOddFill) {
         CGContextEOClip(cgRef);
     } else {
         CGContextClip(cgRef);
     }
-//fprintf(stderr, "gradientInfo->startRadius %f, gradientInfo->endRadius %f\n",startRadius,endRadius);
     CGContextDrawRadialGradient(cgRef, gradient, gradientInfo->start, 0, gradientInfo->end, endRadius, kCGGradientDrawsAfterEndLocation);    
     
     CGContextRestoreGState(cgRef);
@@ -944,54 +929,41 @@
     if (colorArray != NULL)
     {
         jint length = (*env)->GetArrayLength(env, colorArray);
-//fprintf(stderr, "length %d\n", length);
 
         jint* jcolorData = (jint*)(*env)->GetPrimitiveArrayCritical(env, colorArray, NULL);
-        CGFloat* colors= (CGFloat*)calloc(0, sizeof(CGFloat)*length);
+        qsdo->gradientInfo->colordata = (CGFloat*)malloc(sizeof(CGFloat)*4*length);
+        memset(qsdo->gradientInfo->colordata, 0, sizeof(CGFloat)*4*length);
         if (jcolorData != NULL)
         {
-            jint i;
+            int i;
             for (i=0; i<length; i++)
             {
-                colors[i] = (CGFloat)jcolorData[i];
+                qsdo->gradientInfo->colordata[i*4] = ((jcolorData[i]>>16)&0xff)*kColorConversionMultiplier;
+
+                qsdo->gradientInfo->colordata[i*4+1] = ((jcolorData[i]>>8)&0xff)*kColorConversionMultiplier;
+
+                qsdo->gradientInfo->colordata[i*4+2] = ((jcolorData[i]>>0)&0xff)*kColorConversionMultiplier;
+
+                qsdo->gradientInfo->colordata[i*4+3] = ((jcolorData[i]>>24)&0xff)*kColorConversionMultiplier;
             }
         }
         (*env)->ReleasePrimitiveArrayCritical(env, colorArray, jcolorData, 0);
-        qsdo->gradientInfo->colordata = (CGFloat*)calloc(0, sizeof(CGFloat)*4*length);
-        for (int i = 0; i < length; i++) 
-        {
-            jint c1 = colors[i];
-//fprintf(stderr, "c1 %x\n", c1);
-            qsdo->gradientInfo->colordata[i*4] = ((c1>>16)&0xff)*kColorConversionMultiplier;
-//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4, qsdo->gradientInfo->colordata[i*4]);
-
-            qsdo->gradientInfo->colordata[i*4+1] = ((c1>>8)&0xff)*kColorConversionMultiplier;
-//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+1, qsdo->gradientInfo->colordata[i*4+1]);
-
-            qsdo->gradientInfo->colordata[i*4+2] = ((c1>>0)&0xff)*kColorConversionMultiplier;
-//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+2, qsdo->gradientInfo->colordata[i*4+2]);
-
-            qsdo->gradientInfo->colordata[i*4+3] = ((c1>>24)&0xff)*kColorConversionMultiplier;
-//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+3, qsdo->gradientInfo->colordata[i*4+3]);
-        }
-        free(colors);
     }
     jobject fractionsArray  = ((*env)->GetObjectArrayElement(env, qsdo->javaGraphicsStatesObjects, sun_java2d_OSXSurfaceData_kFractionsArrayIndex)); 
     if (fractionsArray != NULL)
     {
         jint length = (*env)->GetArrayLength(env, fractionsArray);
-//fprintf(stderr, "fractions length %d\n", length);
         qsdo->gradientInfo->fractionsLength = length;
 
         jfloat* jfractionsData = (jfloat*)(*env)->GetPrimitiveArrayCritical(env, fractionsArray, NULL);
         if (jfractionsData != NULL)
         {
+            int i;
             qsdo->gradientInfo->fractionsdata = (CGFloat *)malloc(sizeof(CGFloat) *length);
-            jint i;
+            memset(qsdo->gradientInfo->fractionsdata, 0, sizeof(CGFloat)*length);
             for (i=0; i<length; i++)
             {
                 qsdo->gradientInfo->fractionsdata[i] = jfractionsData[i];
-//fprintf(stderr, "jfrationsData[%d] %f, qsdo->gradientInfo->fractionsdata[%d] = %f\n", i, jfractionsData[i], i, qsdo->gradientInfo->fractionsdata[i]);
             }
             (*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, jfractionsData, 0);
         }
--- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java	Wed Jul 05 23:09:40 2017 +0200
@@ -274,6 +274,10 @@
     /**
      * Requests user attention to the specified window.
      *
+     * Has no effect if a window representation is not displayable in
+     * the task area. Whether it is displayable is dependent on all
+     * of window type, platform, and implementation.
+     *
      * @param w window
      * @throws SecurityException if a security manager exists and it denies the
      * {@code RuntimePermission("canProcessApplicationEvents")} permission.
@@ -375,6 +379,10 @@
      * for the specified window.
      * It may be disabled by system settings.
      *
+     * Has no effect if a window representation is not displayable in
+     * the task area. Whether it is displayable is dependent on all
+     * of window type, platform, and implementation.
+     *
      * @param w window to update
      * @param badge image to affix to the icon
      * @throws SecurityException if a security manager exists and it denies the
@@ -409,6 +417,11 @@
     /**
      * Displays a determinate progress bar in the task area for the specified
      * window.
+     *
+     * Has no effect if a window representation is not displayable in
+     * the task area. Whether it is displayable is dependent on all
+     * of window type, platform, and implementation.
+     *
      * <br>
      * The visual behavior is platform and {@link State} dependent.
      * <br>
@@ -437,6 +450,10 @@
 
     /**
      * Sets a progress state for a specified window.
+     *
+     * Has no effect if a window representation is not displayable in
+     * the task area. Whether it is displayable is dependent on all
+     * of window type, platform, and implementation.
      * <br>
      * Each state displays a progress in a platform-dependent way.
      * <br>
--- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java	Wed Jul 05 23:09:40 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
@@ -36,8 +36,6 @@
 import java.beans.PropertyChangeEvent;
 import java.awt.IllegalComponentStateException;
 
-import javax.swing.SwingContainer;
-
 /**
  * AccessibleContext represents the minimum information all accessible objects
  * return.  This information includes the accessible name, description, role,
@@ -79,7 +77,6 @@
  * @author      Lynn Monsanto
  */
 @JavaBean(description = "Minimal information that all accessible objects return")
-@SwingContainer(false)
 public abstract class AccessibleContext {
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalIconFactory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalIconFactory.java	Wed Jul 05 23:09:40 2017 +0200
@@ -33,6 +33,8 @@
 import java.util.Enumeration;
 import java.util.Vector;
 import sun.swing.CachedPainter;
+import static sun.swing.SwingUtilities2.setAntialiasingHintForScaledGraphics;
+import static sun.swing.SwingUtilities2.getAndSetAntialisingHintForScaledGraphics;
 
 /**
  * Factory object that vends <code>Icon</code>s for
@@ -1247,9 +1249,15 @@
 
         protected void drawCheck(Component c, Graphics g, int x, int y) {
             int controlSize = getControlSize();
-            g.fillRect( x+3, y+5, 2, controlSize-8 );
-            g.drawLine( x+(controlSize-4), y+3, x+5, y+(controlSize-6) );
-            g.drawLine( x+(controlSize-4), y+4, x+5, y+(controlSize-5) );
+            int csx = controlSize - 3;
+            int csy1 = controlSize - 6;
+            int csy2 = controlSize - 4;
+            int csy3 = controlSize - 3;
+            int[] xPoints = {3, 5, 5, csx, csx, 5, 5, 3};
+            int[] yPoints = {5, 5, csy1, 2, 4, csy2, csy3, csy3};
+            g.translate(x, y);
+            g.fillPolygon(xPoints, yPoints, 8);
+            g.translate(-x, -y);
         }
 
         public int getIconWidth() {
@@ -1323,8 +1331,12 @@
         }
 
         public void paintIcon(Component c, Graphics g, int x, int y) {
+
+            Object aaHint = getAndSetAntialisingHintForScaledGraphics(g);
+
             if (MetalLookAndFeel.usingOcean()) {
                 paintOceanIcon(c, g, x, y);
+                setAntialiasingHintForScaledGraphics(g, aaHint);
                 return;
             }
             JRadioButton rb = (JRadioButton)c;
@@ -1358,51 +1370,25 @@
 
             // draw Dark Circle (start at top, go clockwise)
             g.setColor(darkCircle);
-            g.drawLine( 4, 0,  7, 0);
-            g.drawLine( 8, 1,  9, 1);
-            g.drawLine(10, 2, 10, 3);
-            g.drawLine(11, 4, 11, 7);
-            g.drawLine(10, 8, 10, 9);
-            g.drawLine( 9,10,  8,10);
-            g.drawLine( 7,11,  4,11);
-            g.drawLine( 3,10,  2,10);
-            g.drawLine( 1, 9,  1, 8);
-            g.drawLine( 0, 7,  0, 4);
-            g.drawLine( 1, 3,  1, 2);
-            g.drawLine( 2, 1,  3, 1);
+            g.drawOval(0, 0, 11, 11);
 
             // draw Inner Left (usually) White Arc
             //  start at lower left corner, go clockwise
             g.setColor(whiteInnerLeftArc);
-            g.drawLine( 2, 9,  2, 8);
-            g.drawLine( 1, 7,  1, 4);
-            g.drawLine( 2, 2,  2, 3);
-            g.drawLine( 2, 2,  3, 2);
-            g.drawLine( 4, 1,  7, 1);
-            g.drawLine( 8, 2,  9, 2);
+            g.drawArc(1, 1, 10, 10, 60, 160);
             // draw Outer Right White Arc
             //  start at upper right corner, go clockwise
             g.setColor(whiteOuterRightArc);
-            g.drawLine(10, 1, 10, 1);
-            g.drawLine(11, 2, 11, 3);
-            g.drawLine(12, 4, 12, 7);
-            g.drawLine(11, 8, 11, 9);
-            g.drawLine(10,10, 10,10);
-            g.drawLine( 9,11,  8,11);
-            g.drawLine( 7,12,  4,12);
-            g.drawLine( 3,11,  2,11);
+            g.drawArc(-1, -1, 13, 13, 235, 180);
 
             // selected dot
             if ( drawDot ) {
                 g.setColor(dotColor);
-                g.fillRect( 4, 4,  4, 4);
-                g.drawLine( 4, 3,  7, 3);
-                g.drawLine( 8, 4,  8, 7);
-                g.drawLine( 7, 8,  4, 8);
-                g.drawLine( 3, 7,  3, 4);
+                g.fillOval(2, 2, 7, 7);
             }
 
             g.translate(-x, -y);
+            setAntialiasingHintForScaledGraphics(g, aaHint);
         }
 
         public int getIconWidth() {
@@ -2051,16 +2037,17 @@
                     g.setColor( b.getForeground() );
                 }
             }
-            if( MetalUtils.isLeftToRight(b) ) {
-                g.drawLine( 0, 0, 0, 7 );
-                g.drawLine( 1, 1, 1, 6 );
-                g.drawLine( 2, 2, 2, 5 );
-                g.drawLine( 3, 3, 3, 4 );
+            if (MetalUtils.isLeftToRight(b)) {
+                int[] xPoints = {0, 3, 3, 0};
+                int[] yPoints = {0, 3, 4, 7};
+                g.fillPolygon(xPoints, yPoints, 4);
+                g.drawPolygon(xPoints, yPoints, 4);
+
             } else {
-                g.drawLine( 4, 0, 4, 7 );
-                g.drawLine( 3, 1, 3, 6 );
-                g.drawLine( 2, 2, 2, 5 );
-                g.drawLine( 1, 3, 1, 4 );
+                int[] xPoints = {4, 4, 1, 1};
+                int[] yPoints = {0, 7, 4, 3};
+                g.fillPolygon(xPoints, yPoints, 4);
+                g.drawPolygon(xPoints, yPoints, 4);
             }
 
             g.translate( -x, -y );
@@ -2138,10 +2125,7 @@
                     g.setColor( MetalLookAndFeel.getMenuDisabledForeground());
                 }
 
-                g.drawLine( 2, 2, 2, 6 );
-                g.drawLine( 3, 2, 3, 6 );
-                g.drawLine( 4, 4, 8, 0 );
-                g.drawLine( 4, 5, 9, 0 );
+                drawCheck(g);
             }
             g.translate( -x, -y );
         }
@@ -2217,15 +2201,18 @@
                     g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
                 }
 
-                g.drawLine( 2, 2, 2, 6 );
-                g.drawLine( 3, 2, 3, 6 );
-                g.drawLine( 4, 4, 8, 0 );
-                g.drawLine( 4, 5, 9, 0 );
+                drawCheck(g);
             }
 
             g.translate( -x, -y );
         }
 
+        private void drawCheck(Graphics g) {
+            int[] xPoints = {2, 3, 3, 8, 9, 3, 2};
+            int[] yPoints = {2, 2, 5, 0, 0, 6, 6};
+            g.drawPolygon(xPoints, yPoints, 7);
+        }
+
         public int getIconWidth() { return menuCheckIconSize.width; }
 
         public int getIconHeight() { return menuCheckIconSize.height; }
@@ -2252,9 +2239,8 @@
                 else {
                     g.setColor(MetalLookAndFeel.getControlHighlight());
                 }
-                g.drawLine( 2, 9, 7, 9 );
-                g.drawLine( 9, 2, 9, 7 );
-                g.drawLine( 8, 8, 8, 8 );
+
+                g.drawArc(-1, -1, 10, 10, 245, 140);
 
                 if (isPressed || isArmed) {
                     g.setColor(MetalLookAndFeel.getControlInfo());
@@ -2266,14 +2252,8 @@
             else {
                 g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
             }
-            g.drawLine( 2, 0, 6, 0 );
-            g.drawLine( 2, 8, 6, 8 );
-            g.drawLine( 0, 2, 0, 6 );
-            g.drawLine( 8, 2, 8, 6 );
-            g.drawLine( 1, 1, 1, 1 );
-            g.drawLine( 7, 1, 7, 1 );
-            g.drawLine( 1, 7, 1, 7 );
-            g.drawLine( 7, 7, 7, 7 );
+
+            g.drawOval(0, 0, 8, 8);
 
             if (isSelected) {
                 if (isEnabled) {
@@ -2288,11 +2268,9 @@
                 else {
                     g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
                 }
-                g.drawLine( 3, 2, 5, 2 );
-                g.drawLine( 2, 3, 6, 3 );
-                g.drawLine( 2, 4, 6, 4 );
-                g.drawLine( 2, 5, 6, 5 );
-                g.drawLine( 3, 6, 5, 6 );
+
+                g.fillOval(2, 2, 4, 4);
+                g.drawOval(2, 2, 4, 4);
             }
 
             g.translate( -x, -y );
@@ -2300,8 +2278,12 @@
 
         public void paintIcon( Component c, Graphics g, int x, int y )
         {
+
+            Object aaHint = getAndSetAntialisingHintForScaledGraphics(g);
+
             if (MetalLookAndFeel.usingOcean()) {
                 paintOceanIcon(c, g, x, y);
+                setAntialiasingHintForScaledGraphics(g, aaHint);
                 return;
             }
             JMenuItem b = (JMenuItem) c;
@@ -2319,55 +2301,24 @@
                 if ( isPressed || isArmed )
                 {
                     g.setColor( MetalLookAndFeel.getPrimaryControl()  );
-                    g.drawLine( 3, 1, 8, 1 );
-                    g.drawLine( 2, 9, 7, 9 );
-                    g.drawLine( 1, 3, 1, 8 );
-                    g.drawLine( 9, 2, 9, 7 );
-                    g.drawLine( 2, 2, 2, 2 );
-                    g.drawLine( 8, 8, 8, 8 );
+                    g.drawOval(1, 1, 8, 8);
 
                     g.setColor( MetalLookAndFeel.getControlInfo()  );
-                    g.drawLine( 2, 0, 6, 0 );
-                    g.drawLine( 2, 8, 6, 8 );
-                    g.drawLine( 0, 2, 0, 6 );
-                    g.drawLine( 8, 2, 8, 6 );
-                    g.drawLine( 1, 1, 1, 1 );
-                    g.drawLine( 7, 1, 7, 1 );
-                    g.drawLine( 1, 7, 1, 7 );
-                    g.drawLine( 7, 7, 7, 7 );
+                    g.drawOval(0, 0, 8, 8);
                 }
                 else
                 {
                     g.setColor( MetalLookAndFeel.getControlHighlight()  );
-                    g.drawLine( 3, 1, 8, 1 );
-                    g.drawLine( 2, 9, 7, 9 );
-                    g.drawLine( 1, 3, 1, 8 );
-                    g.drawLine( 9, 2, 9, 7 );
-                    g.drawLine( 2, 2, 2, 2 );
-                    g.drawLine( 8, 8, 8, 8 );
+                    g.drawOval(1, 1, 8, 8);
 
                     g.setColor( MetalLookAndFeel.getControlDarkShadow()  );
-                    g.drawLine( 2, 0, 6, 0 );
-                    g.drawLine( 2, 8, 6, 8 );
-                    g.drawLine( 0, 2, 0, 6 );
-                    g.drawLine( 8, 2, 8, 6 );
-                    g.drawLine( 1, 1, 1, 1 );
-                    g.drawLine( 7, 1, 7, 1 );
-                    g.drawLine( 1, 7, 1, 7 );
-                    g.drawLine( 7, 7, 7, 7 );
+                    g.drawOval(0, 0, 8, 8);
                 }
             }
             else
             {
                 g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
-                g.drawLine( 2, 0, 6, 0 );
-                g.drawLine( 2, 8, 6, 8 );
-                g.drawLine( 0, 2, 0, 6 );
-                g.drawLine( 8, 2, 8, 6 );
-                g.drawLine( 1, 1, 1, 1 );
-                g.drawLine( 7, 1, 7, 1 );
-                g.drawLine( 1, 7, 1, 7 );
-                g.drawLine( 7, 7, 7, 7 );
+                g.drawOval(0, 0, 8, 8);
             }
 
             if ( isSelected )
@@ -2388,14 +2339,12 @@
                     g.setColor( MetalLookAndFeel.getMenuDisabledForeground()  );
                 }
 
-                g.drawLine( 3, 2, 5, 2 );
-                g.drawLine( 2, 3, 6, 3 );
-                g.drawLine( 2, 4, 6, 4 );
-                g.drawLine( 2, 5, 6, 5 );
-                g.drawLine( 3, 6, 5, 6 );
+                g.fillOval(2, 2, 4, 4);
+                g.drawOval(2, 2, 4, 4);
             }
 
             g.translate( -x, -y );
+            setAntialiasingHintForScaledGraphics(g, aaHint);
         }
 
         public int getIconWidth() { return menuCheckIconSize.width; }
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultStyledDocument.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultStyledDocument.java	Wed Jul 05 23:09:40 2017 +0200
@@ -39,6 +39,7 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.Serializable;
+import java.util.Arrays;
 import javax.swing.event.*;
 import javax.swing.undo.AbstractUndoableEdit;
 import javax.swing.undo.CannotRedoException;
@@ -1263,7 +1264,7 @@
                                   int offs, int len) {
             attr = a;
             this.type = type;
-            this.data = txt;
+            this.data = txt == null ? null : Arrays.copyOf(txt, txt.length);
             this.offs = offs;
             this.len = len;
             this.direction = OriginateDirection;
@@ -1323,7 +1324,7 @@
          * @return the array
          */
         public char[] getArray() {
-            return data;
+            return data == null ? null : Arrays.copyOf(data, data.length);
         }
 
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/StyleContext.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/StyleContext.java	Wed Jul 05 23:09:40 2017 +0200
@@ -794,7 +794,7 @@
          * @param attributes the attributes
          */
         public SmallAttributeSet(Object[] attributes) {
-            this.attributes = attributes;
+            this.attributes = Arrays.copyOf(attributes, attributes.length);
             updateResolveParent();
         }
 
--- a/jdk/src/java.desktop/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
  * Defines the AWT and Swing user interface toolkits, plus APIs for
  * accessibility, audio, imaging, printing, and JavaBeans.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.desktop {
--- a/jdk/src/java.desktop/share/classes/sun/awt/CustomCursor.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/awt/CustomCursor.java	Wed Jul 05 23:09:40 2017 +0200
@@ -66,7 +66,8 @@
 
         // Scale image to nearest supported size.
         Dimension nativeSize = toolkit.getBestCursorSize(width, height);
-        if (nativeSize.width != width || nativeSize.height != height) {
+        if ((nativeSize.width != width || nativeSize.height != height) &&
+            (nativeSize.width != 0 && nativeSize.height != 0)) {
             cursor = cursor.getScaledInstance(nativeSize.width,
                                               nativeSize.height,
                                               Image.SCALE_DEFAULT);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/print/DialogOnTop.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.print;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.PrintRequestAttribute;
+
+/*
+ * An implementation class used to request the dialog be set always-on-top.
+ * It needs to be read and honoured by the dialog code which will use
+ * java.awt.Window.setAlwaysOnTop(true) in cases where it is supported.
+ */
+public class DialogOnTop implements PrintRequestAttribute {
+
+    private static final long serialVersionUID = -1901909867156076547L;
+
+    long id;
+
+    public DialogOnTop() {
+    }
+
+    public DialogOnTop(long id) {
+        this.id = id;
+    }
+
+    public final Class<? extends Attribute> getCategory() {
+        return DialogOnTop.class;
+    }
+
+    public long getID() {
+        return id;
+    }
+
+    public final String getName() {
+        return "dialog-on-top";
+    }
+
+    public String toString() {
+       return "dialog-on-top";
+    }
+}
--- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Wed Jul 05 23:09:40 2017 +0200
@@ -785,7 +785,9 @@
             PrintService pservice = getPrintService();
             PageFormat pageFrmAttrib = attributeToPageFormat(pservice,
                                                              attributes);
+            setParentWindowID(attributes);
             PageFormat page = pageDialog(pageFrmAttrib);
+            clearParentWindowID();
 
             // If user cancels the dialog, pageDialog() will return the original
             // page object and as per spec, we should return null in that case.
@@ -828,6 +830,9 @@
         int x = gcBounds.x+50;
         int y = gcBounds.y+50;
         ServiceDialog pageDialog;
+        if (onTop != null) {
+            attributes.add(onTop);
+        }
         if (w instanceof Frame) {
             pageDialog = new ServiceDialog(gc, x, y, service,
                                            DocFlavor.SERVICE_FORMATTED.PAGEABLE,
@@ -837,6 +842,7 @@
                                            DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                            attributes, (Dialog)w);
         }
+
         Rectangle dlgBounds = pageDialog.getBounds();
 
         // if portion of dialog is not within the gc boundary
@@ -923,7 +929,9 @@
 
             }
 
+            setParentWindowID(attributes);
             boolean ret = printDialog();
+            clearParentWindowID();
             this.attributes = attributes;
             return ret;
 
@@ -2539,4 +2547,26 @@
             return new String(out_chars, 0, pos);
         }
     }
+
+    private DialogOnTop onTop = null;
+
+    private long parentWindowID = 0L;
+
+    /* Called from native code */
+    private long getParentWindowID() {
+        return parentWindowID;
+    }
+
+    private void clearParentWindowID() {
+        parentWindowID = 0L;
+        onTop = null;
+    }
+
+    private void setParentWindowID(PrintRequestAttributeSet attrs) {
+        parentWindowID = 0L;
+        onTop = (DialogOnTop)attrs.get(DialogOnTop.class);
+        if (onTop != null) {
+            parentWindowID = onTop.getID();
+        }
+    }
 }
--- a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java	Wed Jul 05 23:09:40 2017 +0200
@@ -184,6 +184,9 @@
             isAWT = true;
         }
 
+        if (attributes.get(DialogOnTop.class) != null) {
+            setAlwaysOnTop(true);
+        }
         Container c = getContentPane();
         c.setLayout(new BorderLayout());
 
@@ -275,6 +278,10 @@
         this.asOriginal = attributes;
         this.asCurrent = new HashPrintRequestAttributeSet(attributes);
 
+        if (attributes.get(DialogOnTop.class) != null) {
+            setAlwaysOnTop(true);
+        }
+
         Container c = getContentPane();
         c.setLayout(new BorderLayout());
 
--- a/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Wed Jul 05 23:09:40 2017 +0200
@@ -2164,6 +2164,41 @@
         return false;
     }
 
+    /**
+     * Enables the antialiasing rendering hint for the scaled graphics and
+     * returns the previous hint value.
+     * The returned null value indicates that the passed graphics is not
+     * instance of Graphics2D.
+     *
+     * @param g the graphics
+     * @return the previous antialiasing rendering hint value if the passed
+     * graphics is instance of Graphics2D, null otherwise.
+     */
+    public static Object getAndSetAntialisingHintForScaledGraphics(Graphics g) {
+        if (isScaledGraphics(g) && isLocalDisplay()) {
+            Graphics2D g2d = (Graphics2D) g;
+            Object hint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                    RenderingHints.VALUE_ANTIALIAS_ON);
+            return hint;
+        }
+        return null;
+    }
+
+    /**
+     * Sets the antialiasing rendering hint if its value is not null.
+     * Null hint value indicates that the passed graphics is not instance of
+     * Graphics2D.
+     *
+     * @param g the graphics
+     * @param hint the antialiasing rendering hint
+     */
+    public static void setAntialiasingHintForScaledGraphics(Graphics g, Object hint) {
+        if (hint != null) {
+            ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, hint);
+        }
+    }
+
     public static boolean isFloatingPointScale(AffineTransform tx) {
         int type = tx.getType() & ~(TYPE_FLIP | TYPE_TRANSLATION);
         if (type == 0) {
--- a/jdk/src/java.desktop/share/legal/colorimaging.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/legal/colorimaging.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,7 @@
 ## Eastman Kodak Company: Kodak Color Management System (kcms) and portions of color management and imaging software
 
-### Notice
+### Eastman Kodak Notice
+<pre>
+Portions Copyright Eastman Kodak Company 1991-2003
+</pre>
 
-Portions Copyright Eastman Kodak Company 1991-2003
--- a/jdk/src/java.desktop/share/legal/jpeg.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/legal/jpeg.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,4 +1,4 @@
-## JPEG rb6
+## JPEG release 6b
 
 ### JPEG License
 <pre>
--- a/jdk/src/java.desktop/share/legal/libpng.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/legal/libpng.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
-## Libpng v 1.6.23
+## libpng v1.6.23
 
-### Libpng License
+### libpng License
 <pre>
 
 This copy of the libpng notices is provided for your convenience.  In case of
--- a/jdk/src/java.desktop/share/legal/mesa3d.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/share/legal/mesa3d.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 ## Mesa 3-D Graphics Library v4.1
 
-### Mesa 3-D Graphics Library License
+### Mesa License
 <pre>
 
 Mesa 3-D graphics library
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java	Wed Jul 05 23:09:40 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
@@ -25,17 +25,34 @@
 
 package sun.awt.X11;
 
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.peer.TrayIconPeer;
-import sun.awt.*;
-
-import java.awt.image.*;
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.GridLayout;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Label;
+import java.awt.MouseInfo;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.text.BreakIterator;
 import java.util.concurrent.ArrayBlockingQueue;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.lang.reflect.InvocationTargetException;
+
+import sun.awt.SunToolkit;
 
 /**
  * An utility window class. This is a base class for Tooltip and Balloon.
@@ -81,16 +98,16 @@
         Dimension size = getSize();
         Rectangle scrSize = getGraphicsConfiguration().getBounds();
 
-        if (corner.x < scrSize.width/2 && corner.y < scrSize.height/2) { // 1st square
+        if (corner.x < scrSize.x + scrSize.width/2 && corner.y < scrSize.y + scrSize.height/2) { // 1st square
             setLocation(corner.x + indent, corner.y + indent);
 
-        } else if (corner.x >= scrSize.width/2 && corner.y < scrSize.height/2) { // 2nd square
+        } else if (corner.x >= scrSize.x + scrSize.width/2 && corner.y < scrSize.y + scrSize.height/2) { // 2nd square
             setLocation(corner.x - indent - size.width, corner.y + indent);
 
-        } else if (corner.x < scrSize.width/2 && corner.y >= scrSize.height/2) { // 3rd square
+        } else if (corner.x < scrSize.x + scrSize.width/2 && corner.y >= scrSize.y + scrSize.height/2) { // 3rd square
             setLocation(corner.x + indent, corner.y - indent - size.height);
 
-        } else if (corner.x >= scrSize.width/2 && corner.y >= scrSize.height/2) { // 4th square
+        } else if (corner.x >= scrSize.x +scrSize.width/2 && corner.y >= scrSize.y +scrSize.height/2) { // 4th square
             setLocation(corner.x - indent - size.width, corner.y - indent - size.height);
         }
 
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java	Wed Jul 05 23:09:40 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
@@ -25,17 +25,15 @@
 package sun.awt.X11;
 
 import java.awt.*;
-import java.awt.peer.*;
 import java.awt.event.*;
-import java.awt.image.ColorModel;
 
 import sun.awt.*;
 
+import java.awt.peer.ComponentPeer;
 import java.util.ArrayList;
 import java.util.Vector;
 import sun.util.logging.PlatformLogger;
 import sun.java2d.SurfaceData;
-import sun.java2d.SunGraphics2D;
 
 /**
  * The abstract class XBaseMenuWindow is the superclass
@@ -656,28 +654,37 @@
      *
      ************************************************/
 
+    GraphicsConfiguration getCurrentGraphicsConfiguration() {
+        Component hw = SunToolkit.getHeavyweightComponent(target);
+        XWindow peer = AWTAccessor.getComponentAccessor().getPeer(hw);
+        if (peer != null && peer.graphicsConfig != null) {
+            return peer.graphicsConfig;
+        }
+        return graphicsConfig;
+    }
+
     /**
      * Checks if window fits below specified item
      * returns rectangle that the window fits to or null.
      * @param itemBounds rectangle of item in global coordinates
      * @param windowSize size of submenu window to fit
-     * @param screenSize size of screen
+     * @param screenBounds size of screen
      */
-    Rectangle fitWindowBelow(Rectangle itemBounds, Dimension windowSize, Dimension screenSize) {
+    Rectangle fitWindowBelow(Rectangle itemBounds, Dimension windowSize, Rectangle screenBounds) {
         int width = windowSize.width;
         int height = windowSize.height;
         //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
         //near the periphery of the screen, XToolkit
         //Window should be moved if it's outside top-left screen bounds
-        int x = (itemBounds.x > 0) ? itemBounds.x : 0;
-        int y = (itemBounds.y + itemBounds.height > 0) ? itemBounds.y + itemBounds.height : 0;
-        if (y + height <= screenSize.height) {
+        int x = (itemBounds.x > screenBounds.x) ? itemBounds.x : screenBounds.x;
+        int y = (itemBounds.y + itemBounds.height > screenBounds.y) ? itemBounds.y + itemBounds.height : screenBounds.y;
+        if (y + height <= screenBounds.y + screenBounds.height) {
             //move it to the left if needed
-            if (width > screenSize.width) {
-                width = screenSize.width;
+            if (width > screenBounds.width) {
+                width = screenBounds.width;
             }
-            if (x + width > screenSize.width) {
-                x = screenSize.width - width;
+            if (x + width > screenBounds.x + screenBounds.width) {
+                x = screenBounds.x + screenBounds.width - width;
             }
             return new Rectangle(x, y, width, height);
         } else {
@@ -690,23 +697,23 @@
      * returns rectangle that the window fits to or null.
      * @param itemBounds rectangle of item in global coordinates
      * @param windowSize size of submenu window to fit
-     * @param screenSize size of screen
+     * @param screenBounds size of screen
      */
-    Rectangle fitWindowAbove(Rectangle itemBounds, Dimension windowSize, Dimension screenSize) {
+    Rectangle fitWindowAbove(Rectangle itemBounds, Dimension windowSize, Rectangle screenBounds) {
         int width = windowSize.width;
         int height = windowSize.height;
         //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
         //near the periphery of the screen, XToolkit
         //Window should be moved if it's outside bottom-left screen bounds
-        int x = (itemBounds.x > 0) ? itemBounds.x : 0;
-        int y = (itemBounds.y > screenSize.height) ? screenSize.height - height : itemBounds.y - height;
-        if (y >= 0) {
+        int x = (itemBounds.x > screenBounds.x) ? itemBounds.x : screenBounds.x;
+        int y = (itemBounds.y > screenBounds.y + screenBounds.height) ? screenBounds.y + screenBounds.height - height : itemBounds.y - height;
+        if (y >= screenBounds.y) {
             //move it to the left if needed
-            if (width > screenSize.width) {
-                width = screenSize.width;
+            if (width > screenBounds.width) {
+                width = screenBounds.width;
             }
-            if (x + width > screenSize.width) {
-                x = screenSize.width - width;
+            if (x + width > screenBounds.x + screenBounds.width) {
+                x = screenBounds.x + screenBounds.width - width;
             }
             return new Rectangle(x, y, width, height);
         } else {
@@ -719,23 +726,23 @@
      * returns rectangle that the window fits to or null.
      * @param itemBounds rectangle of item in global coordinates
      * @param windowSize size of submenu window to fit
-     * @param screenSize size of screen
+     * @param screenBounds size of screen
      */
-    Rectangle fitWindowRight(Rectangle itemBounds, Dimension windowSize, Dimension screenSize) {
+    Rectangle fitWindowRight(Rectangle itemBounds, Dimension windowSize, Rectangle screenBounds) {
         int width = windowSize.width;
         int height = windowSize.height;
         //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
         //near the periphery of the screen, XToolkit
         //Window should be moved if it's outside top-left screen bounds
-        int x = (itemBounds.x + itemBounds.width > 0) ? itemBounds.x + itemBounds.width : 0;
-        int y = (itemBounds.y > 0) ? itemBounds.y : 0;
-        if (x + width <= screenSize.width) {
+        int x = (itemBounds.x + itemBounds.width > screenBounds.x) ? itemBounds.x + itemBounds.width : screenBounds.x;
+        int y = (itemBounds.y > screenBounds.y) ? itemBounds.y : screenBounds.y;
+        if (x + width <= screenBounds.x + screenBounds.width) {
             //move it to the top if needed
-            if (height > screenSize.height) {
-                height = screenSize.height;
+            if (height > screenBounds.height) {
+                height = screenBounds.height;
             }
-            if (y + height > screenSize.height) {
-                y = screenSize.height - height;
+            if (y + height > screenBounds.y + screenBounds.height) {
+                y = screenBounds.y + screenBounds.height - height;
             }
             return new Rectangle(x, y, width, height);
         } else {
@@ -748,23 +755,23 @@
      * returns rectangle that the window fits to or null.
      * @param itemBounds rectangle of item in global coordinates
      * @param windowSize size of submenu window to fit
-     * @param screenSize size of screen
+     * @param screenBounds size of screen
      */
-    Rectangle fitWindowLeft(Rectangle itemBounds, Dimension windowSize, Dimension screenSize) {
+    Rectangle fitWindowLeft(Rectangle itemBounds, Dimension windowSize, Rectangle screenBounds) {
         int width = windowSize.width;
         int height = windowSize.height;
         //Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
         //near the periphery of the screen, XToolkit
         //Window should be moved if it's outside top-right screen bounds
-        int x = (itemBounds.x < screenSize.width) ? itemBounds.x - width : screenSize.width - width;
-        int y = (itemBounds.y > 0) ? itemBounds.y : 0;
-        if (x >= 0) {
+        int x = (itemBounds.x < screenBounds.x + screenBounds.width) ? itemBounds.x - width : screenBounds.x + screenBounds.width - width;
+        int y = (itemBounds.y > screenBounds.y) ? itemBounds.y : screenBounds.y;
+        if (x >= screenBounds.x) {
             //move it to the top if needed
-            if (height > screenSize.height) {
-                height = screenSize.height;
+            if (height > screenBounds.height) {
+                height = screenBounds.height;
             }
-            if (y + height > screenSize.height) {
-                y = screenSize.height - height;
+            if (y + height > screenBounds.y + screenBounds.height) {
+                y = screenBounds.y + screenBounds.height - height;
             }
             return new Rectangle(x, y, width, height);
         } else {
@@ -777,12 +784,12 @@
      * to fit it on screen - move it to the
      * top-left edge and cut by screen dimensions
      * @param windowSize size of submenu window to fit
-     * @param screenSize size of screen
+     * @param screenBounds size of screen
      */
-    Rectangle fitWindowToScreen(Dimension windowSize, Dimension screenSize) {
-        int width = (windowSize.width < screenSize.width) ? windowSize.width : screenSize.width;
-        int height = (windowSize.height < screenSize.height) ? windowSize.height : screenSize.height;
-        return new Rectangle(0, 0, width, height);
+    Rectangle fitWindowToScreen(Dimension windowSize, Rectangle screenBounds) {
+        int width = (windowSize.width < screenBounds.width) ? windowSize.width : screenBounds.width;
+        int height = (windowSize.height < screenBounds.height) ? windowSize.height : screenBounds.height;
+        return new Rectangle(screenBounds.x, screenBounds.y, width, height);
     }
 
 
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XChoicePeer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XChoicePeer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, 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 @@
 
 // TODO: make painting more efficient (i.e. when down arrow is pressed, only two items should need to be repainted.
 
-public class XChoicePeer extends XComponentPeer implements ChoicePeer, ToplevelStateListener {
+public final class XChoicePeer extends XComponentPeer implements ChoicePeer, ToplevelStateListener {
     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XChoicePeer");
 
     private static final int MAX_UNFURLED_ITEMS = 10;  // Maximum number of
@@ -741,6 +741,16 @@
         }
     }
 
+    @Override
+    protected void initGraphicsConfiguration() {
+        super.initGraphicsConfiguration();
+        // The popup have the same graphic config, so update it at the same time
+        if (unfurledChoice != null) {
+            unfurledChoice.initGraphicsConfiguration();
+            unfurledChoice.doValidateSurface();
+        }
+    }
+
     /**************************************************************************/
     /* Common functionality between List & Choice
        /**************************************************************************/
@@ -749,7 +759,7 @@
      * Inner class for the unfurled Choice list
      * Much, much more docs
      */
-    class UnfurledChoice extends XWindow /*implements XScrollbarClient*/ {
+    final class UnfurledChoice extends XWindow /*implements XScrollbarClient*/ {
 
         // First try - use Choice as the target
 
@@ -785,7 +795,7 @@
                 numItemsDisplayed = Math.min(MAX_UNFURLED_ITEMS, numItems);
             }
             Point global = XChoicePeer.this.toGlobal(0,0);
-            Rectangle screen = graphicsConfig.getBounds();
+            Rectangle screenBounds = graphicsConfig.getBounds();
 
             if (alignUnder != null) {
                 Rectangle choiceRec = XChoicePeer.this.getBounds();
@@ -807,19 +817,19 @@
                 height = 2*BORDER_WIDTH +
                     numItemsDisplayed*(helper.getItemHeight()+2*ITEM_MARGIN);
             }
-            // Don't run off the edge of the screen
-            if (x < 0) {
-                x = 0;
+            // Don't run off the edge of the screenBounds
+            if (x < screenBounds.x) {
+                x = screenBounds.x;
             }
-            else if (x + width > screen.width) {
-                x = screen.width - width;
+            else if (x + width > screenBounds.x + screenBounds.width) {
+                x = screenBounds.x + screenBounds.width - width;
             }
 
-            if (y + height > screen.height) {
+            if (y + height > screenBounds.y + screenBounds.height) {
                 y = global.y - height;
             }
-            if (y < 0) {
-                y = 0;
+            if (y < screenBounds.y) {
+                y = screenBounds.y;
             }
             return new Rectangle(x, y, width, height);
         }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -298,25 +298,25 @@
      */
     protected Rectangle getSubmenuBounds(Rectangle itemBounds, Dimension windowSize) {
         Rectangle globalBounds = toGlobal(itemBounds);
-        Dimension screenSize = graphicsConfig.getBounds().getSize();
+        Rectangle screenBounds = getCurrentGraphicsConfiguration().getBounds();
         Rectangle res;
-        res = fitWindowBelow(globalBounds, windowSize, screenSize);
+        res = fitWindowBelow(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        res = fitWindowAbove(globalBounds, windowSize, screenSize);
+        res = fitWindowAbove(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        res = fitWindowRight(globalBounds, windowSize, screenSize);
+        res = fitWindowRight(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        res = fitWindowLeft(globalBounds, windowSize, screenSize);
+        res = fitWindowLeft(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        return fitWindowToScreen(windowSize, screenSize);
+        return fitWindowToScreen(windowSize, screenBounds);
     }
 
     /**
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuWindow.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuWindow.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, 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
@@ -278,25 +278,25 @@
      */
     protected Rectangle getSubmenuBounds(Rectangle itemBounds, Dimension windowSize) {
         Rectangle globalBounds = toGlobal(itemBounds);
-        Dimension screenSize = graphicsConfig.getBounds().getSize();
+        Rectangle screenBounds = getCurrentGraphicsConfiguration().getBounds();
         Rectangle res;
-        res = fitWindowRight(globalBounds, windowSize, screenSize);
+        res = fitWindowRight(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        res = fitWindowBelow(globalBounds, windowSize, screenSize);
+        res = fitWindowBelow(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        res = fitWindowAbove(globalBounds, windowSize, screenSize);
+        res = fitWindowAbove(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        res = fitWindowLeft(globalBounds, windowSize, screenSize);
+        res = fitWindowLeft(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        return fitWindowToScreen(windowSize, screenSize);
+        return fitWindowToScreen(windowSize, screenBounds);
    }
 
     /**
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, 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
@@ -216,25 +216,25 @@
      */
     protected Rectangle getWindowBounds(Point origin, Dimension windowSize) {
         Rectangle globalBounds = new Rectangle(origin.x, origin.y, 0, 0);
-        Dimension screenSize = graphicsConfig.getBounds().getSize();
+        Rectangle screenBounds = getCurrentGraphicsConfiguration().getBounds();
         Rectangle res;
-        res = fitWindowRight(globalBounds, windowSize, screenSize);
+        res = fitWindowRight(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        res = fitWindowLeft(globalBounds, windowSize, screenSize);
+        res = fitWindowLeft(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        res = fitWindowBelow(globalBounds, windowSize, screenSize);
+        res = fitWindowBelow(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        res = fitWindowAbove(globalBounds, windowSize, screenSize);
+        res = fitWindowAbove(globalBounds, windowSize, screenBounds);
         if (res != null) {
             return res;
         }
-        return fitWindowToScreen(windowSize, screenSize);
+        return fitWindowToScreen(windowSize, screenBounds);
    }
 
     /************************************************
--- a/jdk/src/java.desktop/unix/legal/fontconfig.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/unix/legal/fontconfig.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
-## FontConfig v2.5
+## Fontconfig v2.5
 
-### FontConfig License
+### Fontconfig License
 <pre>
 
 Copyright 2001,2003 Keith Packard
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java	Wed Jul 05 23:09:40 2017 +0200
@@ -186,7 +186,17 @@
         SurfaceData sd = d3dvsm.getPrimarySurfaceData();
         if (sd instanceof D3DSurfaceData) {
             D3DSurfaceData d3dsd = (D3DSurfaceData)sd;
-            D3DSurfaceData.swapBuffers(d3dsd, x1, y1, x2, y2);
+            double scaleX = sd.getDefaultScaleX();
+            double scaleY = sd.getDefaultScaleY();
+            if (scaleX > 1 || scaleY > 1) {
+                int sx1 = (int) Math.floor(x1 * scaleX);
+                int sy1 = (int) Math.floor(y1 * scaleY);
+                int sx2 = (int) Math.ceil(x2 * scaleX);
+                int sy2 = (int) Math.ceil(y2 * scaleY);
+                D3DSurfaceData.swapBuffers(d3dsd, sx1, sy1, sx2, sy2);
+            } else {
+                D3DSurfaceData.swapBuffers(d3dsd, x1, y1, x2, y2);
+            }
         } else {
             // the surface was likely lost could not have been restored
             Graphics g = peer.getGraphics();
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java	Wed Jul 05 23:09:40 2017 +0200
@@ -766,7 +766,17 @@
                 final Component target = (Component)sd.getPeer().getTarget();
                 SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
                     public void run() {
-                        target.repaint(x1, y1, x2, y2);
+                        double scaleX = sd.getDefaultScaleX();
+                        double scaleY = sd.getDefaultScaleY();
+                        if (scaleX > 1 || scaleY > 1) {
+                            int sx1 = (int) Math.floor(x1 / scaleX);
+                            int sy1 = (int) Math.floor(y1 / scaleY);
+                            int sx2 = (int) Math.ceil(x2 / scaleX);
+                            int sy2 = (int) Math.ceil(y2 / scaleY);
+                            target.repaint(sx1, sy1, sx2 - sx1, sy2 - sy1);
+                        } else {
+                            target.repaint(x1, y1, x2 - x1, y2 - y1);
+                        }
                     }
                 });
                 return;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -54,6 +54,7 @@
 jmethodID AwtPrintControl::setDevmodeID;
 jmethodID AwtPrintControl::getDevnamesID;
 jmethodID AwtPrintControl::setDevnamesID;
+jmethodID AwtPrintControl::getParentWindowID;
 jfieldID  AwtPrintControl::driverDoesMultipleCopiesID;
 jfieldID  AwtPrintControl::driverDoesCollationID;
 jmethodID AwtPrintControl::getWin32MediaID;
@@ -240,6 +241,11 @@
     DASSERT(AwtPrintControl::dialogOwnerPeerID != NULL);
     CHECK_NULL(AwtPrintControl::dialogOwnerPeerID);
 
+    AwtPrintControl::getParentWindowID = env->GetMethodID(cls,
+                                       "getParentWindowID", "()J");
+    DASSERT(AwtPrintControl::getParentWindowID != NULL);
+    CHECK_NULL(AwtPrintControl::getParentWindowID);
+
     AwtPrintControl::getPrintDCID = env->GetMethodID(cls, "getPrintDC", "()J");
     DASSERT(AwtPrintControl::getPrintDCID != NULL);
     CHECK_NULL(AwtPrintControl::getPrintDCID);
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.h	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.h	Wed Jul 05 23:09:40 2017 +0200
@@ -47,6 +47,7 @@
     static jmethodID setDevmodeID;
     static jmethodID getDevnamesID;
     static jmethodID setDevnamesID;
+    static jmethodID getParentWindowID;
     static jmethodID getWin32MediaID;
     static jmethodID setWin32MediaID;
     static jmethodID getWin32MediaTrayID;
@@ -97,6 +98,10 @@
                                  LPTSTR pPrinterName,
                                  LPDEVMODE *pDevMode);
 
+    inline static HWND getParentID(JNIEnv *env, jobject self) {
+      return (HWND)env->CallLongMethod(self, getParentWindowID);
+    }
+
     inline static  HDC getPrintDC(JNIEnv *env, jobject self) {
       return (HDC)env->CallLongMethod(self, getPrintDCID);
     }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintDialog.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintDialog.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -248,6 +248,11 @@
       pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDialogHookProc;
       pd.lpfnSetupHook = (LPSETUPHOOKPROC)PrintDialogHookProc;
       pd.Flags |= PD_ENABLESETUPHOOK | PD_ENABLEPRINTHOOK;
+      HWND parent = AwtPrintControl::getParentID(env, control);
+      if (parent != NULL && ::IsWindow(parent)) {
+          // Windows native modality is requested (used by JavaFX).
+          pd.hwndOwner = parent;
+      }
       /*
           Fix for 6488834.
           To disable Win32 native parent modality we have to set
@@ -255,7 +260,7 @@
           parentless dialogs we use NULL to show them in the taskbar,
           and for all other dialogs AwtToolkit's HWND is used.
       */
-      if (awtParent != NULL)
+      else if (awtParent != NULL)
       {
           pd.hwndOwner = AwtToolkit::GetInstance().GetHWnd();
       }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp	Wed Jul 05 23:09:40 2017 +0200
@@ -521,12 +521,18 @@
     AwtComponent *awtParent = (parent != NULL) ? (AwtComponent *)JNI_GET_PDATA(parent) : NULL;
     HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL;
 
+
     jboolean doIt = JNI_FALSE; // Assume the user will cancel the dialog.
     PAGESETUPDLG setup;
     memset(&setup, 0, sizeof(setup));
 
     setup.lStructSize = sizeof(setup);
 
+    HWND parentID = AwtPrintControl::getParentID(env, self);
+    if (parentID != NULL && ::IsWindow(parentID)) {
+        // windows native modality is requested (used by JavaFX).
+        setup.hwndOwner = parentID;
+    }
     /*
       Fix for 6488834.
       To disable Win32 native parent modality we have to set
@@ -534,7 +540,7 @@
       parentless dialogs we use NULL to show them in the taskbar,
       and for all other dialogs AwtToolkit's HWND is used.
     */
-    if (awtParent != NULL)
+    else if (awtParent != NULL)
     {
         setup.hwndOwner = AwtToolkit::GetInstance().GetHWnd();
     }
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -191,6 +191,9 @@
      *         if the input does not represent a well-formed class file
      * @return a well-formed class file buffer (the result of the transform),
      *         or {@code null} if no transform is performed
+     *
+     * @revised 9
+     * @spec JPMS
      */
     default byte[]
     transform(  ClassLoader         loader,
--- a/jdk/src/java.instrument/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.instrument/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
  * Defines services that allow agents to
  * instrument programs running on the JVM.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.instrument {
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1839,6 +1839,7 @@
      *          logging configuration file.
      *
      * @see #updateConfiguration(java.io.InputStream, java.util.function.Function)
+     * @since 9
      */
     public void updateConfiguration(Function<String, BiFunction<String,String,String>> mapper)
             throws IOException {
@@ -2035,6 +2036,7 @@
      * @throws  IOException if there are problems reading from the stream,
      *          or the given stream is not in the
      *          {@linkplain java.util.Properties properties file} format.
+     * @since 9
      */
     public void updateConfiguration(InputStream ins,
             Function<String, BiFunction<String,String,String>> mapper)
--- a/jdk/src/java.logging/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.logging/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the Java Logging API.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.logging {
--- a/jdk/src/java.management.rmi/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.management.rmi/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -46,6 +46,7 @@
  *           and load the appropriate {@code JMXConnectorServerProvider} service
  *           implementation for the given protocol.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.management.rmi {
--- a/jdk/src/java.management/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.management/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,6 +29,7 @@
  * The JMX API consists of interfaces for monitoring and management of the
  * JVM and other components in the Java runtime.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.management {
--- a/jdk/src/java.naming/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.naming/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the Java Naming and Directory Interface (JNDI) API.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.naming {
--- a/jdk/src/java.prefs/share/classes/java/util/prefs/Preferences.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.prefs/share/classes/java/util/prefs/Preferences.java	Wed Jul 05 23:09:40 2017 +0200
@@ -188,8 +188,8 @@
  * administrator to replace the default preferences implementation with an
  * alternative implementation.
  *
- * <p>Implementation note: In Sun's JRE, the {@code PreferencesFactory}
- * implementation is located as follows:
+ * @implNote
+ * The {@code PreferencesFactory} implementation is located as follows:
  *
  * <ol>
  *
--- a/jdk/src/java.prefs/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.prefs/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the Preferences API.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.prefs {
--- a/jdk/src/java.rmi/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.rmi/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the Remote Method Invocation (RMI) API.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.rmi {
--- a/jdk/src/java.scripting/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.scripting/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the Scripting API.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.scripting {
--- a/jdk/src/java.se.ee/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.se.ee/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,6 +29,7 @@
  * This module requires {@code java.se} and supplements it with modules
  * that define CORBA and Java EE APIs. These modules are upgradeable.
  *
+ * @moduleGraph
  * @since 9
  */
 @SuppressWarnings("deprecation")
--- a/jdk/src/java.se/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.se/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,6 +29,7 @@
  * The modules defining CORBA and Java EE APIs are not required by
  * this module, but they are required by {@code java.se.ee}.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.se {
--- a/jdk/src/java.security.jgss/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.security.jgss/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,7 @@
  * <P>
  * This module also contains GSS-API mechanisms including Kerberos v5 and SPNEGO.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.security.jgss {
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java	Wed Jul 05 23:09:40 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.sasl/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.security.sasl/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,6 +30,7 @@
  * This module also contains SASL mechanisms including DIGEST-MD5,
  * CRAM-MD5, and NTLM.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.security.sasl {
--- a/jdk/src/java.smartcardio/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.smartcardio/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the Java Smart Card I/O API.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.smartcardio {
--- a/jdk/src/java.smartcardio/unix/legal/pcsclite.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.smartcardio/unix/legal/pcsclite.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 ## PC/SC Lite for Suse Linux v1.1.1
 
-### PC/SC Lite for Suse Linux License
+### PC/SC Lite License
 <pre>
 
 Copyright (c) 1999-2004 David Corcoran <corcoran@linuxnet.com>
--- a/jdk/src/java.sql.rowset/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql.rowset/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the JDBC RowSet API.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.sql.rowset {
--- a/jdk/src/java.sql/share/classes/java/sql/CallableStatement.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/CallableStatement.java	Wed Jul 05 23:09:40 2017 +0200
@@ -60,6 +60,7 @@
  *
  * @see Connection#prepareCall
  * @see ResultSet
+ * @since 1.1
  */
 
 public interface CallableStatement extends PreparedStatement {
--- a/jdk/src/java.sql/share/classes/java/sql/Connection.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/Connection.java	Wed Jul 05 23:09:40 2017 +0200
@@ -80,6 +80,7 @@
  * @see Statement
  * @see ResultSet
  * @see DatabaseMetaData
+ * @since 1.1
  */
 public interface Connection  extends Wrapper, AutoCloseable {
 
--- a/jdk/src/java.sql/share/classes/java/sql/DataTruncation.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/DataTruncation.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,6 +34,8 @@
  *
  * <P>The SQLstate for a <code>DataTruncation</code> during read is <code>01004</code>.
  * <P>The SQLstate for a <code>DataTruncation</code> during write is <code>22001</code>.
+ *
+ * @since 1.1
  */
 
 public class DataTruncation extends SQLWarning {
--- a/jdk/src/java.sql/share/classes/java/sql/DatabaseMetaData.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/DatabaseMetaData.java	Wed Jul 05 23:09:40 2017 +0200
@@ -68,6 +68,7 @@
  * argument is set to <code>null</code>, that argument's criterion will
  * be dropped from the search.
  *
+ * @since 1.1
  */
 public interface DatabaseMetaData extends Wrapper {
 
--- a/jdk/src/java.sql/share/classes/java/sql/Date.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/Date.java	Wed Jul 05 23:09:40 2017 +0200
@@ -41,6 +41,8 @@
  * must be 'normalized' by setting the
  * hours, minutes, seconds, and milliseconds to zero in the particular
  * time zone with which the instance is associated.
+ *
+ * @since 1.1
  */
 public class Date extends java.util.Date {
 
--- a/jdk/src/java.sql/share/classes/java/sql/Driver.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/Driver.java	Wed Jul 05 23:09:40 2017 +0200
@@ -54,6 +54,7 @@
  * @see DriverManager
  * @see Connection
  * @see DriverAction
+ * @since 1.1
  */
 public interface Driver {
 
--- a/jdk/src/java.sql/share/classes/java/sql/DriverManager.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/DriverManager.java	Wed Jul 05 23:09:40 2017 +0200
@@ -78,6 +78,7 @@
  *
  * @see Driver
  * @see Connection
+ * @since 1.1
  */
 public class DriverManager {
 
--- a/jdk/src/java.sql/share/classes/java/sql/DriverPropertyInfo.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/DriverPropertyInfo.java	Wed Jul 05 23:09:40 2017 +0200
@@ -31,6 +31,8 @@
  * who need to interact with a Driver via the method
  * <code>getDriverProperties</code> to discover
  * and supply properties for connections.
+ *
+ * @since 1.1
  */
 
 public class DriverPropertyInfo {
--- a/jdk/src/java.sql/share/classes/java/sql/PreparedStatement.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/PreparedStatement.java	Wed Jul 05 23:09:40 2017 +0200
@@ -56,6 +56,7 @@
  *
  * @see Connection#prepareStatement
  * @see ResultSet
+ * @since 1.1
  */
 
 public interface PreparedStatement extends Statement {
--- a/jdk/src/java.sql/share/classes/java/sql/ResultSet.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/ResultSet.java	Wed Jul 05 23:09:40 2017 +0200
@@ -143,6 +143,7 @@
  * @see Statement#executeQuery
  * @see Statement#getResultSet
  * @see ResultSetMetaData
+ * @since 1.1
  */
 
 public interface ResultSet extends Wrapper, AutoCloseable {
--- a/jdk/src/java.sql/share/classes/java/sql/ResultSetMetaData.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/ResultSetMetaData.java	Wed Jul 05 23:09:40 2017 +0200
@@ -40,6 +40,8 @@
  *     boolean b = rsmd.isSearchable(1);
  *
  * </PRE>
+ *
+ * @since 1.1
  */
 
 public interface ResultSetMetaData extends Wrapper {
--- a/jdk/src/java.sql/share/classes/java/sql/SQLException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/SQLException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -49,6 +49,8 @@
  *       error information.
  *   <LI> the causal relationship, if any for this <code>SQLException</code>.
  * </UL>
+ *
+ * @since 1.1
  */
 public class SQLException extends java.lang.Exception
                           implements Iterable<Throwable> {
--- a/jdk/src/java.sql/share/classes/java/sql/SQLWarning.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/SQLWarning.java	Wed Jul 05 23:09:40 2017 +0200
@@ -41,6 +41,7 @@
  * @see Connection#getWarnings
  * @see Statement#getWarnings
  * @see ResultSet#getWarnings
+ * @since 1.1
  */
 public class SQLWarning extends SQLException {
 
--- a/jdk/src/java.sql/share/classes/java/sql/ShardingKeyBuilder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/ShardingKeyBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -42,6 +42,8 @@
  *                           .build();
  * }
  * </pre>
+ *
+ * @since 9
  */
 public interface ShardingKeyBuilder {
 
--- a/jdk/src/java.sql/share/classes/java/sql/Statement.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/Statement.java	Wed Jul 05 23:09:40 2017 +0200
@@ -42,6 +42,7 @@
  *
  * @see Connection#createStatement
  * @see ResultSet
+ * @since 1.1
  */
 public interface Statement extends Wrapper, AutoCloseable {
 
@@ -1399,6 +1400,8 @@
      * converted to two single quotes
      * @throws NullPointerException if val is {@code null}
      * @throws SQLException if a database access error occurs
+     *
+     * @since 9
      */
      default String enquoteLiteral(String val)  throws SQLException {
          return "'" + val.replace("'", "''") +  "'";
@@ -1503,6 +1506,8 @@
      * @throws SQLFeatureNotSupportedException if the datasource does not support
      * delimited identifiers
      * @throws NullPointerException if identifier is {@code null}
+     *
+     * @since 9
      */
     default String enquoteIdentifier(String identifier, boolean alwaysQuote) throws SQLException {
         int len = identifier.length();
@@ -1576,6 +1581,8 @@
      * @return  true if  a simple SQL identifier, false otherwise
      * @throws NullPointerException if identifier is {@code null}
      * @throws SQLException if a database access error occurs
+     *
+     * @since 9
      */
     default boolean isSimpleIdentifier(String identifier) throws SQLException {
         int len = identifier.length();
@@ -1617,6 +1624,8 @@
     * then prefixed with 'N'.
     * @throws NullPointerException if val is {@code null}
     * @throws SQLException if a database access error occurs
+    *
+    * @since 9
     */
     default String enquoteNCharLiteral(String val)  throws SQLException {
         return "N'" + val.replace("'", "''") +  "'";
--- a/jdk/src/java.sql/share/classes/java/sql/Time.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/Time.java	Wed Jul 05 23:09:40 2017 +0200
@@ -38,6 +38,8 @@
  * values.
  * <p>The date components should be set to the "zero epoch"
  * value of January 1, 1970 and should not be accessed.
+ *
+ * @since 1.1
  */
 public class Time extends java.util.Date {
 
--- a/jdk/src/java.sql/share/classes/java/sql/Timestamp.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/Timestamp.java	Wed Jul 05 23:09:40 2017 +0200
@@ -69,6 +69,8 @@
  * inheritance relationship between {@code Timestamp}
  * and {@code java.util.Date} really
  * denotes implementation inheritance, and not type inheritance.
+ *
+ * @since 1.1
  */
 public class Timestamp extends java.util.Date {
 
--- a/jdk/src/java.sql/share/classes/java/sql/Types.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/Types.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,6 +30,8 @@
  * SQL types, called JDBC types.
  * <p>
  * This class is never instantiated.
+ *
+ * @since 1.1
  */
 public class Types {
 
--- a/jdk/src/java.sql/share/classes/javax/transaction/xa/XAException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/javax/transaction/xa/XAException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,6 +29,7 @@
  * The XAException is thrown by the Resource Manager (RM) to inform the
  * Transaction Manager of an error encountered by the involved transaction.
  *
+ * @since 1.4
  */
 public class XAException extends Exception {
 
--- a/jdk/src/java.sql/share/classes/javax/transaction/xa/XAResource.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/javax/transaction/xa/XAResource.java	Wed Jul 05 23:09:40 2017 +0200
@@ -56,6 +56,7 @@
  * the transaction manager to prepare, commit, or rollback a transaction
  * according to the two-phase commit protocol.</p>
  *
+ * @since 1.4
  */
 public interface XAResource {
 
--- a/jdk/src/java.sql/share/classes/javax/transaction/xa/Xid.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/javax/transaction/xa/Xid.java	Wed Jul 05 23:09:40 2017 +0200
@@ -32,6 +32,8 @@
  * and branch qualifier. The Xid interface is used by the transaction
  * manager and the resource managers. This interface is not visible to
  * the application programs.
+ *
+ * @since 1.4
  */
 public interface Xid {
 
--- a/jdk/src/java.sql/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.sql/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the JDBC API.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.sql {
--- a/jdk/src/java.transaction/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.transaction/share/classes/module-info.java	Wed Jul 05 23:09:40 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
@@ -29,8 +29,10 @@
  * The subset consists of RMI exception types which are mapped to CORBA system
  * exceptions by the 'Java Language to IDL Mapping Specification'.
  *
+ * @moduleGraph
  * @since 9
  */
+@Deprecated(since="9", forRemoval=true)
 module java.transaction {
     requires transitive java.rmi;
     exports javax.transaction;
--- a/jdk/src/java.xml.crypto/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.xml.crypto/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,8 +24,9 @@
  */
 
 /**
- * Defines an API for XML cryptography.
+ * Defines the API for XML cryptography.
  *
+ * @moduleGraph
  * @since 9
  */
 module java.xml.crypto {
--- a/jdk/src/java.xml.crypto/share/legal/santuario.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/java.xml.crypto/share/legal/santuario.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
 ## Apache Santuario v1.5.4
 
-### Notice
+### Apache Santuario Notice
 <pre>
 
   Apache Santuario - XML Security for Java
--- a/jdk/src/jdk.attach/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.attach/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the attach API.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.attach {
--- a/jdk/src/jdk.charsets/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.charsets/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,13 @@
  * questions.
  */
 
+/**
+ * {@link java.nio.charset.Charset Charset} provider for the charsets that
+ * are not in {@code java.base} (mostly double byte and IBM charsets).
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.charsets {
     provides java.nio.charset.spi.CharsetProvider
         with sun.nio.cs.ext.ExtendedCharsets;
--- a/jdk/src/jdk.crypto.cryptoki/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.crypto.cryptoki/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * The SunPKCS11 security provider.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.crypto.cryptoki {
--- a/jdk/src/jdk.crypto.cryptoki/share/legal/pkcs11cryptotoken.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.crypto.cryptoki/share/legal/pkcs11cryptotoken.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,4 +1,4 @@
-## PKCS #11 Cryptographic Token Interface, v2.20 amendment 3 Header Files
+## PKCS #11 Cryptographic Token Interface v2.20 Amendment 3 Header Files
 
 ### PKCS #11 Cryptographic Token Interface License
 <pre>
--- a/jdk/src/jdk.crypto.ec/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.crypto.ec/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * The SunEC security provider.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.crypto.ec {
--- a/jdk/src/jdk.crypto.ec/share/legal/ecc.md	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.crypto.ec/share/legal/ecc.md	Wed Jul 05 23:09:40 2017 +0200
@@ -1,6 +1,6 @@
-## Mozilla Elliptic Curve Cryptography
+## Mozilla Elliptic Curve Cryptography (ECC)
 
-### Notice
+### Mozilla ECC Notice
 <pre>
 
 This notice is provided with respect to Elliptic Curve Cryptography,
@@ -21,7 +21,7 @@
 
 </pre>
 
-### LGPL 2.1 License
+### LGPL 2.1
 <pre>
 
                   GNU LESSER GENERAL PUBLIC LICENSE
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * The SunMSCAPI security provider.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.crypto.mscapi {
--- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * The OracleUCrypto security provider.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.crypto.ucrypto {
--- a/jdk/src/jdk.httpserver/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.httpserver/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Defines the JDK-specific API for HTTP server.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.httpserver {
 
     exports com.sun.net.httpserver;
--- a/jdk/src/jdk.jartool/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jartool/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,13 @@
  * questions.
  */
 
+/**
+ * Defines tools for manipulating Java Archive (JAR) files,
+ * including the jar and jarsigner tools.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.jartool {
     exports com.sun.jarsigner;
     exports jdk.security.jarsigner;
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java	Wed Jul 05 23:09:40 2017 +0200
@@ -95,7 +95,7 @@
                     tool.xflag = true;
                 }
             },
-            new Option(false, OptionType.MAIN_OPERATION, "--print-module-descriptor", "-d") {
+            new Option(false, OptionType.MAIN_OPERATION, "--describe-module", "-d") {
                 void process(Main tool, String opt, String arg) throws BadArgs {
                     if (tool.cflag || tool.iflag  || tool.tflag || tool.uflag || tool.xflag)
                         throw new BadArgs("error.multiple.main.operations").showUsage(true);
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
 
 import java.io.*;
 import java.lang.module.Configuration;
+import java.lang.module.FindException;
 import java.lang.module.InvalidModuleDescriptorException;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Exports;
@@ -63,6 +64,7 @@
 import jdk.internal.module.ModuleInfo;
 import jdk.internal.module.ModuleInfoExtender;
 import jdk.internal.module.ModuleResolution;
+import jdk.internal.module.ModuleTarget;
 import jdk.internal.util.jar.JarIndex;
 
 import static jdk.internal.util.jar.JarIndex.INDEX_NAME;
@@ -407,11 +409,11 @@
                 boolean found;
                 if (fname != null) {
                     try (ZipFile zf = new ZipFile(fname)) {
-                        found = printModuleDescriptor(zf);
+                        found = describeModule(zf);
                     }
                 } else {
                     try (FileInputStream fin = new FileInputStream(FileDescriptor.in)) {
-                        found = printModuleDescriptor(fin);
+                        found = describeModule(fin);
                     }
                 }
                 if (!found)
@@ -603,7 +605,7 @@
         int n = args.length - count;
         if (n > 0) {
             if (dflag) {
-                // "--print-module-descriptor/-d" does not require file argument(s)
+                // "--describe-module/-d" does not require file argument(s)
                 usageError(formatMsg("error.bad.dflag", args[count]));
                 return false;
             }
@@ -1728,24 +1730,43 @@
                            .collect(joining(", ", prefix, suffix));
     }
 
-    private boolean printModuleDescriptor(ZipFile zipFile)
-        throws IOException
-    {
+    private boolean describeModule(ZipFile zipFile) throws IOException {
         ZipEntry[] zes = zipFile.stream()
             .filter(e -> isModuleInfoEntry(e.getName()))
             .sorted(Validator.ENTRY_COMPARATOR)
             .toArray(ZipEntry[]::new);
-        if (zes.length == 0)
-            return false;
-        for (ZipEntry ze : zes) {
-            try (InputStream is = zipFile.getInputStream(ze)) {
-                printModuleDescriptor(is, ze.getName());
+
+        if (zes.length == 0) {
+            // No module descriptor found, derive the automatic module name
+            String fn = zipFile.getName();
+            ModuleFinder mf = ModuleFinder.of(Paths.get(fn));
+            try {
+                Set<ModuleReference> mref = mf.findAll();
+                if (mref.isEmpty()) {
+                    output(formatMsg("error.unable.derive.automodule", fn));
+                    return true;
+                }
+                ModuleDescriptor md = mref.iterator().next().descriptor();
+                output(getMsg("out.automodule"));
+                describeModule(md, null, null, "automatic");
+            } catch (FindException e) {
+                String msg = formatMsg("error.unable.derive.automodule", fn);
+                Throwable t = e.getCause();
+                if (t != null)
+                    msg = msg + "\n" + t.getMessage();
+                output(msg);
+            }
+        } else {
+            for (ZipEntry ze : zes) {
+                try (InputStream is = zipFile.getInputStream(ze)) {
+                    describeModule(is, ze.getName());
+                }
             }
         }
         return true;
     }
 
-    private boolean printModuleDescriptor(FileInputStream fis)
+    private boolean describeModule(FileInputStream fis)
         throws IOException
     {
         try (BufferedInputStream bis = new BufferedInputStream(fis);
@@ -1764,7 +1785,7 @@
             .sorted(Validator.ENTRYNAME_COMPARATOR)
             .toArray(String[]::new);
         for (String name : names) {
-            printModuleDescriptor(new ByteArrayInputStream(moduleInfos.get(name)), name);
+            describeModule(new ByteArrayInputStream(moduleInfos.get(name)), name);
         }
         return true;
     }
@@ -1775,13 +1796,23 @@
                   .collect(joining(" "));
     }
 
-    private void printModuleDescriptor(InputStream entryInputStream, String ename)
+    private void describeModule(InputStream entryInputStream, String ename)
         throws IOException
     {
         ModuleInfo.Attributes attrs = ModuleInfo.read(entryInputStream, null);
         ModuleDescriptor md = attrs.descriptor();
+        ModuleTarget target = attrs.target();
         ModuleHashes hashes = attrs.recordedHashes();
 
+        describeModule(md, target, hashes, ename);
+    }
+
+    private void describeModule(ModuleDescriptor md,
+                                ModuleTarget target,
+                                ModuleHashes hashes,
+                                String ename)
+        throws IOException
+    {
         StringBuilder sb = new StringBuilder();
         sb.append("\nmodule ")
           .append(md.toNameAndVersion())
@@ -1824,11 +1855,14 @@
 
         md.mainClass().ifPresent(v -> sb.append("\n  main-class " + v));
 
-        md.osName().ifPresent(v -> sb.append("\n  operating-system-name " + v));
-
-        md.osArch().ifPresent(v -> sb.append("\n  operating-system-architecture " + v));
-
-        md.osVersion().ifPresent(v -> sb.append("\n  operating-system-version " + v));
+        if (target != null) {
+            String osName = target.osName();
+            if (osName != null)
+                sb.append("\n  operating-system-name " + osName);
+            String osArch = target.osArch();
+            if (osArch != null)
+                sb.append("\n  operating-system-architecture " + osArch);
+       }
 
        if (hashes != null) {
            hashes.names().stream().sorted().forEach(
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -45,7 +45,7 @@
 	'e' flag and manifest with the 'Main-Class' attribute cannot be specified \n\
 	 together!
 error.bad.dflag=\
-        '-d, --print-module-descriptor' option requires no input file(s) to be specified: {0}
+        '-d, --describe-module' option requires no input file(s) to be specified: {0}
 error.bad.reason=\
         bad reason: {0}, must be one of deprecated, deprecated-for-removal, or incubating
 error.nosuch.fileordir=\
@@ -62,6 +62,8 @@
         Hashing module {0} dependences, unable to find module {1} on module path
 error.module.options.without.info=\
         One of --module-version or --hash-modules without module-info.class
+error.unable.derive.automodule=\
+        Unable to derive module descriptor for: {0}
 error.unexpected.module-info=\
         Unexpected module descriptor {0}
 error.module.descriptor.not.found=\
@@ -129,6 +131,8 @@
         added manifest
 out.added.module-info=\
         added module-info: {0}
+out.automodule=\
+        No module descriptor found. Derived automatic module.
 out.update.manifest=\
         updated manifest
 out.update.module-info=\
@@ -224,8 +228,8 @@
 \  -u, --update               Update an existing jar archive
 main.help.opt.main.extract=\
 \  -x, --extract              Extract named (or all) files from the archive
-main.help.opt.main.print-module-descriptor=\
-\  -d, --print-module-descriptor  Print the module descriptor
+main.help.opt.main.describe-module=\
+\  -d, --describe-module      Print the module descriptor, or automatic module name
 main.help.opt.any=\
 \ Operation modifiers valid in any mode:\n\
 \n\
--- a/jdk/src/jdk.jcmd/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,13 @@
  * questions.
  */
 
+/**
+ * Defines tools for diagnostics and troubleshooting a JVM,
+ * including the jcmd, jps, jstat and other diagnostics tools.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.jcmd {
     requires jdk.attach;
     requires jdk.internal.jvmstat;
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,6 +30,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.VirtualMachineDescriptor;
@@ -145,4 +146,17 @@
         return this.getVirtualMachineDescriptors(null);
     }
 
+    public Collection<String> getVirtualMachinePids(Class<?> excludeClass) {
+        if (singlePid != null) {
+            // There is a bug in AttachProvider, when VM is debuggee-suspended it's not listed by the AttachProvider.
+            // If we are talking about a specific pid, just return it.
+            return List.of(singlePid);
+        } else {
+            return getVMDs(excludeClass, matchClass).stream().map(x -> {return x.id();}).collect(Collectors.toList());
+        }
+    }
+
+    public Collection<String> getVirtualMachinePids() {
+        return this.getVirtualMachinePids(null);
+    }
 }
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java	Wed Jul 05 23:09:40 2017 +0200
@@ -80,22 +80,22 @@
             System.exit(0);
         }
 
-        Collection<VirtualMachineDescriptor> vids = ap.getVirtualMachineDescriptors(JCmd.class);
+        Collection<String> pids = ap.getVirtualMachinePids(JCmd.class);
 
-        if (vids.isEmpty()) {
+        if (pids.isEmpty()) {
             System.err.println("Could not find any processes matching : '"
                                + arg.getProcessString() + "'");
             System.exit(1);
         }
 
         boolean success = true;
-        for (VirtualMachineDescriptor vid : vids) {
-            System.out.println(vid.id() + ":");
+        for (String pid : pids) {
+            System.out.println(pid + ":");
             if (arg.isListCounters()) {
-                listCounters(vid.id());
+                listCounters(pid);
             } else {
                 try {
-                    executeCommandForPid(vid.id(), arg.getCommand());
+                    executeCommandForPid(pid, arg.getCommand());
                 } catch(AttachOperationFailedException ex) {
                     System.err.println(ex.getMessage());
                     success = false;
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java	Wed Jul 05 23:09:40 2017 +0200
@@ -96,37 +96,37 @@
         String parg = args[optionCount];
 
         ProcessArgumentMatcher ap = new ProcessArgumentMatcher(parg);
-        Collection<VirtualMachineDescriptor> vids = ap.getVirtualMachineDescriptors(JInfo.class);
+        Collection<String> pids = ap.getVirtualMachinePids(JInfo.class);
 
-        if (vids.isEmpty()) {
+        if (pids.isEmpty()) {
             System.err.println("Could not find any processes matching : '" + parg + "'");
             System.exit(1);
         }
 
-        for (VirtualMachineDescriptor vid : vids) {
-            if (vids.size() > 1) {
-                System.out.println("Pid:" + vid.id());
+        for (String pid : pids) {
+            if (pids.size() > 1) {
+                System.out.println("Pid:" + pid);
             }
             if (!doFlag && !doFlags && !doSysprops) {
                 // Print flags and sysporps if no options given
-                sysprops(vid.id());
+                sysprops(pid);
                 System.out.println();
-                flags(vid.id());
+                flags(pid);
                 System.out.println();
-                commandLine(vid.id());
+                commandLine(pid);
             }
             if (doFlag) {
                 if (flag < 0) {
                     System.err.println("Missing flag");
                     usage(1);
                 }
-                flag(vid.id(), args[flag]);
+                flag(pid, args[flag]);
             }
             if (doFlags) {
-                flags(vid.id());
+                flags(pid);
             }
             if (doSysprops) {
-                sysprops(vid.id());
+                sysprops(pid);
             }
         }
     }
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java	Wed Jul 05 23:09:40 2017 +0200
@@ -91,16 +91,15 @@
         // As more options are added we should create an abstract tool class and
         // have a table to map the options
         ProcessArgumentMatcher ap = new ProcessArgumentMatcher(pidArg);
-        Collection<VirtualMachineDescriptor> vids = ap.getVirtualMachineDescriptors(JMap.class);
+        Collection<String> pids = ap.getVirtualMachinePids(JMap.class);
 
-        if (vids.isEmpty()) {
+        if (pids.isEmpty()) {
             System.err.println("Could not find any processes matching : '" + pidArg + "'");
             System.exit(1);
         }
 
-        for (VirtualMachineDescriptor vid : vids) {
-            String pid = vid.id();
-            if (vids.size() > 1) {
+        for (String pid : pids) {
+            if (pids.size() > 1) {
                 System.out.println("Pid:" + pid);
             }
             if (option.equals("-histo")) {
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java	Wed Jul 05 23:09:40 2017 +0200
@@ -84,18 +84,18 @@
             params = new String[0];
         }
         ProcessArgumentMatcher ap = new ProcessArgumentMatcher(pidArg);
-        Collection<VirtualMachineDescriptor> vids = ap.getVirtualMachineDescriptors(JStack.class);
+        Collection<String> pids = ap.getVirtualMachinePids(JStack.class);
 
-        if (vids.isEmpty()) {
+        if (pids.isEmpty()) {
             System.err.println("Could not find any processes matching : '" + pidArg + "'");
             System.exit(1);
         }
 
-        for (VirtualMachineDescriptor vid : vids) {
-            if (vids.size() > 1) {
-                System.out.println("Pid:" + vid.id());
+        for (String pid : pids) {
+            if (pids.size() > 1) {
+                System.out.println("Pid:" + pid);
             }
-            runThreadDump(vid.id(), params);
+            runThreadDump(pid, params);
         }
     }
 
--- a/jdk/src/jdk.jconsole/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jconsole/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,13 @@
  * questions.
  */
 
+/**
+ * Defines the JMX graphical tool, jconsole, for monitoring and managing
+ * a running application.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.jconsole {
     requires transitive java.desktop;
     requires transitive java.management;
--- a/jdk/src/jdk.jdi/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Defines the Java Debugger Interface.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.jdi {
--- a/jdk/src/jdk.jdwp.agent/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jdwp.agent/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,6 +26,7 @@
 /**
  * Java Debug Wire Protocol.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.jdwp.agent {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Wed Jul 05 23:09:40 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
@@ -35,8 +35,12 @@
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
 import jdk.internal.jimage.BasicImageReader;
 import jdk.internal.jimage.ImageHeader;
 import jdk.internal.jimage.ImageLocation;
@@ -99,7 +103,7 @@
     }
 
     static class OptionsValues {
-        Task task = Task.LIST;
+        Task task = null;
         String directory = ".";
         String include = "";
         boolean fullVersion;
@@ -172,24 +176,31 @@
         }
 
         try {
-            List<String> unhandled = OPTION_HELPER.handleOptions(this, args);
+            String command;
+            String[] remaining = args;
+            try {
+                command = args[0];
+                options.task = Enum.valueOf(Task.class, args[0].toUpperCase(Locale.ENGLISH));
+                remaining = args.length > 1 ? Arrays.copyOfRange(args, 1, args.length)
+                                            : new String[0];
+            } catch (IllegalArgumentException ex) {
+                command = null;
+                options.task = null;
+            }
 
-            if(!unhandled.isEmpty()) {
-                try {
-                    options.task = Enum.valueOf(Task.class, unhandled.get(0).toUpperCase());
-                } catch (IllegalArgumentException ex) {
-                    throw TASK_HELPER.newBadArgs("err.not.a.task", unhandled.get(0));
-                }
+            // process arguments
+            List<String> unhandled = OPTION_HELPER.handleOptions(this, remaining);
+            for (String f : unhandled) {
+                options.jimages.add(new File(f));
+            }
 
-                for(int i = 1; i < unhandled.size(); i++) {
-                    options.jimages.add(new File(unhandled.get(i)));
-                }
-            } else if (!options.help && !options.version && !options.fullVersion) {
-                throw TASK_HELPER.newBadArgs("err.invalid.task", "<unspecified>");
+            if (options.task == null && !options.help && !options.version && !options.fullVersion) {
+                throw TASK_HELPER.newBadArgs("err.not.a.task",
+                    command != null ? command : "<unspecified>");
             }
 
             if (options.help) {
-                if (unhandled.isEmpty()) {
+                if (options.task == null) {
                     log.println(TASK_HELPER.getMessage("main.usage", PROGNAME));
                     Arrays.asList(RECOGNIZED_OPTIONS).stream()
                         .filter(option -> !option.isHidden())
@@ -203,15 +214,19 @@
                         log.println(TASK_HELPER.getMessage("main.usage." +
                                 options.task.toString().toLowerCase()));
                     } catch (MissingResourceException ex) {
-                        throw TASK_HELPER.newBadArgs("err.not.a.task", unhandled.get(0));
+                        throw TASK_HELPER.newBadArgs("err.not.a.task", command);
                     }
                 }
                 return EXIT_OK;
             }
 
             if (options.version || options.fullVersion) {
+                if (options.task == null && !unhandled.isEmpty()) {
+                    throw TASK_HELPER.newBadArgs("err.not.a.task",
+                        Stream.of(args).collect(Collectors.joining(" ")));
+                }
+
                 TASK_HELPER.showVersion(options.fullVersion);
-
                 if (unhandled.isEmpty()) {
                     return EXIT_OK;
                 }
@@ -435,7 +450,7 @@
                 iterate(this::listTitle, null, this::verify);
                 break;
             default:
-                throw TASK_HELPER.newBadArgs("err.invalid.task",
+                throw TASK_HELPER.newBadArgs("err.not.a.task",
                         options.task.name()).showUsage(true);
         }
         return true;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Wed Jul 05 23:09:40 2017 +0200
@@ -151,16 +151,8 @@
     @Override
     public void storeFiles(ResourcePool files) {
         try {
-            // populate targetOsName field up-front because it's used elsewhere.
-            Optional<ResourcePoolModule> javaBase = files.moduleView().findModule("java.base");
-            javaBase.ifPresent(mod -> {
-                // fill release information available from transformed "java.base" module!
-                ModuleDescriptor desc = mod.descriptor();
-                desc.osName().ifPresent(s -> {
-                    this.targetOsName = s;
-                });
-            });
-
+            this.targetOsName = files.moduleView().
+                findModule("java.base").get().osName();
             if (this.targetOsName == null) {
                 throw new PluginException("ModuleTarget attribute is missing for java.base module");
             }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java	Wed Jul 05 23:09:40 2017 +0200
@@ -43,6 +43,8 @@
 import java.util.stream.Stream;
 
 import jdk.internal.jimage.decompressor.Decompressor;
+import jdk.internal.module.ModuleInfo.Attributes;
+import jdk.internal.module.ModuleTarget;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.builder.ImageBuilder;
 import jdk.tools.jlink.plugin.PluginException;
@@ -298,6 +300,7 @@
             final ResourcePoolModule module;
             // lazily initialized
             ModuleDescriptor descriptor;
+            ModuleTarget target;
 
             LastModule(ResourcePoolModule module) {
                 this.module = module;
@@ -316,10 +319,28 @@
 
             @Override
             public ModuleDescriptor descriptor() {
-                if (descriptor == null) {
-                    descriptor = ResourcePoolManager.readModuleDescriptor(this);
+                initModuleAttributes();
+                return descriptor;
+            }
+
+            @Override
+            public String osName() {
+                initModuleAttributes();
+                return target != null? target.osName() : null;
+            }
+
+            @Override
+            public String osArch() {
+                initModuleAttributes();
+                return target != null? target.osArch() : null;
+            }
+
+            private void initModuleAttributes() {
+                if (this.descriptor == null) {
+                    Attributes attr = ResourcePoolManager.readModuleAttributes(this);
+                    this.descriptor = attr.descriptor();
+                    this.target = attr.target();
                 }
-                return descriptor;
             }
 
             @Override
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java	Wed Jul 05 23:09:40 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,6 +24,8 @@
  */
 package jdk.tools.jlink.internal;
 
+import java.lang.module.Configuration;
+import java.lang.module.ModuleFinder;
 import java.lang.reflect.Layer;
 import java.nio.ByteOrder;
 import java.nio.file.Path;
@@ -33,6 +35,8 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+
+import jdk.internal.module.ModulePath;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.builder.ImageBuilder;
@@ -147,8 +151,8 @@
         private final Path output;
         private final Set<String> modules;
         private final Set<String> limitmods;
-
         private final ByteOrder endian;
+        private final ModuleFinder finder;
 
         /**
          * jlink configuration,
@@ -160,31 +164,23 @@
          * @param endian Jimage byte order. Native order by default
          */
         public JlinkConfiguration(Path output,
-                List<Path> modulepaths,
-                Set<String> modules,
-                Set<String> limitmods,
-                ByteOrder endian) {
-            this.output = output;
-            this.modulepaths = modulepaths == null ? Collections.emptyList() : modulepaths;
-            this.modules = modules == null ? Collections.emptySet() : modules;
-            this.limitmods = limitmods == null ? Collections.emptySet() : limitmods;
-            this.endian = endian == null ? ByteOrder.nativeOrder() : endian;
-        }
+                                  List<Path> modulepaths,
+                                  Set<String> modules,
+                                  Set<String> limitmods,
+                                  ByteOrder endian) {
+            if (Objects.requireNonNull(modulepaths).isEmpty()) {
+                throw new IllegalArgumentException("Empty module path");
+            }
+            if (Objects.requireNonNull(modules).isEmpty()) {
+                throw new IllegalArgumentException("Empty modules");
+            }
 
-        /**
-         * jlink configuration,
-         *
-         * @param output Output directory, must not exist.
-         * @param modulepaths Modules paths
-         * @param modules Root modules to resolve
-         * @param limitmods Limit the universe of observable modules
-         */
-        public JlinkConfiguration(Path output,
-                List<Path> modulepaths,
-                Set<String> modules,
-                Set<String> limitmods) {
-            this(output, modulepaths, modules, limitmods,
-                    ByteOrder.nativeOrder());
+            this.output = output;
+            this.modulepaths = modulepaths;
+            this.modules = modules;
+            this.limitmods = Objects.requireNonNull(limitmods);
+            this.endian = Objects.requireNonNull(endian);
+            this.finder = moduleFinder();
         }
 
         /**
@@ -222,6 +218,45 @@
             return limitmods;
         }
 
+        /**
+         * Returns {@link ModuleFinder} that finds all observable modules
+         * for this jlink configuration.
+         */
+        public ModuleFinder finder() {
+            return finder;
+        }
+
+        /**
+         * Returns a {@link Configuration} of the given module path,
+         * root modules with full service binding.
+         */
+        public Configuration resolveAndBind()
+        {
+            return Configuration.empty().resolveAndBind(finder,
+                                                        ModuleFinder.of(),
+                                                        modules);
+        }
+
+        /**
+         * Returns a {@link Configuration} of the given module path,
+         * root modules with no service binding.
+         */
+        public Configuration resolve()
+        {
+            return Configuration.empty().resolve(finder,
+                                                 ModuleFinder.of(),
+                                                 modules);
+        }
+
+        private ModuleFinder moduleFinder() {
+            Path[] entries = modulepaths.toArray(new Path[0]);
+            ModuleFinder finder = ModulePath.of(Runtime.version(), true, entries);
+            if (!limitmods.isEmpty()) {
+                finder = JlinkTask.limitFinder(finder, limitmods, modules);
+            }
+            return finder;
+        }
+
         @Override
         public String toString() {
             StringBuilder builder = new StringBuilder();
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Wed Jul 05 23:09:40 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
@@ -54,7 +54,6 @@
 import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.builder.DefaultImageBuilder;
 import jdk.tools.jlink.plugin.Plugin;
-import jdk.internal.module.Checks;
 import jdk.internal.module.ModulePath;
 import jdk.internal.module.ModuleResolution;
 
@@ -111,6 +110,12 @@
             Path path = Paths.get(arg);
             task.options.output = path;
         }, "--output"),
+        new Option<JlinkTask>(false, (task, opt, arg) -> {
+            task.options.bindServices = true;
+        }, "--bind-services"),
+        new Option<JlinkTask>(false, (task, opt, arg) -> {
+            task.options.suggestProviders = true;
+        }, "--suggest-providers", "", true),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
             String[] values = arg.split("=");
             // check values
@@ -142,6 +147,9 @@
             }
         }, "--endian"),
         new Option<JlinkTask>(false, (task, opt, arg) -> {
+            task.options.verbose = true;
+        }, "--verbose", "-v"),
+        new Option<JlinkTask>(false, (task, opt, arg) -> {
             task.options.version = true;
         }, "--version"),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
@@ -186,6 +194,7 @@
     static class OptionsValues {
         boolean help;
         String  saveoptsfile;
+        boolean verbose;
         boolean version;
         boolean fullVersion;
         final List<Path> modulePath = new ArrayList<>();
@@ -196,6 +205,8 @@
         Path packagedModulesPath;
         ByteOrder endian = ByteOrder.nativeOrder();
         boolean ignoreSigning = false;
+        boolean bindServices = false;
+        boolean suggestProviders = false;
     }
 
     int run(String[] args) {
@@ -204,7 +215,11 @@
                    new PrintWriter(System.err, true));
         }
         try {
-            optionsHelper.handleOptionsNoUnhandled(this, args);
+            List<String> remaining = optionsHelper.handleOptions(this, args);
+            if (remaining.size() > 0 && !options.suggestProviders) {
+                throw taskHelper.newBadArgs("err.orphan.arguments", toString(remaining))
+                                .showUsage(true);
+            }
             if (options.help) {
                 optionsHelper.showHelp(PROGNAME);
                 return EXIT_OK;
@@ -218,17 +233,24 @@
                 return EXIT_OK;
             }
 
-            if (taskHelper.getExistingImage() == null) {
-                if (options.modulePath.isEmpty()) {
-                    throw taskHelper.newBadArgs("err.modulepath.must.be.specified").showUsage(true);
-                }
-                createImage();
-            } else {
+            if (taskHelper.getExistingImage() != null) {
                 postProcessOnly(taskHelper.getExistingImage());
+                return EXIT_OK;
             }
 
-            if (options.saveoptsfile != null) {
-                Files.write(Paths.get(options.saveoptsfile), getSaveOpts().getBytes());
+            if (options.modulePath.isEmpty()) {
+                throw taskHelper.newBadArgs("err.modulepath.must.be.specified")
+                                .showUsage(true);
+            }
+
+            JlinkConfiguration config = initJlinkConfig();
+            if (options.suggestProviders) {
+                suggestProviders(config, remaining);
+            } else {
+                createImage(config);
+                if (options.saveoptsfile != null) {
+                    Files.write(Paths.get(options.saveoptsfile), getSaveOpts().getBytes());
+                }
             }
 
             return EXIT_OK;
@@ -267,25 +289,13 @@
         Objects.requireNonNull(config.getOutput());
         plugins = plugins == null ? new PluginsConfiguration() : plugins;
 
-        if (config.getModulepaths().isEmpty()) {
-            throw new IllegalArgumentException("Empty module paths");
-        }
-
-        ModuleFinder finder = newModuleFinder(config.getModulepaths(),
-                                              config.getLimitmods(),
-                                              config.getModules());
-
-        if (config.getModules().isEmpty()) {
-            throw new IllegalArgumentException("No modules to add");
-        }
-
         // First create the image provider
         ImageProvider imageProvider =
-                createImageProvider(finder,
-                                    config.getModules(),
-                                    config.getByteOrder(),
+                createImageProvider(config,
                                     null,
                                     IGNORE_SIGNING_DEFAULT,
+                                    false,
+                                    false,
                                     null);
 
         // Then create the Plugin Stack
@@ -320,20 +330,24 @@
 
     // the token for "all modules on the module path"
     private static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
-    private void createImage() throws Exception {
-        if (options.output == null) {
-            throw taskHelper.newBadArgs("err.output.must.be.specified").showUsage(true);
-        }
-
+    private JlinkConfiguration initJlinkConfig() throws BadArgs {
         if (options.addMods.isEmpty()) {
             throw taskHelper.newBadArgs("err.mods.must.be.specified", "--add-modules")
-                    .showUsage(true);
+                .showUsage(true);
         }
 
         Set<String> roots = new HashSet<>();
         for (String mod : options.addMods) {
             if (mod.equals(ALL_MODULE_PATH)) {
-                ModuleFinder finder = modulePathFinder();
+                Path[] entries = options.modulePath.toArray(new Path[0]);
+                ModuleFinder finder = ModulePath.of(Runtime.version(), true, entries);
+                if (!options.limitMods.isEmpty()) {
+                    // finder for the observable modules specified in
+                    // the --module-path and --limit-modules options
+                    finder = limitFinder(finder, options.limitMods, Collections.emptySet());
+                }
+
+                // all observable modules are roots
                 finder.findAll()
                       .stream()
                       .map(ModuleReference::descriptor)
@@ -344,40 +358,34 @@
             }
         }
 
-        ModuleFinder finder = newModuleFinder(options.modulePath,
-                                              options.limitMods,
-                                              roots);
+        return new JlinkConfiguration(options.output,
+                                      options.modulePath,
+                                      roots,
+                                      options.limitMods,
+                                      options.endian);
+    }
 
+    private void createImage(JlinkConfiguration config) throws Exception {
+        if (options.output == null) {
+            throw taskHelper.newBadArgs("err.output.must.be.specified").showUsage(true);
+        }
 
         // First create the image provider
-        ImageProvider imageProvider = createImageProvider(finder,
-                                                          roots,
-                                                          options.endian,
+        ImageProvider imageProvider = createImageProvider(config,
                                                           options.packagedModulesPath,
                                                           options.ignoreSigning,
+                                                          options.bindServices,
+                                                          options.verbose,
                                                           log);
 
         // Then create the Plugin Stack
-        ImagePluginStack stack = ImagePluginConfiguration.
-                parseConfiguration(taskHelper.getPluginsConfig(options.output, options.launchers));
+        ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(
+            taskHelper.getPluginsConfig(options.output, options.launchers));
 
         //Ask the stack to proceed
         stack.operate(imageProvider);
     }
 
-    /**
-     * Returns a module finder to find the observable modules specified in
-     * the --module-path and --limit-modules options
-     */
-    private ModuleFinder modulePathFinder() {
-        Path[] entries = options.modulePath.toArray(new Path[0]);
-        ModuleFinder finder = ModulePath.of(Runtime.version(), true, entries);
-        if (!options.limitMods.isEmpty()) {
-            finder = limitFinder(finder, options.limitMods, Collections.emptySet());
-        }
-        return finder;
-    }
-
     /*
      * Returns a module finder of the given module path that limits
      * the observable modules to those in the transitive closure of
@@ -406,29 +414,32 @@
         return Paths.get(uri);
     }
 
-    private static ImageProvider createImageProvider(ModuleFinder finder,
-                                                     Set<String> roots,
-                                                     ByteOrder order,
+
+    private static ImageProvider createImageProvider(JlinkConfiguration config,
                                                      Path retainModulesPath,
                                                      boolean ignoreSigning,
+                                                     boolean bindService,
+                                                     boolean verbose,
                                                      PrintWriter log)
             throws IOException
     {
-        if (roots.isEmpty()) {
-            throw new IllegalArgumentException("empty modules and limitmods");
-        }
+        Configuration cf = bindService ? config.resolveAndBind()
+                                       : config.resolve();
 
-        Configuration cf = Configuration.empty()
-                .resolve(finder,
-                         ModuleFinder.of(),
-                         roots);
+        if (verbose && log != null) {
+            // print modules to be linked in
+            cf.modules().stream()
+              .sorted(Comparator.comparing(ResolvedModule::name))
+              .forEach(rm -> log.format("module %s (%s)%n",
+                                        rm.name(), rm.reference().location().get()));
 
-        // emit warning for modules that end with a digit
-        cf.modules().stream()
-            .map(ResolvedModule::name)
-            .filter(mn -> !Checks.hasLegalModuleNameLastCharacter(mn))
-            .forEach(mn -> System.err.println("WARNING: Module name \""
-                                              + mn + "\" may soon be illegal"));
+            // print provider info
+            Set<ModuleReference> references = cf.modules().stream()
+                .map(ResolvedModule::reference).collect(Collectors.toSet());
+
+            String msg = String.format("%n%s:", taskHelper.getMessage("providers.header"));
+            printProviders(log, msg, references);
+        }
 
         // emit a warning for any incubating modules in the configuration
         if (log != null) {
@@ -446,16 +457,16 @@
 
         Map<String, Path> mods = cf.modules().stream()
             .collect(Collectors.toMap(ResolvedModule::name, JlinkTask::toPathLocation));
-        return new ImageHelper(cf, mods, order, retainModulesPath, ignoreSigning);
+        return new ImageHelper(cf, mods, config.getByteOrder(), retainModulesPath, ignoreSigning);
     }
 
     /*
      * Returns a ModuleFinder that limits observability to the given root
      * modules, their transitive dependences, plus a set of other modules.
      */
-    private static ModuleFinder limitFinder(ModuleFinder finder,
-                                            Set<String> roots,
-                                            Set<String> otherMods) {
+    public static ModuleFinder limitFinder(ModuleFinder finder,
+                                           Set<String> roots,
+                                           Set<String> otherMods) {
 
         // resolve all root modules
         Configuration cf = Configuration.empty()
@@ -492,6 +503,147 @@
         };
     }
 
+    /*
+     * Returns a map of each service type to the modules that use it
+     */
+    private static Map<String, Set<String>> uses(Set<ModuleReference> modules) {
+        // collects the services used by the modules and print uses
+        Map<String, Set<String>> uses = new HashMap<>();
+        modules.stream()
+               .map(ModuleReference::descriptor)
+               .forEach(md -> md.uses().forEach(s ->
+                   uses.computeIfAbsent(s, _k -> new HashSet<>()).add(md.name()))
+               );
+        return uses;
+    }
+
+    private static void printProviders(PrintWriter log,
+                                       String header,
+                                       Set<ModuleReference> modules) {
+        printProviders(log, header, modules, uses(modules));
+    }
+
+    /*
+     * Prints the providers that are used by the services specified in
+     * the given modules.
+     *
+     * The specified uses maps a service type name to the modules
+     * using the service type and that may or may not be present
+     * the given modules.
+     */
+    private static void printProviders(PrintWriter log,
+                                       String header,
+                                       Set<ModuleReference> modules,
+                                       Map<String, Set<String>> uses) {
+        if (modules.isEmpty())
+            return;
+
+        // Build a map of a service type to the provider modules
+        Map<String, Set<ModuleDescriptor>> providers = new HashMap<>();
+        modules.stream()
+            .map(ModuleReference::descriptor)
+            .forEach(md -> {
+                md.provides().stream()
+                  .filter(p -> uses.containsKey(p.service()))
+                  .forEach(p -> providers.computeIfAbsent(p.service(), _k -> new HashSet<>())
+                                         .add(md));
+            });
+
+        if (!providers.isEmpty()) {
+            log.println(header);
+        }
+
+        // print the providers of the service types used by the specified modules
+        // sorted by the service type name and then provider's module name
+        providers.entrySet().stream()
+            .sorted(Map.Entry.comparingByKey())
+            .forEach(e -> {
+                String service = e.getKey();
+                e.getValue().stream()
+                 .sorted(Comparator.comparing(ModuleDescriptor::name))
+                 .forEach(md ->
+                     md.provides().stream()
+                       .filter(p -> p.service().equals(service))
+                       .forEach(p -> log.format("  module %s provides %s, used by %s%n",
+                                                md.name(), p.service(),
+                                                uses.get(p.service()).stream()
+                                                    .sorted()
+                                                    .collect(Collectors.joining(","))))
+                 );
+            });
+    }
+
+    private void suggestProviders(JlinkConfiguration config, List<String> args)
+        throws BadArgs
+    {
+        if (args.size() > 1) {
+            throw taskHelper.newBadArgs("err.orphan.argument",
+                                        toString(args.subList(1, args.size())))
+                            .showUsage(true);
+        }
+
+        if (options.bindServices) {
+            log.println(taskHelper.getMessage("no.suggested.providers"));
+            return;
+        }
+
+        ModuleFinder finder = config.finder();
+        if (args.isEmpty()) {
+            // print providers used by the modules resolved without service binding
+            Configuration cf = config.resolve();
+            Set<ModuleReference> mrefs = cf.modules().stream()
+                .map(ResolvedModule::reference)
+                .collect(Collectors.toSet());
+
+            // print uses of the modules that would be linked into the image
+            mrefs.stream()
+                 .sorted(Comparator.comparing(mref -> mref.descriptor().name()))
+                 .forEach(mref -> {
+                     ModuleDescriptor md = mref.descriptor();
+                     log.format("module %s located (%s)%n", md.name(),
+                                mref.location().get());
+                     md.uses().stream().sorted()
+                       .forEach(s -> log.format("    uses %s%n", s));
+                 });
+
+            String msg = String.format("%n%s:", taskHelper.getMessage("suggested.providers.header"));
+            printProviders(log, msg, finder.findAll(), uses(mrefs));
+
+        } else {
+            // comma-separated service types, if specified
+            Set<String> names = Stream.of(args.get(0).split(","))
+                .collect(Collectors.toSet());
+            // find the modules that provide the specified service
+            Set<ModuleReference> mrefs = finder.findAll().stream()
+                .filter(mref -> mref.descriptor().provides().stream()
+                                    .map(ModuleDescriptor.Provides::service)
+                                    .anyMatch(names::contains))
+                .collect(Collectors.toSet());
+
+            // the specified services may or may not be in the modules that
+            // would be linked in.  So find uses declared in all observable modules
+            Map<String, Set<String>> uses = uses(finder.findAll());
+
+            // check if any name given on the command line are unused service
+            mrefs.stream()
+                 .flatMap(mref -> mref.descriptor().provides().stream()
+                                      .map(ModuleDescriptor.Provides::service))
+                 .forEach(names::remove);
+            if (!names.isEmpty()) {
+                log.println(taskHelper.getMessage("warn.unused.services",
+                                                  toString(names)));
+            }
+
+            String msg = String.format("%n%s:", taskHelper.getMessage("suggested.providers.header"));
+            printProviders(log, msg, mrefs, uses);
+        }
+    }
+
+    private static String toString(Collection<String> collection) {
+        return collection.stream().sorted()
+                         .collect(Collectors.joining(","));
+    }
+
     private String getSaveOpts() {
         StringBuilder sb = new StringBuilder();
         sb.append('#').append(new Date()).append("\n");
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolConfiguration.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolConfiguration.java	Wed Jul 05 23:09:40 2017 +0200
@@ -66,9 +66,6 @@
 
         md.version().ifPresent(builder::version);
         md.mainClass().ifPresent(builder::mainClass);
-        md.osName().ifPresent(builder::osName);
-        md.osArch().ifPresent(builder::osArch);
-        md.osVersion().ifPresent(builder::osVersion);
 
         return builder.build();
     }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java	Wed Jul 05 23:09:40 2017 +0200
@@ -35,7 +35,10 @@
 import java.util.Set;
 import java.util.stream.Stream;
 import jdk.internal.jimage.decompressor.CompressedResourceHeader;
-import jdk.internal.loader.ResourceHelper;
+import jdk.internal.module.Resources;
+import jdk.internal.module.ModuleInfo;
+import jdk.internal.module.ModuleInfo.Attributes;
+import jdk.internal.module.ModuleTarget;
 import jdk.tools.jlink.plugin.ResourcePool;
 import jdk.tools.jlink.plugin.ResourcePoolBuilder;
 import jdk.tools.jlink.plugin.ResourcePoolEntry;
@@ -47,8 +50,8 @@
  * A manager for pool of resources.
  */
 public class ResourcePoolManager {
-    // utility to read ModuleDescriptor of the given ResourcePoolModule
-    static ModuleDescriptor readModuleDescriptor(ResourcePoolModule mod) {
+    // utility to read Module Attributes of the given ResourcePoolModule
+    static Attributes readModuleAttributes(ResourcePoolModule mod) {
         String p = "/" + mod.name() + "/module-info.class";
         Optional<ResourcePoolEntry> content = mod.findEntry(p);
         if (!content.isPresent()) {
@@ -57,9 +60,9 @@
         }
         ByteBuffer bb = ByteBuffer.wrap(content.get().contentBytes());
         try {
-            return ModuleDescriptor.read(bb);
+            return ModuleInfo.read(bb, null);
         } catch (RuntimeException re) {
-            throw new RuntimeException("module descriptor cannot be read for " + mod.name(), re);
+            throw new RuntimeException("module info cannot be read for " + mod.name(), re);
         }
     }
 
@@ -68,7 +71,7 @@
      */
     public static boolean isNamedPackageResource(String path) {
         return (path.endsWith(".class") && !path.endsWith("module-info.class")) ||
-                !ResourceHelper.isSimpleResource(path);
+                Resources.canEncapsulate(path);
     }
 
     class ResourcePoolModuleImpl implements ResourcePoolModule {
@@ -76,6 +79,8 @@
         final Map<String, ResourcePoolEntry> moduleContent = new LinkedHashMap<>();
         // lazily initialized
         private ModuleDescriptor descriptor;
+        private ModuleTarget target;
+
         final String name;
 
         private ResourcePoolModuleImpl(String name) {
@@ -100,10 +105,28 @@
 
         @Override
         public ModuleDescriptor descriptor() {
-            if (descriptor == null) {
-                descriptor = readModuleDescriptor(this);
+            initModuleAttributes();
+            return descriptor;
+        }
+
+        @Override
+        public String osName() {
+            initModuleAttributes();
+            return target != null? target.osName() : null;
+        }
+
+        @Override
+        public String osArch() {
+            initModuleAttributes();
+            return target != null? target.osArch() : null;
+        }
+
+        private void initModuleAttributes() {
+            if (this.descriptor == null) {
+                Attributes attr = readModuleAttributes(this);
+                this.descriptor = attr.descriptor();
+                this.target = attr.target();
             }
-            return descriptor;
         }
 
         @Override
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Wed Jul 05 23:09:40 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
@@ -46,6 +46,7 @@
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 import java.util.Set;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import jdk.tools.jlink.internal.plugins.ExcludeJmodSectionPlugin;
@@ -101,8 +102,15 @@
         final boolean hidden;
         final String name;
         final String shortname;
+        final boolean terminalOption;
 
-        public Option(boolean hasArg, Processing<T> processing, boolean hidden, String name, String shortname) {
+        public Option(boolean hasArg,
+                      Processing<T> processing,
+                      boolean hidden,
+                      String name,
+                      String shortname,
+                      boolean isTerminal)
+        {
             if (!name.startsWith("--")) {
                 throw new RuntimeException("option name missing --, " + name);
             }
@@ -115,24 +123,33 @@
             this.hidden = hidden;
             this.name = name;
             this.shortname = shortname;
+            this.terminalOption = isTerminal;
+        }
+
+        public Option(boolean hasArg, Processing<T> processing, String name, String shortname, boolean isTerminal) {
+            this(hasArg, processing, false, name, shortname, isTerminal);
         }
 
         public Option(boolean hasArg, Processing<T> processing, String name, String shortname) {
-            this(hasArg, processing, false, name, shortname);
+            this(hasArg, processing, false, name, shortname, false);
         }
 
         public Option(boolean hasArg, Processing<T> processing, boolean hidden, String name) {
-            this(hasArg, processing, hidden, name, "");
+            this(hasArg, processing, hidden, name, "", false);
         }
 
         public Option(boolean hasArg, Processing<T> processing, String name) {
-            this(hasArg, processing, false, name, "");
+            this(hasArg, processing, false, name, "", false);
         }
 
         public boolean isHidden() {
             return hidden;
         }
 
+        public boolean isTerminal() {
+            return terminalOption;
+        }
+
         public boolean matches(String opt) {
             return opt.equals(name) ||
                    opt.equals(shortname) ||
@@ -179,12 +196,12 @@
     private static class PluginOption extends Option<PluginsHelper> {
         public PluginOption(boolean hasArg,
                 Processing<PluginsHelper> processing, boolean hidden, String name, String shortname) {
-            super(hasArg, processing, hidden, name, shortname);
+            super(hasArg, processing, hidden, name, shortname, false);
         }
 
         public PluginOption(boolean hasArg,
                 Processing<PluginsHelper> processing, boolean hidden, String name) {
-            super(hasArg, processing, hidden, name, "");
+            super(hasArg, processing, hidden, name, "", false);
         }
 
         public String resourcePrefix() {
@@ -498,21 +515,13 @@
             return null;
         }
 
-        // used by jimage. Return unhandled arguments like "create", "describe".
+        /**
+         * Handles all options.  This method stops processing the argument
+         * at the first non-option argument i.e. not starts with `-`, or
+         * at the first terminal option and returns the remaining arguments,
+         * if any.
+         */
         public List<String> handleOptions(T task, String[] args) throws BadArgs {
-            return handleOptions(task, args, true);
-        }
-
-        // used by jlink. No unhandled arguments like "create", "describe".
-        void handleOptionsNoUnhandled(T task, String[] args) throws BadArgs {
-            handleOptions(task, args, false);
-        }
-
-        // shared code that handles options for both jlink and jimage. jimage uses arguments like
-        // "create", "describe" etc. as "task names". Those arguments are unhandled here and returned
-        // as "unhandled arguments list". jlink does not want such arguments. "collectUnhandled" flag
-        // tells whether to allow for unhandled arguments or not.
-        private List<String> handleOptions(T task, String[] args, boolean collectUnhandled) throws BadArgs {
             // findbugs warning, copy instead of keeping a reference.
             command = Arrays.copyOf(args, args.length);
 
@@ -521,7 +530,6 @@
             // Unit tests can call Task multiple time in same JVM.
             pluginOptions = new PluginsHelper(null);
 
-            List<String> rest = collectUnhandled? new ArrayList<>() : null;
             // process options
             for (int i = 0; i < args.length; i++) {
                 if (args[i].startsWith("-")) {
@@ -531,7 +539,6 @@
                     if (option == null) {
                         pluginOption = pluginOptions.getOption(name);
                         if (pluginOption == null) {
-
                             throw new BadArgs("err.unknown.option", name).
                                     showUsage(true);
                         }
@@ -556,20 +563,23 @@
                         pluginOption.process(pluginOptions, name, param);
                     } else {
                         option.process(task, name, param);
+                        if (option.isTerminal()) {
+                            return ++i < args.length
+                                        ? Stream.of(Arrays.copyOfRange(args, i, args.length))
+                                                .collect(Collectors.toList())
+                                        : Collections.emptyList();
+
+                        }
                     }
                     if (opt.ignoreRest()) {
                         i = args.length;
                     }
                 } else {
-                    if (collectUnhandled) {
-                        rest.add(args[i]);
-                    } else {
-                        throw new BadArgs("err.orphan.argument", args[i]).
-                            showUsage(true);
-                    }
+                    return Stream.of(Arrays.copyOfRange(args, i, args.length))
+                                 .collect(Collectors.toList());
                 }
             }
-            return rest;
+            return Collections.emptyList();
         }
 
         private Option<T> getOption(String name) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java	Wed Jul 05 23:09:40 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
@@ -34,6 +34,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.lang.module.ModuleFinder;
+import java.nio.ByteOrder;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -93,9 +94,12 @@
 
     public void build() throws IOException {
         // jlink main arguments
-        Jlink.JlinkConfiguration jlinkConfig = new Jlink.JlinkConfiguration(
-            new File("").toPath(), // Unused
-            modulePath, addModules, limitModules);
+        Jlink.JlinkConfiguration jlinkConfig =
+            new Jlink.JlinkConfiguration(new File("").toPath(), // Unused
+                                         modulePath,
+                                         addModules,
+                                         limitModules,
+                                         ByteOrder.nativeOrder());
 
         // plugin configuration
         List<Plugin> plugins = new ArrayList<Plugin>();
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java	Wed Jul 05 23:09:40 2017 +0200
@@ -115,7 +115,7 @@
     @Override
     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
         ResourcePoolModule javaBase = in.moduleView().findModule("java.base").get();
-        String[] jvmlibs = jvmlibs(javaBase.descriptor().osName().get());
+        String[] jvmlibs = jvmlibs(javaBase.osName());
         TreeSet<Jvm> existing = new TreeSet<>(new JvmComparator());
         TreeSet<Jvm> removed = new TreeSet<>(new JvmComparator());
         if (!keepAll) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Wed Jul 05 23:09:40 2017 +0200
@@ -137,15 +137,13 @@
         javaBase.ifPresent(mod -> {
             // fill release information available from transformed "java.base" module!
             ModuleDescriptor desc = mod.descriptor();
-            desc.osName().ifPresent(s -> {
-                release.put("OS_NAME", quote(s));
-            });
-            desc.osVersion().ifPresent(s -> release.put("OS_VERSION", quote(s)));
-            desc.osArch().ifPresent(s -> release.put("OS_ARCH", quote(s)));
             desc.version().ifPresent(s -> release.put("JAVA_VERSION",
                     quote(parseVersion(s.toString()))));
             desc.version().ifPresent(s -> release.put("JAVA_FULL_VERSION",
                     quote(s.toString())));
+
+            release.put("OS_NAME", quote(mod.osName()));
+            release.put("OS_ARCH", quote(mod.osArch()));
         });
 
         // put topological sorted module names separated by space
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java	Wed Jul 05 23:09:40 2017 +0200
@@ -52,6 +52,7 @@
 import jdk.internal.module.ModuleInfo.Attributes;
 import jdk.internal.module.ModuleInfoExtender;
 import jdk.internal.module.ModuleResolution;
+import jdk.internal.module.ModuleTarget;
 import jdk.internal.module.SystemModules;
 import jdk.internal.org.objectweb.asm.Attribute;
 import jdk.internal.org.objectweb.asm.ClassReader;
@@ -206,12 +207,12 @@
             // add ModulePackages attribute if this module contains some packages
             // and ModulePackages is not present
             this.addModulePackages = packages.size() > 0 && !hasModulePackages();
+
             // drop target attribute only if any OS property is present
-            if (dropModuleTarget) {
-                this.dropModuleTarget =
-                    descriptor.osName().isPresent() ||
-                    descriptor.osArch().isPresent() ||
-                    descriptor.osVersion().isPresent();
+            ModuleTarget target = attrs.target();
+            if (dropModuleTarget && target != null) {
+                this.dropModuleTarget = (target.osName() != null)
+                                        || (target.osArch() != null);
             } else {
                 this.dropModuleTarget = false;
             }
@@ -230,6 +231,10 @@
             return packages;
         }
 
+        ModuleTarget target() {
+            return attrs.target();
+        }
+
         ModuleHashes recordedHashes() {
             return attrs.recordedHashes();
         }
@@ -372,7 +377,7 @@
             }
 
             void dropModuleTarget() {
-                extender.targetPlatform("", "", "");
+                extender.targetPlatform("", "");
             }
 
             byte[] getBytes() throws IOException {
@@ -399,6 +404,10 @@
             "java/lang/module/ModuleDescriptor$Exports$Modifier";
         private static final String OPENS_MODIFIER_CLASSNAME =
             "java/lang/module/ModuleDescriptor$Opens$Modifier";
+        private static final String MODULE_TARGET_CLASSNAME  =
+            "jdk/internal/module/ModuleTarget";
+        private static final String MODULE_TARGET_ARRAY_SIGNATURE  =
+            "[Ljdk/internal/module/ModuleTarget;";
         private static final String MODULE_HASHES_ARRAY_SIGNATURE  =
             "[Ljdk/internal/module/ModuleHashes;";
         private static final String MODULE_RESOLUTION_CLASSNAME  =
@@ -414,6 +423,7 @@
 
         private final int BUILDER_VAR    = 0;
         private final int MD_VAR         = 1;  // variable for ModuleDescriptor
+        private final int MT_VAR         = 1;  // variable for ModuleTarget
         private final int MH_VAR         = 1;  // variable for ModuleHashes
         private int nextLocalVar         = 2;  // index to next local variable
 
@@ -515,11 +525,10 @@
             if (entry.moduleName().equals("java.base")) {
                 moduleInfo = new ModuleInfo(entry.contentBytes(), packages, false);
                 ModuleDescriptor md = moduleInfo.descriptor;
-                // drop Moduletarget attribute only if java.base has all OS properties
-                // otherwise, retain it
-                if (dropModuleTarget &&
-                        md.osName().isPresent() && md.osArch().isPresent() &&
-                        md.osVersion().isPresent()) {
+                // drop ModuleTarget attribute if java.base has all OS properties
+                ModuleTarget target = moduleInfo.target();
+                if (dropModuleTarget
+                    && (target.osName() != null) && (target.osArch() != null)) {
                     dropModuleTarget = true;
                 } else {
                     dropModuleTarget = false;
@@ -584,15 +593,20 @@
 
             // generate SystemModules::descriptors
             genDescriptorsMethod();
+
+            // generate SystemModules::targets
+            genTargetsMethod();
+
             // generate SystemModules::hashes
             genHashesMethod();
+
             // generate SystemModules::moduleResolutions
             genModuleResolutionsMethod();
 
             return cw;
         }
 
-        /*
+        /**
          * Generate bytecode for SystemModules::descriptors method
          */
         private void genDescriptorsMethod() {
@@ -616,10 +630,47 @@
             mv.visitInsn(ARETURN);
             mv.visitMaxs(0, 0);
             mv.visitEnd();
-
         }
 
-        /*
+        /**
+         * Generate bytecode for SystemModules::targets method
+         */
+        private void genTargetsMethod() {
+            MethodVisitor mv = cw.visitMethod(ACC_PUBLIC+ACC_STATIC,
+                                              "targets",
+                                              "()" + MODULE_TARGET_ARRAY_SIGNATURE,
+                                              "()" + MODULE_TARGET_ARRAY_SIGNATURE,
+                                              null);
+            mv.visitCode();
+            pushInt(mv, moduleInfos.size());
+            mv.visitTypeInsn(ANEWARRAY, MODULE_TARGET_CLASSNAME);
+            mv.visitVarInsn(ASTORE, MT_VAR);
+
+            for (int index=0; index < moduleInfos.size(); index++) {
+                ModuleInfo minfo = moduleInfos.get(index);
+                if (minfo.target() != null && !minfo.dropModuleTarget) {
+                    mv.visitVarInsn(ALOAD, MT_VAR);
+                    pushInt(mv, index);
+
+                    // new ModuleTarget(String, String)
+                    mv.visitTypeInsn(NEW, MODULE_TARGET_CLASSNAME);
+                    mv.visitInsn(DUP);
+                    mv.visitLdcInsn(minfo.target().osName());
+                    mv.visitLdcInsn(minfo.target().osArch());
+                    mv.visitMethodInsn(INVOKESPECIAL, MODULE_TARGET_CLASSNAME,
+                        "<init>", "(Ljava/lang/String;Ljava/lang/String;)V", false);
+
+                    mv.visitInsn(AASTORE);
+                }
+            }
+
+            mv.visitVarInsn(ALOAD, MT_VAR);
+            mv.visitInsn(ARETURN);
+            mv.visitMaxs(0, 0);
+            mv.visitEnd();
+        }
+
+        /**
          * Generate bytecode for SystemModules::hashes method
          */
         private void genHashesMethod() {
@@ -647,10 +698,9 @@
             hmv.visitInsn(ARETURN);
             hmv.visitMaxs(0, 0);
             hmv.visitEnd();
-
         }
 
-        /*
+        /**
          * Generate bytecode for SystemModules::methodResoultions method
          */
         private void genModuleResolutionsMethod() {
@@ -749,6 +799,7 @@
             final ModuleDescriptor md;
             final Set<String> packages;
             final int index;
+
             ModuleDescriptorBuilder(ModuleDescriptor md, Set<String> packages, int index) {
                 if (md.isAutomatic()) {
                     throw new InternalError("linking automatic module is not supported");
@@ -786,11 +837,6 @@
                 // main class
                 md.mainClass().ifPresent(this::mainClass);
 
-                // os name, arch, version
-                targetPlatform(md.osName().orElse(null),
-                               md.osArch().orElse(null),
-                               md.osVersion().orElse(null));
-
                 putModuleDescriptor();
             }
 
@@ -1088,25 +1134,6 @@
                 mv.visitInsn(POP);
             }
 
-            /*
-             * Invoke Builder.osName(String name)
-             *        Builder.osArch(String arch)
-             *        Builder.osVersion(String version)
-             */
-            void targetPlatform(String osName, String osArch, String osVersion) {
-                if (osName != null) {
-                    invokeBuilderMethod("osName", osName);
-                }
-
-                if (osArch != null) {
-                    invokeBuilderMethod("osArch", osArch);
-                }
-
-                if (osVersion != null) {
-                    invokeBuilderMethod("osVersion", osVersion);
-                }
-            }
-
             void invokeBuilderMethod(String methodName, String value) {
                 mv.visitVarInsn(ALOAD, BUILDER_VAR);
                 mv.visitLdcInsn(value);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ResourcePoolModule.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ResourcePoolModule.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,7 @@
 import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Stream;
+import jdk.internal.module.ModuleTarget;
 
 /**
   * Link-time representation of a module.
@@ -57,6 +58,20 @@
     public ModuleDescriptor descriptor();
 
     /**
+     * The module target OS name for this module.
+     *
+     * @return The module target OS name
+     */
+    public String osName();
+
+    /**
+     * The module target OS arch for this module.
+     *
+     * @return The module target OS arch
+     */
+    public String osArch();
+
+    /**
      * Retrieves all the packages located in this module.
      *
      * @return The set of packages.
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Wed Jul 05 23:09:40 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,15 +24,12 @@
 #
 
 main.usage.summary=\
-Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output\n\
-\<path> use --help for a list of possible options
+Usage: {0} <options> --module-path <modulepath> --add-modules <module>[,<module>...]\n\
+\Use --help for a list of possible options
 
 main.usage=\
-Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output\n\
-\<path> Possible options include:
-
-error.prefix=Error:
-warn.prefix=Warning:
+Usage: {0} <options> --module-path <modulepath> --add-modules <module>[,<module>...]\n\
+\Possible options include:
 
 main.opt.help=\
 \  -h, --help                            Print this help message
@@ -54,9 +51,18 @@
 \      --output <path>                   Location of output path
 
 main.opt.launcher=\
-\      --launcher <command>=<module>     Launcher command name for the module\n\
-\      --launcher <command>=<module>/<main>\n\
-\                                        Launcher command name for the module and the main class
+\      --launcher <name>=<module>[/<mainclass>]\n\
+\                                        Add a launcher command of the given\n\
+\                                        name for the module and the main class\n\
+\                                        if specified  
+
+main.opt.bind-services=\
+\      --bind-services                   Do full service binding
+
+main.opt.suggest-providers=\
+\      --suggest-providers [<name>,...]  Suggest providers of services used by\n\
+\                                        the modules that would be linked, or\n\
+\                                        of the given service types
 
 main.command.files=\
 \      @<filename>                       Read options from file
@@ -75,6 +81,9 @@
 \                                        signed modular JARs are not copied to\n\
 \                                        the runtime image.
 
+main.opt.verbose=\
+\  -v, --verbose                         Enable verbose tracing
+
 main.msg.bug=\
 An exception has occurred in jlink. \
 Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \
@@ -95,6 +104,9 @@
 \n\
 
 
+error.prefix=Error:
+warn.prefix=Warning:
+
 err.unknown.byte.order:unknown byte order {0}
 err.launcher.main.class.empty:launcher main class name cannot be empty: {0}
 err.launcher.module.name.empty:launcher module name cannot be empty: {0}
@@ -111,12 +123,12 @@
 err.dir.exists={0} already exists
 err.badpattern=bad pattern {0}
 err.unknown.option=unknown option: {0}
-err.orphan.argument=orphan argument: {0}
 err.missing.arg=no value given for {0}
 err.internal.error=internal error: {0} {1} {2}
 err.invalid.arg.for.option=invalid argument for option: {0}
 err.option.after.class=option must be specified before classes: {0}
 err.option.unsupported={0} not supported: {1}
+err.orphan.arguments=invalid argument: {0}
 err.config.defaults=property {0} is missing from configuration
 err.config.defaults.value=wrong value in defaults property: {0}
 err.bom.generation=bom file generation failed: {0}
@@ -126,3 +138,7 @@
 warn.signing=WARNING: signed modular JAR {0} is currently not supported
 warn.invalid.arg=invalid classname or pathname not exist: {0}
 warn.split.package=package {0} defined in {1} {2}
+warn.unused.services=Services specified in --suggest-providers not used: {0}
+no.suggested.providers=--bind-services option is specified. No additional providers suggested.
+suggested.providers.header=Suggested providers
+providers.header=Providers
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Wed Jul 05 23:09:40 2017 +0200
@@ -96,13 +96,14 @@
 import jdk.internal.joptsimple.OptionSet;
 import jdk.internal.joptsimple.OptionSpec;
 import jdk.internal.joptsimple.ValueConverter;
-import jdk.internal.loader.ResourceHelper;
 import jdk.internal.module.ModuleHashes;
 import jdk.internal.module.ModuleHashesBuilder;
 import jdk.internal.module.ModuleInfo;
 import jdk.internal.module.ModuleInfoExtender;
 import jdk.internal.module.ModulePath;
 import jdk.internal.module.ModuleResolution;
+import jdk.internal.module.ModuleTarget;
+import jdk.internal.module.Resources;
 import jdk.tools.jlink.internal.Utils;
 
 import static java.util.stream.Collectors.joining;
@@ -178,7 +179,6 @@
         String mainClass;
         String osName;
         String osArch;
-        String osVersion;
         Pattern modulesToHash;
         ModuleResolution moduleResolution;
         boolean dryrun;
@@ -311,7 +311,9 @@
         try (JmodFile jf = new JmodFile(options.jmodFile)) {
             try (InputStream in = jf.getInputStream(Section.CLASSES, MODULE_INFO)) {
                 ModuleInfo.Attributes attrs = ModuleInfo.read(in, null);
-                printModuleDescriptor(attrs.descriptor(), attrs.recordedHashes());
+                printModuleDescriptor(attrs.descriptor(),
+                                      attrs.target(),
+                                      attrs.recordedHashes());
                 return true;
             } catch (IOException e) {
                 throw new CommandException("err.module.descriptor.not.found");
@@ -325,7 +327,9 @@
                   .collect(joining(" "));
     }
 
-    private void printModuleDescriptor(ModuleDescriptor md, ModuleHashes hashes)
+    private void printModuleDescriptor(ModuleDescriptor md,
+                                       ModuleTarget target,
+                                       ModuleHashes hashes)
         throws IOException
     {
         StringBuilder sb = new StringBuilder();
@@ -365,11 +369,14 @@
 
         md.mainClass().ifPresent(v -> sb.append("\n  main-class " + v));
 
-        md.osName().ifPresent(v -> sb.append("\n  operating-system-name " + v));
-
-        md.osArch().ifPresent(v -> sb.append("\n  operating-system-architecture " + v));
-
-        md.osVersion().ifPresent(v -> sb.append("\n  operating-system-version " + v));
+        if (target != null) {
+            String osName = target.osName();
+            if (osName != null)
+                sb.append("\n  operating-system-name " + osName);
+            String osArch = target.osArch();
+            if (osArch != null)
+                sb.append("\n  operating-system-architecture " + osArch);
+        }
 
         if (hashes != null) {
             hashes.names().stream().sorted().forEach(
@@ -432,7 +439,6 @@
         final String mainClass = options.mainClass;
         final String osName = options.osName;
         final String osArch = options.osArch;
-        final String osVersion = options.osVersion;
         final List<PathMatcher> excludes = options.excludes;
         final ModuleResolution moduleResolution = options.moduleResolution;
 
@@ -528,9 +534,9 @@
                 if (mainClass != null)
                     extender.mainClass(mainClass);
 
-                // --os-name, --os-arch, --os-version
-                if (osName != null || osArch != null || osVersion != null)
-                    extender.targetPlatform(osName, osArch, osVersion);
+                // --os-name, --os-arch
+                if (osName != null || osArch != null)
+                    extender.targetPlatform(osName, osArch);
 
                 // --module-version
                 if (moduleVersion != null)
@@ -675,7 +681,7 @@
          */
         boolean isResource(String name) {
             name = name.replace(File.separatorChar, '/');
-            return name.endsWith(".class") || !ResourceHelper.isSimpleResource(name);
+            return name.endsWith(".class") || Resources.canEncapsulate(name);
         }
 
 
@@ -1331,11 +1337,6 @@
                         .withRequiredArg()
                         .describedAs(getMessage("main.opt.os-arch.arg"));
 
-        OptionSpec<String> osVersion
-                = parser.accepts("os-version", getMessage("main.opt.os-version"))
-                        .withRequiredArg()
-                        .describedAs(getMessage("main.opt.os-version.arg"));
-
         OptionSpec<Void> doNotResolveByDefault
                 = parser.accepts("do-not-resolve-by-default",
                                  getMessage("main.opt.do-not-resolve-by-default"));
@@ -1403,8 +1404,6 @@
                 options.osName = getLastElement(opts.valuesOf(osName));
             if (opts.has(osArch))
                 options.osArch = getLastElement(opts.valuesOf(osArch));
-            if (opts.has(osVersion))
-                options.osVersion = getLastElement(opts.valuesOf(osVersion));
             if (opts.has(warnIfResolved))
                 options.moduleResolution = getLastElement(opts.valuesOf(warnIfResolved));
             if (opts.has(doNotResolveByDefault)) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -68,8 +68,6 @@
 main.opt.os-name.arg=os-name
 main.opt.os-arch=Operating system architecture
 main.opt.os-arch.arg=os-arch
-main.opt.os-version=Operating system version
-main.opt.os-version.arg=os-version
 main.opt.module-path=Module path
 main.opt.hash-modules=Compute and record hashes to tie a packaged module\
 \ with modules matching the given <regex-pattern> and depending upon it directly\
--- a/jdk/src/jdk.jlink/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Defines the Java linker tool, jlink.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.jlink {
     requires jdk.internal.opt;
     requires jdk.jdeps;
--- a/jdk/src/jdk.jsobject/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jsobject/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Defines the API for the JavaScript Object.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.jsobject {
     requires java.desktop;
     exports netscape.javascript;
--- a/jdk/src/jdk.jstatd/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.jstatd/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,13 @@
  * questions.
  */
 
+/**
+ * Defines the tool for starting a daemon for the jstat tool to monitor
+ * JVM statistics remotely.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.jstatd {
     requires java.rmi;
     requires jdk.internal.jvmstat;
@@ -32,4 +39,3 @@
 
     provides sun.jvmstat.monitor.MonitoredHostService with sun.jvmstat.perfdata.monitor.protocol.rmi.MonitoredHostRmiService;
 }
-
--- a/jdk/src/jdk.localedata/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.localedata/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Locale data provider for locales other than {@linkplain java.util.Locale#US US locale}.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.localedata {
     provides sun.util.locale.provider.LocaleDataMetaInfo with
         sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo,
--- a/jdk/src/jdk.management.agent/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.management.agent/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Define the JMX management agent.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.management.agent {
     requires java.management;
     requires java.management.rmi;
--- a/jdk/src/jdk.management/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.management/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Defines the JDK-specific Management Interfaces for JVM.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.management {
     requires transitive java.management;
 
--- a/jdk/src/jdk.naming.dns/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.naming.dns/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * DNS Java Naming provider.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.naming.dns {
     requires java.naming;
 
--- a/jdk/src/jdk.naming.rmi/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.naming.rmi/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * RMI Java Naming provider.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.naming.rmi {
     requires java.naming;
     requires java.rmi;
--- a/jdk/src/jdk.net/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.net/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Defines the JDK-specific Networking API.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.net {
     exports jdk.net;
 }
--- a/jdk/src/jdk.sctp/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.sctp/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Defines the JDK-specific API for SCTP.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.sctp {
     exports com.sun.nio.sctp;
 }
--- a/jdk/src/jdk.security.auth/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.security.auth/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
  * Contains the implementation of the javax.security.auth.* interfaces and
  * various authentication modules.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.security.auth {
--- a/jdk/src/jdk.security.jgss/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.security.jgss/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
  * Defines Java extensions to the GSS-API and an implementation of the SASL
  * GSSAPI mechanism.
  *
+ * @moduleGraph
  * @since 9
  */
 module jdk.security.jgss {
--- a/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java	Wed Jul 05 23:09:40 2017 +0200
@@ -813,6 +813,7 @@
     /**
      * Tells the VM to define a class, without security checks.  By default, the
      * class loader and protection domain come from the caller's class.
+     * @see java.lang.invoke.MethodHandles.Lookup#defineClass(byte[])
      */
     @ForceInline
     public Class<?> defineClass(String name, byte[] b, int off, int len,
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java	Wed Jul 05 23:09:40 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
@@ -28,6 +28,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.Runtime.Version;
+import java.nio.file.NoSuchFileException;
 import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -86,12 +87,12 @@
         }
     }
 
-    private boolean isMultiReleaseJar() {
+    private boolean isMultiReleaseJar() throws IOException {
         try (InputStream is = newInputStream(getBytes("/META-INF/MANIFEST.MF"))) {
-            return (new Manifest(is)).getMainAttributes()
-                    .containsKey(new Attributes.Name("Multi-Release"));
-            // fixme change line above after JarFile integration to contain Attributes.Name.MULTI_RELEASE
-        } catch (IOException x) {
+            String multiRelease = new Manifest(is).getMainAttributes()
+                    .getValue(Attributes.Name.MULTI_RELEASE);
+            return "true".equalsIgnoreCase(multiRelease);
+        } catch (NoSuchFileException x) {
             return false;
         }
     }
--- a/jdk/src/jdk.zipfs/share/classes/module-info.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/src/jdk.zipfs/share/classes/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Zip file system provider.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module jdk.zipfs {
     provides java.nio.file.spi.FileSystemProvider with jdk.nio.zipfs.ZipFileSystemProvider;
 }
--- a/jdk/test/ProblemList.txt	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/ProblemList.txt	Wed Jul 05 23:09:40 2017 +0200
@@ -180,8 +180,6 @@
 
 java/nio/channels/DatagramChannel/ChangingAddress.java          7141822 macosx-all
 
-java/nio/channels/Selector/OutOfBand.java                       7132677 macosx-all
-
 java/nio/file/WatchService/Basic.java                           7158947 solaris-all Solaris 11
 java/nio/file/WatchService/MayFlies.java                        7158947 solaris-all Solaris 11
 java/nio/file/WatchService/LotsOfEvents.java                    7158947 solaris-all Solaris 11
@@ -215,9 +213,8 @@
 javax/net/ssl/DTLS/PacketLossRetransmission.java                8169086 macosx-x64
 javax/net/ssl/DTLS/RespondToRetransmit.java                     8169086 macosx-x64
 
-sun/security/krb5/auto/Basic.java                               8176296 generic-all
+sun/security/ssl/X509KeyManager/PreferredKey.java               8176354 generic-all
 
-sun/security/ssl/X509KeyManager/PreferredKey.java               8176354 generic-all
 ############################################################################
 
 # jdk_sound
@@ -292,6 +289,7 @@
 
 java/util/BitSet/BitSetStreamTest.java                          8079538 generic-all
 
+jdk/internal/util/jar/TestVersionedStream.java                  8177640 windows-all
 
 ############################################################################
 
--- a/jdk/test/TEST.groups	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/TEST.groups	Wed Jul 05 23:09:40 2017 +0200
@@ -28,8 +28,6 @@
 tier1 = \
     :jdk_lang \
     :jdk_util \
-    -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
-    -java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
     sun/nio/cs/ISO8859x.java \
     java/nio/Buffer \
     com/sun/crypto/provider/Cipher \
@@ -37,8 +35,6 @@
     tools/pack200
 
 tier2 = \
-    java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
-    java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
     :jdk_io \
     :jdk_nio \
     -sun/nio/cs/ISO8859x.java \
@@ -74,9 +70,11 @@
     sun/reflect \
     jdk/internal/reflect \
     jdk/lambda \
+    jdk/internal/loader \
     jdk/internal/misc \
     jdk/internal/ref \
     jdk/internal/jimage \
+    jdk/internal/math \
     jdk/modules \
     vm
 
@@ -91,6 +89,7 @@
 jdk_util_other = \
     java/util \
     sun/util \
+    jdk/internal/util \
     -:jdk_collections \
     -:jdk_concurrent \
     -:jdk_stream
@@ -145,8 +144,7 @@
     java/util/stream
 
 jdk_math = \
-    java/math \
-    jdk/internal/math
+    java/math
 
 jdk_io = \
     java/io
@@ -181,6 +179,7 @@
 jdk_security3 = \
     javax/security  \
     -javax/security/auth/kerberos \
+    com/sun/jarsigner \
     com/sun/security \
     -com/sun/security/jgss \
     com/sun/org/apache/xml/internal/security \
@@ -211,7 +210,8 @@
 jdk_management = \
     java/lang/management \
     com/sun/management \
-    sun/management
+    sun/management \
+    jdk/internal/agent
 
 jdk_instrument = \
     java/lang/instrument
--- a/jdk/test/com/sun/jdi/AcceptTimeout.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/AcceptTimeout.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,8 +24,7 @@
 /* @test
  * @bug 6198277
  * @summary Test that each ListeningConnector that supports a "timeout" argument will
- *     timeout with TransportTimeoutException
- * @modules jdk.jdi
+ * timeout with TransportTimeoutException
  */
 import com.sun.jdi.Bootstrap;
 import com.sun.jdi.connect.Connector;
--- a/jdk/test/com/sun/jdi/AccessSpecifierTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/AccessSpecifierTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4359628
- *  @summary Test fix for JDI: methods Accessible.is...() lie about array types
+ * @test
+ * @bug 4359628
+ * @summary Test fix for JDI: methods Accessible.is...() lie about array types
+ * @author Tim Bell
  *
- *  @author Tim Bell
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g AccessSpecifierTest.java
- *  @run driver AccessSpecifierTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g AccessSpecifierTest.java
+ * @run driver AccessSpecifierTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/AfterThreadDeathTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/AfterThreadDeathTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4364671
- *  @summary Creating a StepRequest on a nonexistant thread fails
+ * @test
+ * @bug 4364671
+ * @summary Creating a StepRequest on a nonexistant thread fails
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g AfterThreadDeathTest.java
- *  @run driver AfterThreadDeathTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g AfterThreadDeathTest.java
+ * @run driver AfterThreadDeathTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/AllLineLocations.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/AllLineLocations.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4248728
- *  @summary Test ReferenceType.allLineLocations
- *  @author Gordon Hirsch
+ * @test
+ * @bug 4248728
+ * @summary Test ReferenceType.allLineLocations
+ * @author Gordon Hirsch
  *
- *  @modules jdk.jdi
- *  @run build JDIScaffold VMConnection
- *  @run compile -g RefTypes.java
- *  @run build AllLineLocations
+ * @run build JDIScaffold VMConnection
+ * @run compile -g RefTypes.java
+ * @run build AllLineLocations
  *
- *  @run driver AllLineLocations RefTypes
+ * @run driver AllLineLocations RefTypes
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/ArrayRangeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ArrayRangeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,18 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4439631
- *  @bug 4448721
- *  @bug 4448603
- *  @summary Test access to ranges within ArrayReferences
+ * @test
+ * @bug 4439631
+ * @bug 4448721
+ * @bug 4448603
+ * @summary Test access to ranges within ArrayReferences
+ * @author Robert Field
  *
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g ArrayRangeTest.java
- *  @run driver ArrayRangeTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g ArrayRangeTest.java
+ * @run driver ArrayRangeTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/BacktraceFieldTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/BacktraceFieldTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4446677
- *  @bug 8158237
- *  @summary debuggee used to crash when debugging under jbuilder
+ * @test
+ * @bug 4446677
+ * @bug 8158237
+ * @summary debuggee used to crash when debugging under jbuilder
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g BacktraceFieldTest.java
- *  @run driver BacktraceFieldTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g BacktraceFieldTest.java
+ * @run driver BacktraceFieldTest
  */
 
 /*
--- a/jdk/test/com/sun/jdi/ClassLoaderClassesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ClassLoaderClassesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,10 +27,8 @@
  *  @summary Test ClassLoaderReference.visibleClasses() which is
  *  a direct pass-through of the JVMDI function GetClassLoaderClasses
  *  for inclusion of primitive arrays.
- *
  *  @author Robert Field
  *
- *  @modules jdk.jdi
  *  @run build TestScaffold VMConnection TargetListener TargetAdapter
  *  @run compile -g ClassLoaderClassesTest.java
  *  @run driver ClassLoaderClassesTest
--- a/jdk/test/com/sun/jdi/ClassesByName.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ClassesByName.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,16 +24,14 @@
 /**
  *  @test
  *  @bug 4287992
+ *  @summary ClassesByName verifies that all the classes in the
+ *  loaded class list can be found with classesByName..
  *  @author Robert Field
  *
- *  @modules jdk.jdi
  *  @run build JDIScaffold VMConnection
  *  @run compile -g HelloWorld.java
  *  @run build ClassesByName
  *
- *  @summary ClassesByName verifies that all the classes in the
- *  loaded class list can be found with classesByName..
- *
  *  @run driver ClassesByName HelloWorld
  */
 import com.sun.jdi.*;
--- a/jdk/test/com/sun/jdi/ClassesByName2Test.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ClassesByName2Test.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,17 @@
  */
 
 /**
- *  @test
- *  @bug 4406439 4925740
- *  @summary ClassesByName2 verifies that all the classes in the loaded class list can be found with classesByName..
+ * @test
+ * @bug 4406439 4925740
+ * @summary ClassesByName2 verifies that all the classes in the loaded class list can be found with classesByName..
+ * @author Tim Bell (based on ClassesByName by Robert Field)
  *
- *  @author Tim Bell (based on ClassesByName by Robert Field)
+ * @modules jdk.jdi
+ *          java.desktop
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g ClassesByName2Test.java
- *  @run driver ClassesByName2Test
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g ClassesByName2Test.java
+ * @run driver ClassesByName2Test
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/CompatibleConnectors.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/CompatibleConnectors.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  *
  * This test checks that VirtualMachineManager creates Connectors that
  * are "compatible" those created by 1.4 or earilier releases.
- * @modules jdk.jdi
  */
 
 import com.sun.jdi.*;
--- a/jdk/test/com/sun/jdi/ConnectedVMs.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ConnectedVMs.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,20 +22,18 @@
  */
 
 /**
- *  @test
- *  @bug 4329140
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g InstTarg.java
- *  @run driver ConnectedVMs Kill
- *  @run driver ConnectedVMs Resume-to-exit
- *  @run driver ConnectedVMs dispose()
- *  @run driver ConnectedVMs exit()
- *
+ * @test
+ * @bug 4329140
  * @summary ConnectedVMs checks the method
  * VirtualMachineManager.connectedVirtualMachines()
+ * @author Robert Field
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g InstTarg.java
+ * @run driver ConnectedVMs Kill
+ * @run driver ConnectedVMs Resume-to-exit
+ * @run driver ConnectedVMs dispose()
+ * @run driver ConnectedVMs exit()
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/ConstantPoolInfo.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ConstantPoolInfo.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 5024104
- *  @summary Test ReferenceType.majorVersion(), minorVersion, constantPoolCount and ConstantPool apis.
+ * @test
+ * @bug 5024104
+ * @summary Test ReferenceType.majorVersion(), minorVersion, constantPoolCount and ConstantPool apis.
+ * @author Swamy Venkataramanappa
  *
- *  @author Swamy Venkataramanappa
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection
- *  @run compile -g ConstantPoolInfo.java
- *  @run driver ConstantPoolInfo
+ * @run build TestScaffold VMConnection
+ * @run compile -g ConstantPoolInfo.java
+ * @run driver ConstantPoolInfo
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/ConstantPoolInfoGC.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ConstantPoolInfoGC.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,16 @@
  */
 
 /*
- *  @test
- *  @bug 6822627
- *  @summary Test that ReferenceType.constantPool does not produce an NPE
+ * @test
+ * @bug 6822627
+ * @summary Test that ReferenceType.constantPool does not produce an NPE
+ * @author Egor Ushakov
  *
- *  @author Egor Ushakov
+ * @modules jdk.jdi/com.sun.tools.jdi:+open
  *
- *  @modules jdk.jdi/com.sun.tools.jdi:+open
- *  @run build TestScaffold VMConnection
- *  @run compile -g ConstantPoolInfoGC.java
- *  @run main/othervm ConstantPoolInfoGC
+ * @run build TestScaffold VMConnection
+ * @run compile -g ConstantPoolInfoGC.java
+ * @run main/othervm ConstantPoolInfoGC
  */
 
 import com.sun.jdi.ReferenceType;
--- a/jdk/test/com/sun/jdi/CountEvent.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/CountEvent.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4315352
- *  @summary disabling EventRequest expired with addCountFilter() throws
- *   InternalException.
+ * @test
+ * @bug 4315352
+ * @summary disabling EventRequest expired with addCountFilter() throws
+ * InternalException.
+ * @author Robert Field
  *
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetAdapter TargetListener
- *  @run compile -g CountEvent.java
- *  @run driver CountEvent
+ * @run build TestScaffold VMConnection TargetAdapter TargetListener
+ * @run compile -g CountEvent.java
+ * @run driver CountEvent
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/CountFilterTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/CountFilterTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4321339
- *  @summary Check correct processing of filters after a count filter
+ * @test
+ * @bug 4321339
+ * @summary Check correct processing of filters after a count filter
+ * @author Robert Field
  *
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g CountFilterTest.java
- *  @run driver CountFilterTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g CountFilterTest.java
+ * @run driver CountFilterTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/DebuggerThreadTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/DebuggerThreadTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4513488
- *  @summary Test for JDI: Internal JDI helper threads should setDaemon(true)
+ * @test
+ * @bug 4513488
+ * @summary Test for JDI: Internal JDI helper threads should setDaemon(true)
+ * @author Tim Bell
  *
- *  @author Tim Bell
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g DebuggerThreadTest.java
- *  @run driver DebuggerThreadTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g DebuggerThreadTest.java
+ * @run driver DebuggerThreadTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/DeleteAllBkptsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/DeleteAllBkptsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4528948
- *  @summary Unable to finish a debugging in NetBeans IDE
- *
- *  @author jjh
+ * @test
+ * @bug 4528948
+ * @summary Unable to finish a debugging in NetBeans IDE
+ * @author jjh
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build  TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g DeleteAllBkptsTest.java
- *  @run driver DeleteAllBkptsTest
+ * @library ..
+ *
+ * @run build  TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g DeleteAllBkptsTest.java
+ * @run driver DeleteAllBkptsTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/DeleteEventRequestsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/DeleteEventRequestsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4331872
- *  @summary erm.deleteEventRequests(erm.breakpointRequests()) throws exception
+ * @test
+ * @bug 4331872
+ * @summary erm.deleteEventRequests(erm.breakpointRequests()) throws exception
+ * @author Robert Field
  *
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g DeleteEventRequestsTest.java
- *  @run driver DeleteEventRequestsTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g DeleteEventRequestsTest.java
+ * @run driver DeleteEventRequestsTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/EarlyReturnNegativeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/EarlyReturnNegativeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,15 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 6431735
- *  @summary Unexpected ClassCastException in ThreadReference.forceEarlyReturn
- *  @author Jim Holmlund
+ * @test
+ * @bug 6431735
+ * @summary Unexpected ClassCastException in ThreadReference.forceEarlyReturn
+ * @author Jim Holmlund
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g EarlyReturnNegativeTest.java
- *  @run driver EarlyReturnNegativeTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g EarlyReturnNegativeTest.java
+ * @run driver EarlyReturnNegativeTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/EarlyReturnTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/EarlyReturnTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,22 +22,21 @@
  */
 
 /*
- *  @test
- *  @bug 6175634
- *  @summary Allow early return from methods
+ * @test
+ * @bug 6175634
+ * @summary Allow early return from methods
  *
- *  @bug 6431720
- *  @summary Unexpected InvalidTypeException when call ThreadReference.forceEarlyReturn with VoidValue
+ * @bug 6431720
+ * @summary Unexpected InvalidTypeException when call ThreadReference.forceEarlyReturn with VoidValue
  *
- *  @bug 6432855
- *  @summary Need a way to create JDI VoidValue for use in ThreadReference.forceEarlyReturn
- *
- *  @author Tim Bell (based on MethodExitReturnValuesTest by Jim Holmlund)
+ * @bug 6432855
+ * @summary Need a way to create JDI VoidValue for use in ThreadReference.forceEarlyReturn
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g EarlyReturnTest.java
- *  @run driver EarlyReturnTest
+ * @author Tim Bell (based on MethodExitReturnValuesTest by Jim Holmlund)
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g EarlyReturnTest.java
+ * @run driver EarlyReturnTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/EnumTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/EnumTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4728816
- *  @summary JPDA: Add support for enums
+ * @test
+ * @bug 4728816
+ * @summary JPDA: Add support for enums
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g EnumTest.java
- *  @run driver EnumTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g EnumTest.java
+ * @run driver EnumTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/EventQueueDisconnectTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/EventQueueDisconnectTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,21 +22,20 @@
  */
 
 /**
- *  @test
- *  @bug 4425852
- *  @author Robert Field
+ * @test
+ * @bug 4425852
+ * @author Robert Field
  *
- *  @modules jdk.jdi
- *  @run build VMConnection
- *  @run compile -g EventQueueDisconnectTest.java
- *  @run driver EventQueueDisconnectTest
- *
- *  @summary EventQueueDisconnectTest checks to see that
- *  VMDisconnectedException is never thrown before VMDisconnectEvent.
+ * @summary EventQueueDisconnectTest checks to see that
+ * VMDisconnectedException is never thrown before VMDisconnectEvent.
  *
  * Failure mode for this test is throwing VMDisconnectedException
  * on vm.eventQueue().remove();
  * Does not use a scaffold since we don't want that hiding the exception.
+ *
+ * @run build VMConnection
+ * @run compile -g EventQueueDisconnectTest.java
+ * @run driver EventQueueDisconnectTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/ExceptionEvents.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ExceptionEvents.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,43 +22,41 @@
  */
 
 /**
- *  @test
- *  @bug 4407397
- *  @summary Test the requesting of exception events
- *
- *  @author Robert Field
+ * @test
+ * @bug 4407397
+ * @key intermittent
+ * @summary Test the requesting of exception events
+ * @author Robert Field
  *
- *  @key intermittent
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection
- *  @run compile -g ExceptionEvents.java
+ * @run build TestScaffold VMConnection
+ * @run compile -g ExceptionEvents.java
  *
- *  @run driver ExceptionEvents N A StackOverflowCaughtTarg java.lang.Exception
- *  @run driver ExceptionEvents C A StackOverflowCaughtTarg null
- *  @run driver ExceptionEvents C A StackOverflowCaughtTarg java.lang.Error
- *  @run driver ExceptionEvents C A StackOverflowCaughtTarg java.lang.StackOverflowError
- *  @run driver ExceptionEvents N A StackOverflowCaughtTarg java.lang.NullPointerException
+ * @run driver ExceptionEvents N A StackOverflowCaughtTarg java.lang.Exception
+ * @run driver ExceptionEvents C A StackOverflowCaughtTarg null
+ * @run driver ExceptionEvents C A StackOverflowCaughtTarg java.lang.Error
+ * @run driver ExceptionEvents C A StackOverflowCaughtTarg java.lang.StackOverflowError
+ * @run driver ExceptionEvents N A StackOverflowCaughtTarg java.lang.NullPointerException
 
- *  @run driver ExceptionEvents N T StackOverflowCaughtTarg java.lang.Exception
- *  @run driver ExceptionEvents C T StackOverflowCaughtTarg null
- *  @run driver ExceptionEvents C T StackOverflowCaughtTarg java.lang.Error
- *  @run driver ExceptionEvents C T StackOverflowCaughtTarg java.lang.StackOverflowError
- *  @run driver ExceptionEvents N T StackOverflowCaughtTarg java.lang.NullPointerException
+ * @run driver ExceptionEvents N T StackOverflowCaughtTarg java.lang.Exception
+ * @run driver ExceptionEvents C T StackOverflowCaughtTarg null
+ * @run driver ExceptionEvents C T StackOverflowCaughtTarg java.lang.Error
+ * @run driver ExceptionEvents C T StackOverflowCaughtTarg java.lang.StackOverflowError
+ * @run driver ExceptionEvents N T StackOverflowCaughtTarg java.lang.NullPointerException
 
- *  @run driver ExceptionEvents N N StackOverflowCaughtTarg java.lang.Exception
- *  @run driver ExceptionEvents C N StackOverflowCaughtTarg null
- *  @run driver ExceptionEvents C N StackOverflowCaughtTarg java.lang.Error
- *  @run driver ExceptionEvents C N StackOverflowCaughtTarg java.lang.StackOverflowError
- *  @run driver ExceptionEvents N N StackOverflowCaughtTarg java.lang.NullPointerException
+ * @run driver ExceptionEvents N N StackOverflowCaughtTarg java.lang.Exception
+ * @run driver ExceptionEvents C N StackOverflowCaughtTarg null
+ * @run driver ExceptionEvents C N StackOverflowCaughtTarg java.lang.Error
+ * @run driver ExceptionEvents C N StackOverflowCaughtTarg java.lang.StackOverflowError
+ * @run driver ExceptionEvents N N StackOverflowCaughtTarg java.lang.NullPointerException
 
- *  @run driver ExceptionEvents N A StackOverflowUncaughtTarg java.lang.Exception
- *  @run driver ExceptionEvents U A StackOverflowUncaughtTarg null
- *  @run driver ExceptionEvents U A StackOverflowUncaughtTarg java.lang.Error
- *  @run driver ExceptionEvents U A StackOverflowUncaughtTarg java.lang.StackOverflowError
- *  @run driver ExceptionEvents N A StackOverflowUncaughtTarg java.lang.NullPointerException
+ * @run driver ExceptionEvents N A StackOverflowUncaughtTarg java.lang.Exception
+ * @run driver ExceptionEvents U A StackOverflowUncaughtTarg null
+ * @run driver ExceptionEvents U A StackOverflowUncaughtTarg java.lang.Error
+ * @run driver ExceptionEvents U A StackOverflowUncaughtTarg java.lang.StackOverflowError
+ * @run driver ExceptionEvents N A StackOverflowUncaughtTarg java.lang.NullPointerException
 
- *  @run driver ExceptionEvents N T StackOverflowUncaughtTarg java.lang.NullPointerException
- *  @run driver ExceptionEvents N N StackOverflowUncaughtTarg java.lang.NullPointerException
+ * @run driver ExceptionEvents N T StackOverflowUncaughtTarg java.lang.NullPointerException
+ * @run driver ExceptionEvents N N StackOverflowUncaughtTarg java.lang.NullPointerException
 
  */
 import com.sun.jdi.*;
--- a/jdk/test/com/sun/jdi/ExpiredRequestDeletionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ExpiredRequestDeletionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4453310
- *  @summary Test the deletion of event requests that are expired
- *     by virtue of addCountFilter.
+ * @test
+ * @bug 4453310
+ * @summary Test the deletion of event requests that are expired
+ * by virtue of addCountFilter.
  *
- *  @author Robert Field
+ * @author Robert Field
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g ExpiredRequestDeletionTest.java
- *  @run driver ExpiredRequestDeletionTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g ExpiredRequestDeletionTest.java
+ * @run driver ExpiredRequestDeletionTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/FieldWatchpoints.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/FieldWatchpoints.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4408582
- *  @summary Test fix for: JDWP: WatchpointEvents outside of class filtered out
+ * @test
+ * @bug 4408582
+ * @summary Test fix for: JDWP: WatchpointEvents outside of class filtered out
+ * @author Tim Bell
  *
- *  @author Tim Bell
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g FieldWatchpoints.java
- *  @run driver FieldWatchpoints
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g FieldWatchpoints.java
+ * @run driver FieldWatchpoints
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/FilterMatch.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/FilterMatch.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4331522
- *  @summary addClassFilter("Foo") acts like "Foo*"
+ * @test
+ * @bug 4331522
+ * @summary addClassFilter("Foo") acts like "Foo*"
+ * @author Robert Field/Jim Holmlund
  *
- *  @author Robert Field/Jim Holmlund
- *
- *  @modules jdk.jdi
- *  @run build JDIScaffold VMConnection
- *  @run compile -g HelloWorld.java
- *  @run driver FilterMatch
+ * @run build JDIScaffold VMConnection
+ * @run compile -g HelloWorld.java
+ * @run driver FilterMatch
  */
 
 /* Look at patternMatch in JDK file:
--- a/jdk/test/com/sun/jdi/FilterNoMatch.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/FilterNoMatch.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4331522
- *  @summary addClassFilter("Foo") acts like "Foo*"
+ * @test
+ * @bug 4331522
+ * @summary addClassFilter("Foo") acts like "Foo*"
+ * @author Robert Field/Jim Holmlund
  *
- *  @author Robert Field/Jim Holmlund
- *
- *  @modules jdk.jdi
- *  @run build JDIScaffold VMConnection
- *  @run compile -g HelloWorld.java
- *  @run driver FilterNoMatch
+ * @run build JDIScaffold VMConnection
+ * @run compile -g HelloWorld.java
+ * @run driver FilterNoMatch
  */
 
 /* This tests the patternMatch function in JDK file:
--- a/jdk/test/com/sun/jdi/FinalLocalsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/FinalLocalsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,18 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4326648 4768329
- *  @summary Test to verify that table entries are generated for all final
- *           locals when a class is built for debug, even if they could be
- *           inlined otherwise.
+ * @test
+ * @bug 4326648 4768329
+ * @summary Test to verify that table entries are generated for all final
+ *          locals when a class is built for debug, even if they could be
+ *          inlined otherwise.
+ * @author Tim Bell
  *
- *  @author Tim Bell
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g FinalLocalsTest.java
- *  @run driver FinalLocalsTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g FinalLocalsTest.java
+ * @run driver FinalLocalsTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/FinalizerTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/FinalizerTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4272800 4274208 4392010
- *  @summary Test debugger operations in finalize() methods
- *  @author Gordon Hirsch  (modified for HotSpot by tbell & rfield)
+ * @test
+ * @bug 4272800 4274208 4392010
+ * @summary Test debugger operations in finalize() methods
+ * @author Gordon Hirsch  (modified for HotSpot by tbell & rfield)
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g FinalizerTest.java
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g FinalizerTest.java
  *
- *  @run driver FinalizerTest
+ * @run driver FinalizerTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/FramesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/FramesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4434232
- *  @summary Test ThreadReference.frames(int,int)
+ * @test
+ * @bug 4434232
+ * @summary Test ThreadReference.frames(int,int)
+ * @author Robert Field
  *
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g FramesTest.java
- *  @run driver FramesTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g FramesTest.java
+ * @run driver FramesTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/GenericsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/GenericsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4421040
- *  @summary  JPDA: Add support for JSR-014 Generics
+ * @test
+ * @bug 4421040
+ * @summary  JPDA: Add support for JSR-014 Generics
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g GenericsTest.java
- *  @run driver GenericsTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g GenericsTest.java
+ * @run driver GenericsTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/GetLocalVariables2Test.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/GetLocalVariables2Test.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4349534 4690242 4695338
- *  @summary regression - bad LocalVariableTable attribute when no initialization needed
+ * @test
+ * @bug 4349534 4690242 4695338
+ * @summary regression - bad LocalVariableTable attribute when no initialization needed
+ * @author Tim Bell
  *
- *  @author Tim Bell
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g GetLocalVariables2Test.java
- *  @run driver GetLocalVariables2Test
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g GetLocalVariables2Test.java
+ * @run driver GetLocalVariables2Test
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/GetUninitializedStringValue.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/GetUninitializedStringValue.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 8021897
- *  @summary Test getting the value for an uninitialized String object
+ * @test
+ * @bug 8021897
+ * @summary Test getting the value for an uninitialized String object
+ * @author Staffan Larsen
  *
- *  @author Staffan Larsen
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g GetUninitializedStringValue.java
- *  @run driver GetUninitializedStringValue
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g GetUninitializedStringValue.java
+ * @run driver GetUninitializedStringValue
  */
 import com.sun.jdi.ReferenceType;
 import com.sun.jdi.StackFrame;
--- a/jdk/test/com/sun/jdi/HomeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/HomeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4446294
- *  @summary JDI spec/impl: default "home" for CommandLineLaunch isn't java.home
+ * @test
+ * @bug 4446294
+ * @summary JDI spec/impl: default "home" for CommandLineLaunch isn't java.home
+ * @author Tim Bell (based on "HomeTest.java" by Eugene I. Latkin)
  *
- *  @author Tim Bell (based on "HomeTest.java" by Eugene I. Latkin)
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g HomeTest.java
- *  @run driver HomeTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g HomeTest.java
+ * @run driver HomeTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.connect.*;
--- a/jdk/test/com/sun/jdi/ImmutableResourceTest.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ImmutableResourceTest.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -21,13 +21,15 @@
 # questions.
 #
 
-#   @test
-#   @bug        6287579
-#   @summary    SubClasses of ListResourceBundle should fix getContents()
-#   @author     Tim Bell
 #
-#   @run shell ImmutableResourceTest.sh
+# @test
+# @bug        6287579
+# @summary    SubClasses of ListResourceBundle should fix getContents()
+# @author     Tim Bell
 #
+# @modules jdk.jdi/com.sun.tools.example.debug.tty
+#
+# @run shell ImmutableResourceTest.sh
 #
 
 # Beginning of subroutines:
--- a/jdk/test/com/sun/jdi/InstanceFilter.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/InstanceFilter.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4312961
- *  @summary Verify that an instance filter on a MethodEntryRequest works
- *   properly.
+ * @test
+ * @bug 4312961
+ * @summary Verify that an instance filter on a MethodEntryRequest works
+ *  properly.
+ * @author Robert Field/Jim Holmlund
  *
- *  @author Robert Field/Jim Holmlund
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetAdapter TargetListener
- *  @run compile -g InstanceFilter.java
- *  @run driver InstanceFilter
+ * @run build TestScaffold VMConnection TargetAdapter TargetListener
+ * @run compile -g InstanceFilter.java
+ * @run driver InstanceFilter
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/InstancesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/InstancesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,15 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 5024119
- *  @summary Add ReferenceType.getAllInstances () method to JDI.
- *  @author jjh
+ * @test
+ * @bug 5024119
+ * @summary Add ReferenceType.getAllInstances () method to JDI.
+ * @author jjh
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g InstancesTest.java
- *  @run driver InstancesTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g InstancesTest.java
+ * @run driver InstancesTest
  */
 
 /*
--- a/jdk/test/com/sun/jdi/InterfaceMethodsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/InterfaceMethodsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 8031195
- *  @bug 8071657
- *  @bug 8165827
- *  @summary  JDI: Add support for static, private and default methods in interfaces
+ * @test
+ * @bug 8031195
+ * @bug 8071657
+ * @bug 8165827
+ * @summary  JDI: Add support for static, private and default methods in interfaces
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run build InterfaceMethodsTest
- *  @run driver InterfaceMethodsTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run build InterfaceMethodsTest
+ * @run driver InterfaceMethodsTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/InterruptHangTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/InterruptHangTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,16 +26,14 @@
 import com.sun.jdi.request.*;
 
 /**
- *  @test
- *  @bug 6459476
- *  @summary Debuggee is blocked,  looks like running
+ * @test
+ * @bug 6459476
+ * @summary Debuggee is blocked,  looks like running
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g InterruptHangTest.java
- *  @run driver InterruptHangTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g InterruptHangTest.java
+ * @run driver InterruptHangTest
  */
 
 /**
--- a/jdk/test/com/sun/jdi/InvokeHangTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/InvokeHangTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,18 @@
  */
 
 /**
- *  @test
- *  @bug 6293795
- *  @summary  Backend hangs when invokeMethod is called from a JDI eventHandler
- *
- *  @author jjh
+ * @test
+ * @bug 6293795
+ * @summary  Backend hangs when invokeMethod is called from a JDI eventHandler
+ * @author jjh
  *
- *  @modules jdk.jdi
- *  @library /test/lib
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g InvokeHangTest.java
- *  @run driver InvokeHangTest
+ * @library /test/lib
+ * @modules java.management
+ *          jdk.jdi
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g InvokeHangTest.java
+ * @run driver InvokeHangTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/InvokeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/InvokeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4451941 4527072
- *  @summary Test argument types for invoke
- *
- *  @author Robert Field
+ * @test
+ * @bug 4451941 4527072
+ * @summary Test argument types for invoke
+ * @author Robert Field
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build  TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g InvokeTest.java
- *  @run driver InvokeTest
+ * @library ..
+ *
+ * @run build  TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g InvokeTest.java
+ * @run driver InvokeTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/JITDebug.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/JITDebug.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -24,17 +24,16 @@
 #
 
 #
-#   @test       JITDebug.sh 1.7 03/09/05
-#   @bug        4291701 4376819 4422312 4522770 4913748
-#   @summary    Test JIT debugging - assure that launching on
-#               uncaught exception works
-#   @author     Tim Bell
-#   Based on test/java/awt/TEMPLATE/AutomaticShellTest.sh
+# @test       JITDebug.sh 1.7 03/09/05
+# @bug        4291701 4376819 4422312 4522770 4913748
+# @summary    Test JIT debugging - assure that launching on
+#             uncaught exception works
+# @author     Tim Bell
+# Based on test/java/awt/TEMPLATE/AutomaticShellTest.sh
 #
-#   @modules jdk.jdi
-#   @run build TestScaffold VMConnection TargetListener TargetAdapter
-#   @run compile -g JITDebug.java
-#   @run shell JITDebug.sh
+# @run build TestScaffold VMConnection TargetListener TargetAdapter
+# @run compile -g JITDebug.java
+# @run shell JITDebug.sh
 
 # Beginning of subroutines:
 status=1
--- a/jdk/test/com/sun/jdi/Java_gTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/Java_gTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4500906 4433599 4740097
- *  @summary vmexec= debug java fails for SunCommandLineLauncher
+ * @test
+ * @bug 4500906 4433599 4740097
+ * @summary vmexec= debug java fails for SunCommandLineLauncher
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g Java_gTest.java
- *  @run driver Java_gTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g Java_gTest.java
+ * @run driver Java_gTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/LambdaStepTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/LambdaStepTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,15 +22,13 @@
  */
 
 /**
- *  @test
- *  @summary Test stepping through lambdas
- *
- *  @author Staffan Larsen
+ * @test
+ * @summary Test stepping through lambdas
+ * @author Staffan Larsen
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g LambdaStepTest.java
- *  @run driver LambdaStepTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g LambdaStepTest.java
+ * @run driver LambdaStepTest
  */
 import com.sun.jdi.LocalVariable;
 import com.sun.jdi.ObjectReference;
--- a/jdk/test/com/sun/jdi/LaunchCommandLine.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/LaunchCommandLine.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4245011
- *  @summary Test launcher command line construction
- *  @author Gordon Hirsch
+ * @test
+ * @bug 4245011
+ * @summary Test launcher command line construction
+ * @author Gordon Hirsch
  *
- *  @modules jdk.jdi
- *  @run build JDIScaffold VMConnection
- *  @run compile -g HelloWorld.java
- *  @run build LaunchCommandLine
+ * @run build JDIScaffold VMConnection
+ * @run compile -g HelloWorld.java
+ * @run build LaunchCommandLine
  *
- *  @run driver LaunchCommandLine
+ * @run driver LaunchCommandLine
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/LineNumberInfo.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/LineNumberInfo.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  *  @summary Test javac regressions in the generation of line number info
  *  @author Gordon Hirsch
  *
- *  @modules jdk.jdi
  *  @run build TestScaffold VMConnection TargetListener TargetAdapter
  *  @run compile -XDstringConcat=inline -g LineNumberInfo.java ControlFlow.java
  *
--- a/jdk/test/com/sun/jdi/ListenAddress.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ListenAddress.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @summary Test that startListening(Map) method of the com.sun.jdi.SocketListen
  *          Connector returns an address that is usable for the address option on
  *          remove debuggees.
- * @modules jdk.jdi
  */
 import java.net.InetAddress;
 import java.net.Inet4Address;
--- a/jdk/test/com/sun/jdi/LocalVariableEqual.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/LocalVariableEqual.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4916263
- *  @summary Test
+ * @test
+ * @bug 4916263
+ * @summary Test
+ * @author Serguei Spitsyn
  *
- *  @author Serguei Spitsyn
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g LocalVariableEqual.java
- *  @run driver LocalVariableEqual
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g LocalVariableEqual.java
+ * @run driver LocalVariableEqual
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/LocationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/LocationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4419453
- *  @summary Test that Method.location() returns the right values
+ * @test
+ * @bug 4419453
+ * @summary Test that Method.location() returns the right values
+ * @author Robert Field
  *
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g LocationTest.java
- *  @run driver LocationTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g LocationTest.java
+ * @run driver LocationTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/MethodEntryExitEvents.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/MethodEntryExitEvents.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4409241 4432820
- *  @summary Test the bug fix for: MethodExitEvents disappear when Object-Methods are called from main
- *  @author Tim Bell
+ * @test
+ * @bug 4409241 4432820
+ * @summary Test the bug fix for: MethodExitEvents disappear when Object-Methods are called from main
+ * @author Tim Bell
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g MethodEntryExitEvents.java
- *  @run driver MethodEntryExitEvents SUSPEND_EVENT_THREAD MethodEntryExitEventsDebugee
- *  @run driver MethodEntryExitEvents SUSPEND_NONE MethodEntryExitEventsDebugee
- *  @run driver MethodEntryExitEvents SUSPEND_ALL MethodEntryExitEventsDebugee
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g MethodEntryExitEvents.java
+ * @run driver MethodEntryExitEvents SUSPEND_EVENT_THREAD MethodEntryExitEventsDebugee
+ * @run driver MethodEntryExitEvents SUSPEND_NONE MethodEntryExitEventsDebugee
+ * @run driver MethodEntryExitEvents SUSPEND_ALL MethodEntryExitEventsDebugee
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/MethodExitReturnValuesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/MethodExitReturnValuesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,15 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4195445 6204179
- *  @summary JDWP, JDI: Add return value to Method Exit Event
- *  @author Jim Holmlund
+ * @test
+ * @bug 4195445 6204179
+ * @summary JDWP, JDI: Add return value to Method Exit Event
+ * @author Jim Holmlund
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g MethodExitReturnValuesTest.java
- *  @run driver MethodExitReturnValuesTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g MethodExitReturnValuesTest.java
+ * @run driver MethodExitReturnValuesTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/MixedSuspendTest.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/MixedSuspendTest.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -23,16 +23,14 @@
 # questions.
 #
 
-#  @test
-#  @bug 6224859
-#  @summary JDWP: Mixing application suspends and debugger suspends can cause hangs
-# 
-#  @author Jim Holmlund
-# 
-#  @key intermittent
-#  @modules jdk.jdi
-#  @run build TestScaffold VMConnection TargetListener TargetAdapter
-#  @run shell MixedSuspendTest.sh
+# @test
+# @bug 6224859
+# @key intermittent
+# @summary JDWP: Mixing application suspends and debugger suspends can cause hangs
+# @author Jim Holmlund
+#
+# @run build TestScaffold VMConnection TargetListener TargetAdapter
+# @run shell MixedSuspendTest.sh
 
 classname=MixedSuspendTarg
 
@@ -84,7 +82,7 @@
                 int i = 0;
             }
         }
-            
+
         System.out.println("Debuggee: end of thread");
     }
 
@@ -113,7 +111,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/ModificationWatchpoints.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ModificationWatchpoints.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4409582
- *  @summary Test all info returned by modification watchpoints
+ * @test
+ * @bug 4409582
+ * @summary Test all info returned by modification watchpoints
+ * @author Daniel Prusa (or someone in the FFJ group)
+ * @author Robert Field (modified to JDIScaffold)
  *
- *  @author Daniel Prusa (or someone in the FFJ group)
- *  @author Robert Field (modified to JDIScaffold)
- *
- *  @modules jdk.jdi
- *  @run build JDIScaffold VMConnection
- *  @run compile -g ModificationWatchpoints.java
- *  @run driver ModificationWatchpoints
+ * @run build JDIScaffold VMConnection
+ * @run compile -g ModificationWatchpoints.java
+ * @run driver ModificationWatchpoints
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/ModulesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ModulesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,14 +22,13 @@
  */
 
 /**
- *  @test
- *  @bug 8049365
- *  @summary Tests the JDI and JDWP update for modules
+ * @test
+ * @bug 8049365
+ * @summary Tests the JDI and JDWP update for modules
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g ModulesTest.java
- *  @run driver ModulesTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g ModulesTest.java
+ * @run driver ModulesTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/MonitorEventTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/MonitorEventTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4401399
- *  @summary Simple basic test of jdi Monitor request and event.
+ * @test
+ * @bug 4401399
+ * @summary Simple basic test of jdi Monitor request and event.
+ * @author Swamy Venkataramanappa
  *
- *  @author Swamy Venkataramanappa
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g MonitorEventTest.java
- *  @run driver MonitorEventTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g MonitorEventTest.java
+ * @run driver MonitorEventTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/MonitorFrameInfo.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/MonitorFrameInfo.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 6230699
- *  @summary Test ThreadReference.ownedMonitorsAndFrames()
- *  @bug 6701700
- *  @summary MonitorInfo objects aren't invalidated when the owning thread is resumed
- *  @author Swamy Venkataramanappa
+ * @test
+ * @bug 6230699
+ * @summary Test ThreadReference.ownedMonitorsAndFrames()
+ * @bug 6701700
+ * @summary MonitorInfo objects aren't invalidated when the owning thread is resumed
+ * @author Swamy Venkataramanappa
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g MonitorFrameInfo.java
- *  @run driver MonitorFrameInfo
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g MonitorFrameInfo.java
+ * @run driver MonitorFrameInfo
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/MultiBreakpointsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/MultiBreakpointsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,16 +23,14 @@
 
 
 /**
- *  @test
- *  @bug 4359247
- *  @summary Breakpoints on multiple threads have problems.
+ * @test
+ * @bug 4359247
+ * @summary Breakpoints on multiple threads have problems.
+ * @author tbell, jjh
  *
- *  @author tbell, jjh
- *
- *  @modules jdk.jdi
- *  @build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g MultiBreakpointsTest.java
- *  @run driver MultiBreakpointsTest
+ * @build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g MultiBreakpointsTest.java
+ * @run driver MultiBreakpointsTest
  */
 
 /*
--- a/jdk/test/com/sun/jdi/NativeInstanceFilter.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/NativeInstanceFilter.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 6426034
- *  @summary Instance filter doesn't filter event if it occurs in native method
+ * @test
+ * @bug 6426034
+ * @summary Instance filter doesn't filter event if it occurs in native method
+ * @author Keith McGuigan
  *
- *  @author Keith McGuigan
- *
- *  @modules jdk.jdi
- *  @run build JDIScaffold VMConnection
- *  @compile -XDignore.symbol.file NativeInstanceFilterTarg.java
- *  @run driver NativeInstanceFilter
+ * @run build JDIScaffold VMConnection
+ * @compile -XDignore.symbol.file NativeInstanceFilterTarg.java
+ * @run driver NativeInstanceFilter
  */
 
 /*
--- a/jdk/test/com/sun/jdi/NewInstanceTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/NewInstanceTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4419450
- *  @summary Test newInstance() for arrays - currently covers
- *  only reference type arrays (see bug #4450091).
+ * @test
+ * @bug 4419450
+ * @summary Test newInstance() for arrays - currently covers
+ * only reference type arrays (see bug #4450091).
+ * @author Robert Field
  *
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g NewInstanceTest.java
- *  @run driver NewInstanceTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g NewInstanceTest.java
+ * @run driver NewInstanceTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/NoLaunchOptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/NoLaunchOptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,8 +30,9 @@
  * @bug        4554734 4724714
  * @summary    Test for -Xrunjdwp:[onthrow,onuncaught] suboptions require launch suboption
  * @author     Tim Bell
+ *
  * @library /lib/testlibrary
- * @modules jdk.jdi
+ *
  * @run compile -g NoLaunchOptionTest.java
  * @build jdk.testlibrary.* VMConnection
  * @run driver NoLaunchOptionTest
--- a/jdk/test/com/sun/jdi/NoLocInfoTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/NoLocInfoTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4642611
- *  @summary Test that method.allLineLocations() should
- *           throw AbsentInformationException exception
+ * @test
+ * @bug 4642611
+ * @summary Test that method.allLineLocations() should
+ *          throw AbsentInformationException exception
+ * @author Serguei Spitsyn
  *
- *  @author Serguei Spitsyn
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g:none NoLocInfoTest.java
- *  @run driver NoLocInfoTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g:none NoLocInfoTest.java
+ * @run driver NoLocInfoTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/NullThreadGroupNameTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/NullThreadGroupNameTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,13 +22,12 @@
  */
 
 /**
- *  @test
- *  @bug 7105883
- *  @summary Ensure that JDWP doesn't crash with a null thread group name
+ * @test
+ * @bug 7105883
+ * @summary Ensure that JDWP doesn't crash with a null thread group name
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run driver NullThreadGroupNameTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run driver NullThreadGroupNameTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.connect.*;
--- a/jdk/test/com/sun/jdi/OnThrowTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/OnThrowTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,15 @@
  */
 
 /*
- *   @test       OnThrowTest.java
- *   @bug        6263814
- *   @summary    Test for -agentlib::[onthrow,launch]
- *   @author     Kelly O'Hair
+ * @test       OnThrowTest.java
+ * @bug        6263814
+ * @summary    Test for -agentlib::[onthrow,launch]
+ * @author     Kelly O'Hair
  *
- *  @modules jdk.jdi
- *  @run compile -g OnThrowTest.java
- *  @run compile -g OnThrowTarget.java
- *  @run compile -g VMConnection.java
- *  @run driver OnThrowTest
+ * @run compile -g OnThrowTest.java
+ * @run compile -g OnThrowTarget.java
+ * @run compile -g VMConnection.java
+ * @run driver OnThrowTest
  */
 
 import java.io.File;
--- a/jdk/test/com/sun/jdi/OptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/OptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,15 @@
  */
 
 /*
- *   @test       OptionTest
- *   @bug        5095072
- *   @summary    Test for misc jdwp options, just that the option is parsed
- *   @author     Kelly O'Hair (copied from Tim Bell's NoLaunchOptionTest)
+ * @test       OptionTest
+ * @bug        5095072
+ * @summary    Test for misc jdwp options, just that the option is parsed
+ * @author     Kelly O'Hair (copied from Tim Bell's NoLaunchOptionTest)
  *
- *  @modules jdk.jdi
- *  @run compile -g OptionTest.java
- *  @run compile -g HelloWorld.java
- *  @run compile -g VMConnection.java
- *  @run driver OptionTest
+ * @run compile -g OptionTest.java
+ * @run compile -g HelloWorld.java
+ * @run compile -g VMConnection.java
+ * @run driver OptionTest
  */
 
 import java.net.ServerSocket;
--- a/jdk/test/com/sun/jdi/PopAndInvokeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/PopAndInvokeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 6517249
- *  @modules jdk.jdi
- *  @ignore 6951287
- *  @summary JDWP: Cannot do an invokeMethod after a popFrames operation
+ * @test
+ * @bug 6517249
+ * @summary JDWP: Cannot do an invokeMethod after a popFrames operation
+ * @author jjh
  *
- *  @author jjh
+ * @ignore 6951287
  *
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g PopAndInvokeTest.java
- *  @run driver PopAndInvokeTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g PopAndInvokeTest.java
+ * @run driver PopAndInvokeTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/PopAsynchronousTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/PopAsynchronousTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4467564
- *  @summary Test the popping of frames in an asynchronous context
- *           (that is, when suspended by the debugger at random points)
+ * @test
+ * @bug 4467564
+ * @summary Test the popping of frames in an asynchronous context
+ *          (that is, when suspended by the debugger at random points)
+ * @author Robert Field
  *
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g PopAsynchronousTest.java
- *  @run driver PopAsynchronousTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g PopAsynchronousTest.java
+ * @run driver PopAsynchronousTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/PopSynchronousTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/PopSynchronousTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4467564
- *  @summary Test the popping of frames in synchronous context
- *           (that is, when stopped at an event)
+ * @test
+ * @bug 4467564
+ * @summary Test the popping of frames in synchronous context
+ *          (that is, when stopped at an event)
+ * @author Robert Field
  *
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g PopSynchronousTest.java
- *  @run driver PopSynchronousTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g PopSynchronousTest.java
+ * @run driver PopSynchronousTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/RedefineCrossEvent.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/RedefineCrossEvent.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,52 +22,52 @@
  */
 
 /**
- *  @test
- *  @bug 4628726
- *  @summary Test class redefinition at each event cross tested with other tests
+ * @test
+ * @bug 4628726
+ * @summary Test class redefinition at each event cross tested with other tests
+ * @author Robert Field
  *
- *  @author Robert Field
+ * @modules java.corba
+ *          jdk.jdi
  *
- *  @modules java.corba
- *           jdk.jdi
- *  @run build TestScaffold VMConnection TargetAdapter TargetListener
- *  @run compile -g AccessSpecifierTest.java
- *  @run compile -g AfterThreadDeathTest.java
- *  @run compile -g ArrayRangeTest.java
- *  @run compile -g BacktraceFieldTest.java
- *  @run compile -g ClassesByName2Test.java
- *  @run compile -g DebuggerThreadTest.java
- *  @run compile -g DeleteEventRequestsTest.java
- *  @run compile -g ExceptionEvents.java
- *  @run compile -g ExpiredRequestDeletionTest.java
- *  @run compile -g FieldWatchpoints.java
- *  @run build InstanceFilter
- *  @run compile -g LocationTest.java
- *  @run compile -g NewInstanceTest.java
- *  @run compile -g PopSynchronousTest.java
- *  @run compile -g RepStepTarg.java
- *  @run compile -g RequestReflectionTest.java
+ * @run build TestScaffold VMConnection TargetAdapter TargetListener
+ * @run compile -g AccessSpecifierTest.java
+ * @run compile -g AfterThreadDeathTest.java
+ * @run compile -g ArrayRangeTest.java
+ * @run compile -g BacktraceFieldTest.java
+ * @run compile -g ClassesByName2Test.java
+ * @run compile -g DebuggerThreadTest.java
+ * @run compile -g DeleteEventRequestsTest.java
+ * @run compile -g ExceptionEvents.java
+ * @run compile -g ExpiredRequestDeletionTest.java
+ * @run compile -g FieldWatchpoints.java
+ * @run build InstanceFilter
+ * @run compile -g LocationTest.java
+ * @run compile -g NewInstanceTest.java
+ * @run compile -g PopSynchronousTest.java
+ * @run compile -g RepStepTarg.java
+ * @run compile -g RequestReflectionTest.java
  *
- *  @run driver AccessSpecifierTest -redefstart -redefevent
- *  @run driver AfterThreadDeathTest -redefstart -redefevent
- *  @run driver ArrayRangeTest -redefstart -redefevent
- *  @run driver BacktraceFieldTest -redefstart -redefevent
- *  @run driver ClassesByName2Test -redefstart -redefevent
- *  @run driver DebuggerThreadTest -redefstart -redefevent
- *  @run driver DeleteEventRequestsTest -redefstart -redefevent
- *  @run driver ExceptionEvents -redefstart -redefevent N A StackOverflowCaughtTarg java.lang.Exception
- *  @run driver ExceptionEvents -redefstart -redefevent C A StackOverflowCaughtTarg null
- *  @run driver ExceptionEvents -redefstart -redefevent C A StackOverflowCaughtTarg java.lang.StackOverflowError
- *  @run driver ExceptionEvents -redefstart -redefevent N A StackOverflowCaughtTarg java.lang.NullPointerException
- *  @run driver ExceptionEvents -redefstart -redefevent C T StackOverflowCaughtTarg java.lang.Error
- *  @run driver ExceptionEvents -redefstart -redefevent N T StackOverflowCaughtTarg java.lang.NullPointerException
- *  @run driver ExceptionEvents -redefstart -redefevent N N StackOverflowCaughtTarg java.lang.Exception
- *  @run driver ExceptionEvents -redefstart -redefevent C N StackOverflowCaughtTarg java.lang.Error
- *  @run driver ExceptionEvents -redefstart -redefevent N A StackOverflowUncaughtTarg java.lang.Exception
- *  @run driver ExpiredRequestDeletionTest -redefstart -redefevent
- *  @run driver FieldWatchpoints -redefstart -redefevent
- *  @run driver InstanceFilter -redefstart -redefevent
- *  @run driver LocationTest -redefstart -redefevent
- *  @run driver NewInstanceTest -redefstart -redefevent
- *  @run driver RequestReflectionTest -redefstart -redefevent
+ * @run driver AccessSpecifierTest -redefstart -redefevent
+ * @run driver AfterThreadDeathTest -redefstart -redefevent
+ * @run driver ArrayRangeTest -redefstart -redefevent
+ * @run driver BacktraceFieldTest -redefstart -redefevent
+ * @run driver ClassesByName2Test -redefstart -redefevent
+ * @run driver DebuggerThreadTest -redefstart -redefevent
+ * @run driver DeleteEventRequestsTest -redefstart -redefevent
+ * @run driver ExceptionEvents -redefstart -redefevent N A StackOverflowCaughtTarg java.lang.Exception
+ * @run driver ExceptionEvents -redefstart -redefevent C A StackOverflowCaughtTarg null
+ * @run driver ExceptionEvents -redefstart -redefevent C A StackOverflowCaughtTarg java.lang.StackOverflowError
+ * @run driver ExceptionEvents -redefstart -redefevent N A StackOverflowCaughtTarg java.lang.NullPointerException
+ * @run driver ExceptionEvents -redefstart -redefevent C T StackOverflowCaughtTarg java.lang.Error
+ * @run driver ExceptionEvents -redefstart -redefevent N T StackOverflowCaughtTarg java.lang.NullPointerException
+ * @run driver ExceptionEvents -redefstart -redefevent N N StackOverflowCaughtTarg java.lang.Exception
+ * @run driver ExceptionEvents -redefstart -redefevent C N StackOverflowCaughtTarg java.lang.Error
+ * @run driver ExceptionEvents -redefstart -redefevent N A StackOverflowUncaughtTarg java.lang.Exception
+ * @run driver ExpiredRequestDeletionTest -redefstart -redefevent
+ * @run driver FieldWatchpoints -redefstart -redefevent
+ * @run driver InstanceFilter -redefstart -redefevent
+ * @run driver LocationTest -redefstart -redefevent
+ * @run driver NewInstanceTest -redefstart -redefevent
+ * @run driver RequestReflectionTest -redefstart -redefevent
  */
--- a/jdk/test/com/sun/jdi/RedefineCrossStart.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/RedefineCrossStart.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,29 +22,28 @@
  */
 
 /**
- *  @test
- *  @bug 4628726
- *  @summary Test class redefinition at start only (they use breakpoint
- *  or resumeTo()) cross tested with other tests.
- *  ExceptionEvents/StackOverflowUncaughtTarg are here because they hit
- *  an unrelated crash in event testing.
+ * @test
+ * @bug 4628726
+ * @summary Test class redefinition at start only (they use breakpoint
+ * or resumeTo()) cross tested with other tests.
+ * ExceptionEvents/StackOverflowUncaughtTarg are here because they hit
+ * an unrelated crash in event testing.
  *
- *  @author Robert Field
+ * @author Robert Field
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g CountEvent.java
- *  @run compile -g CountFilterTest.java
- *  @run compile -g FramesTest.java
- *  @run compile -g InvokeTest.java
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g CountEvent.java
+ * @run compile -g CountFilterTest.java
+ * @run compile -g FramesTest.java
+ * @run compile -g InvokeTest.java
  *
- *  @run driver CountEvent -redefstart
- *  @run driver CountFilterTest -redefstart
- *  @run driver FramesTest -redefstart
- *  @run driver InvokeTest -redefstart
+ * @run driver CountEvent -redefstart
+ * @run driver CountFilterTest -redefstart
+ * @run driver FramesTest -redefstart
+ * @run driver InvokeTest -redefstart
  *
- *  @run driver ExceptionEvents -redefstart U A StackOverflowUncaughtTarg null
- *  @run driver ExceptionEvents -redefstart U A StackOverflowUncaughtTarg java.lang.Error
- *  @run driver ExceptionEvents -redefstart U A StackOverflowUncaughtTarg java.lang.StackOverflowError
- *  @run driver PopSynchronousTest -redefstart
+ * @run driver ExceptionEvents -redefstart U A StackOverflowUncaughtTarg null
+ * @run driver ExceptionEvents -redefstart U A StackOverflowUncaughtTarg java.lang.Error
+ * @run driver ExceptionEvents -redefstart U A StackOverflowUncaughtTarg java.lang.StackOverflowError
+ * @run driver PopSynchronousTest -redefstart
  */
--- a/jdk/test/com/sun/jdi/ReferrersTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ReferrersTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,15 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 5089849
- *  @summary Add support for backtracking reference graph.
- *  @author jjh
+ * @test
+ * @bug 5089849
+ * @summary Add support for backtracking reference graph.
+ * @author jjh
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g ReferrersTest.java
- *  @run driver ReferrersTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g ReferrersTest.java
+ * @run driver ReferrersTest
  */
 
 /*
--- a/jdk/test/com/sun/jdi/RepStep.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/RepStep.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,18 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4334008
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run compile -g RepStepTarg.java
- *  @run build VMConnection RepStep
- *
- *  @run driver RepStep
- *
+ * @test
+ * @bug 4334008
  * @summary RepStep detects missed step events due to lack of
  * frame pop events (in back-end).
+ * @author Robert Field
+ *
+ * @run compile -g RepStepTarg.java
+ * @run build VMConnection RepStep
+ *
+ * @run driver RepStep
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/RequestReflectionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/RequestReflectionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4425840
- *  @author Robert Field
+ * @test
+ * @bug 4425840
+ * @summary RequestReflectionTest checks to see that reflective
+ * accessors on EventRequests return what they are given.
+ * @author Robert Field
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g RequestReflectionTest.java
- *  @run driver RequestReflectionTest
- *
- *  @summary RequestReflectionTest checks to see that reflective
- *  accessors on EventRequests return what they are given.
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g RequestReflectionTest.java
+ * @run driver RequestReflectionTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/ResumeOneThreadTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ResumeOneThreadTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 6700889
- *  @summary  Thread resume invalidates all stack frames, even from other threads
+ * @test
+ * @bug 6700889
+ * @summary  Thread resume invalidates all stack frames, even from other threads
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g ResumeOneThreadTest.java
- *  @run driver ResumeOneThreadTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g ResumeOneThreadTest.java
+ * @run driver ResumeOneThreadTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/SDENullTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/SDENullTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4621289
- *  @summary vm.setDefaultStratum(null) causes a Null Ptr exception
+ * @test
+ * @bug 4621289
+ * @summary vm.setDefaultStratum(null) causes a Null Ptr exception
  *
- *  @author jjh
+ * @author jjh
  *
- *  @modules jdk.jdi
- *  @run build  TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g SDENullTest.java
- *  @run driver SDENullTest
+ * @run build  TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g SDENullTest.java
+ * @run driver SDENullTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/SimulResumerTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/SimulResumerTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 6751643
- *  @summary  ThreadReference.ownedMonitors() can return null
- *
- *  @author jjh
+ * @test
+ * @bug 6751643
+ * @key intermittent
+ * @summary ThreadReference.ownedMonitors() can return null
+ * @author jjh
  *
- *  @key intermittent
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g SimulResumerTest.java
- *  @run driver SimulResumerTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g SimulResumerTest.java
+ * @run driver SimulResumerTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/SourceNameFilterTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/SourceNameFilterTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,18 +22,16 @@
  */
 
 /**
- *  @test
- *  @bug 4836939 6646613
- *  @summary JDI add addSourceNameFilter to ClassPrepareRequest
- *
- *  @author jjh
+ * @test
+ * @bug 4836939 6646613
+ * @summary JDI add addSourceNameFilter to ClassPrepareRequest
+ * @author jjh
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g SourceNameFilterTest.java
- *  @run driver SourceNameFilterTest
- *  @run compile -g:none SourceNameFilterTest.java
- *  @run driver SourceNameFilterTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g SourceNameFilterTest.java
+ * @run driver SourceNameFilterTest
+ * @run compile -g:none SourceNameFilterTest.java
+ * @run driver SourceNameFilterTest
  */
 // The compile -g:none suppresses the lineNumber table to trigger bug 6646613.
 
--- a/jdk/test/com/sun/jdi/StepTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/StepTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4270488 4787861
- *  @author Gordon Hirsch
+ * @test
+ * @bug 4270488 4787861
+ * @author Gordon Hirsch
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetAdapter TargetListener
- *  @run compile -g MethodCalls.java
- *  @run compile -g MethodCallsReflection.java
- *  @run compile -g ControlFlow.java
- *  @run build StepTest
+ * @run build TestScaffold VMConnection TargetAdapter TargetListener
+ * @run compile -g MethodCalls.java
+ * @run compile -g MethodCallsReflection.java
+ * @run compile -g ControlFlow.java
+ * @run build StepTest
  *
  * @summary StepTest starts at a method named "go()" in the debuggee and
  * repetitively steps. It will do a step into until the maximum
@@ -46,21 +45,21 @@
  * for the debuggee files- MethodCalls.java, ...
  * See LineNumberInfo.java for more info.
  *
- *                     +--- maximum stack depth in debuggee
- *                     |  +--- step granularity: "line" or "min"
- *                     |  |    +---Expected number of steps
- *                     |  |    |  +--- Debuggee command Line
- *                     V  V    V  V      Workaround-----+
- *                                                      V
- *  @run driver StepTest 2 line  2 MethodCalls
- *  @run driver StepTest 3 line 14 MethodCalls
+ *                      +--- maximum stack depth in debuggee
+ *                      |  +--- step granularity: "line" or "min"
+ *                      |  |    +---Expected number of steps
+ *                      |  |    |  +--- Debuggee command Line
+ *                      V  V    V  V      Workaround-----+
+ *                                                       V
+ * @run driver StepTest 2 line  2 MethodCalls
+ * @run driver StepTest 3 line 14 MethodCalls
  *
- *  @run driver StepTest 2 line 18 MethodCallsReflection  12
+ * @run driver StepTest 2 line 18 MethodCallsReflection  12
  *
- *  @run driver StepTest 2 min   4 MethodCalls
- *  @run driver StepTest 3 min  43 MethodCalls
+ * @run driver StepTest 2 min   4 MethodCalls
+ * @run driver StepTest 3 min  43 MethodCalls
  *
- *  @run driver StepTest 2 line 65 ControlFlow            64
+ * @run driver StepTest 2 line 65 ControlFlow            64
  */
 
 /*
--- a/jdk/test/com/sun/jdi/SuspendThreadTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/SuspendThreadTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 6485605
- *  @summary com.sun.jdi.InternalException: Inconsistent suspend policy in internal event handler
+ * @test
+ * @bug 6485605
+ * @summary com.sun.jdi.InternalException: Inconsistent suspend policy in internal event handler
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g SuspendThreadTest.java
- *  @run driver SuspendThreadTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g SuspendThreadTest.java
+ * @run driver SuspendThreadTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/jdi/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.jdi
+
--- a/jdk/test/com/sun/jdi/TemplateTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/TemplateTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,16 +25,14 @@
 // TEMPLATE: change bug number and fill out <SUMMARY> and <AUTHOR>
 // TEMPLATE: delete TEMPLATE lines
 /**
- *  @test
- *  @bug 0000000
- *  @summary <SUMMARY>
+ * @test
+ * @bug 0000000
+ * @summary <SUMMARY>
+ * @author <AUTHOR>
  *
- *  @author <AUTHOR>
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g TemplateTest.java
- *  @run driver TemplateTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g TemplateTest.java
+ * @run driver TemplateTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/ThreadGroupTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/ThreadGroupTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4893530
- *  @summary If JDI is initially started from a thread group that is subsequently
- *           destroyed this should not impact subsequent thread creation by
- *           the virtual machine manager.
+ * @test
+ * @bug 4893530
+ * @summary If JDI is initially started from a thread group that is subsequently
+ *          destroyed this should not impact subsequent thread creation by
+ *          the virtual machine manager.
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile ThreadGroupTest.java
- *  @run driver ThreadGroupTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile ThreadGroupTest.java
+ * @run driver ThreadGroupTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.connect.*;
--- a/jdk/test/com/sun/jdi/TwoThreadsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/TwoThreadsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 6296125
- *  @summary  JDI: Disabling an EventRequest can cause a multi-threaded debuggee to hang
+ * @test
+ * @bug 6296125
+ * @summary  JDI: Disabling an EventRequest can cause a multi-threaded debuggee to hang
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g TwoThreadsTest.java
- *  @run driver TwoThreadsTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g TwoThreadsTest.java
+ * @run driver TwoThreadsTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/UTF8Test.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/UTF8Test.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 5033550
- *  @summary  JDWP back end uses modified UTF-8
+ * @test
+ * @bug 5033550
+ * @summary  JDWP back end uses modified UTF-8
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g UTF8Test.java
- *  @run driver UTF8Test
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g UTF8Test.java
+ * @run driver UTF8Test
  */
 
 /*
--- a/jdk/test/com/sun/jdi/UnpreparedByName.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/UnpreparedByName.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,18 +22,17 @@
  */
 
 /**
- *  @test
- *  @bug 4368402
- *  @summary UnpreparedByName verifies that unprepared classes
- *  won't be returned by classesByName.
- *  @author Robert Field
+ * @test
+ * @bug 4368402
+ * @summary UnpreparedByName verifies that unprepared classes
+ * won't be returned by classesByName.
+ * @author Robert Field
  *
- *  @modules jdk.jdi
- *  @run build JDIScaffold VMConnection
- *  @run compile -g InnerTarg.java
- *  @run build UnpreparedByName
+ * @run build JDIScaffold VMConnection
+ * @run compile -g InnerTarg.java
+ * @run build UnpreparedByName
  *
- *  @run driver UnpreparedByName InnerTarg
+ * @run driver UnpreparedByName InnerTarg
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/UnpreparedClasses.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/UnpreparedClasses.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,18 +22,17 @@
  */
 
 /**
- *  @test
- *  @bug 4368402
- *  @summary UnpreparedClasses verifies that all the classes in the
- *  loaded class list are prepared classes.
- *  @author Robert Field
+ * @test
+ * @bug 4368402
+ * @summary UnpreparedClasses verifies that all the classes in the
+ * loaded class list are prepared classes.
+ * @author Robert Field
  *
- *  @modules jdk.jdi
- *  @run build JDIScaffold VMConnection
- *  @run compile -g InnerTarg.java
- *  @run build UnpreparedClasses
+ * @run build JDIScaffold VMConnection
+ * @run compile -g InnerTarg.java
+ * @run build UnpreparedClasses
  *
- *  @run driver UnpreparedClasses InnerTarg
+ * @run driver UnpreparedClasses InnerTarg
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/VMDeathLastTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/VMDeathLastTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,17 +22,15 @@
  */
 
 /**
- *  @test
- *  @bug 4420844 4449394
- *  @summary Checks that no events are sent after VMDeath, and test vm.canBeModified
- *
- *  @author Robert Field
+ * @test
+ * @bug 4420844 4449394
+ * @summary Checks that no events are sent after VMDeath, and test vm.canBeModified
+ * @author Robert Field
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g HelloWorld.java
- *  @run build VMDeathLastTest
- *  @run driver VMDeathLastTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g HelloWorld.java
+ * @run build VMDeathLastTest
+ * @run driver VMDeathLastTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/VMDeathRequestTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/VMDeathRequestTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,22 +22,20 @@
  */
 
 /**
- *  @test
- *  @bug 4419314
- *  @author Robert Field
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g HelloWorld.java
- *  @run build VMDeathRequestTest
- *  @run driver VMDeathRequestTest
- *
+ * @test
+ * @bug 4419314
  * @summary VMDeathRequestTest checks to see that
  * VMDisconnectedException is never thrown before VMDisconnectEvent.
  *
  * Failure mode for this test is throwing VMDisconnectedException
  * on vm.eventQueue().remove();
  * Does not use a scaffold since we don't want that hiding the exception.
+ * @author Robert Field
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g HelloWorld.java
+ * @run build VMDeathRequestTest
+ * @run driver VMDeathRequestTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/VarargsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/VarargsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @bug 4870984
- *  @summary  JPDA: Add support for RFE 4856541 - varargs
+ * @test
+ * @bug 4870984
+ * @summary  JPDA: Add support for RFE 4856541 - varargs
+ * @author jjh
  *
- *  @author jjh
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g VarargsTest.java
- *  @run driver VarargsTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g VarargsTest.java
+ * @run driver VarargsTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/Vars.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/Vars.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,15 +22,13 @@
  */
 
 /**
- *  @test
- *  @summary Test Method.variables() and the like.
- *
- *  @author Robert Field
+ * @test
+ * @summary Test Method.variables() and the like.
+ * @author Robert Field
  *
- *  @modules jdk.jdi
- *  @run build JDIScaffold VMConnection
- *  @run compile -g Vars.java
- *  @run driver Vars
+ * @run build JDIScaffold VMConnection
+ * @run compile -g Vars.java
+ * @run driver Vars
  */
 
 import com.sun.jdi.*;
--- a/jdk/test/com/sun/jdi/VisibleMethods.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/VisibleMethods.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,16 +22,14 @@
  */
 
 /**
- *  @test
- *  @summary Test ReferenceType.visibleMethods
- *  @bug 8028430
+ * @test
+ * @summary Test ReferenceType.visibleMethods
+ * @bug 8028430
+ * @author Staffan Larsen
  *
- *  @author Staffan Larsen
- *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g VisibleMethods.java
- *  @run driver VisibleMethods
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g VisibleMethods.java
+ * @run driver VisibleMethods
  */
 import com.sun.jdi.Method;
 import com.sun.jdi.ReferenceType;
--- a/jdk/test/com/sun/jdi/connect/spi/GeneratedConnectors.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/connect/spi/GeneratedConnectors.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,7 +30,6 @@
  * to encapsulate the transport. This tests that the connectors are
  * created and that they have an "address" argument.
  *
- * @modules jdk.jdi/com.sun.tools.jdi
  * @build GeneratedConnectors NullTransportService SimpleLaunchingConnector
  * @run main/othervm GeneratedConnectors
  */
--- a/jdk/test/com/sun/jdi/redefine/RedefineTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/redefine/RedefineTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,20 +22,20 @@
  */
 
 /**
- *  @test
- *  @bug 4287595
- *  @bug 4462989
- *  @bug 4531511
- *  @summary Test class redefinition
+ * @test
+ * @bug 4287595
+ * @bug 4462989
+ * @bug 4531511
+ * @summary Test class redefinition
  *
- *  @author Robert Field
+ * @author Robert Field
+ *
+ * @library ..
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g RedefineTest.java
- *  @run shell RedefineSetUp.sh
- *  @run driver RedefineTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g RedefineTest.java
+ * @run shell RedefineSetUp.sh
+ * @run driver RedefineTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/redefineMethod/RedefineTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/redefineMethod/RedefineTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,19 +22,18 @@
  */
 
 /**
- *  @test
- *  @bug 4628726
- *  @summary Test class redefinition - method data line numbers and local vars,
- *
- *  @author Robert Field
+ * @test
+ * @bug 4628726
+ * @summary Test class redefinition - method data line numbers and local vars,
+ * @author Robert Field
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g RedefineTest.java
- *  @run shell RedefineSetUp.sh
- *  @run driver RedefineTest -repeat 3
- *  @run driver RedefineTest
+ * @library ..
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g RedefineTest.java
+ * @run shell RedefineSetUp.sh
+ * @run driver RedefineTest -repeat 3
+ * @run driver RedefineTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/sde/FilterMangleTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/sde/FilterMangleTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,31 +1,30 @@
 /**
- *  @test
- *  @bug 4836939
- *  @summary JDI add addSourceNameFilter to ClassPrepareRequest
+ * @test
+ * @bug 4836939
+ * @key intermittent
+ * @summary JDI add addSourceNameFilter to ClassPrepareRequest
+ * @author Robert Field / Jim Holmlund
  *
- *  @author Robert Field / Jim Holmlund
+ * @library ..
  *
- *  @key intermittent
- *  @library ..
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
- *  @run compile FilterMangleTest.java
- *  @run compile -g onion/pickle/Mangle.java
- *  @run driver FilterMangleTest
- *  @run driver FilterMangleTest SDE-pMangle.java*
- *  @run driver FilterMangleTest SDE-pMangle.jav*
- *  @run driver FilterMangleTest SDE-pMangle.j*
- *  @run driver FilterMangleTest SDE-p*Mangle.java
- *  @run driver FilterMangleTest SDE-p*angle.java
- *  @run driver FilterMangleTest SDE-p*java
- *  @run driver FilterMangleTest SDE-pMangle.xyz
- *  @run driver FilterMangleTest SDE-pIncl.rats*
- *  @run driver FilterMangleTest SDE-pIncl.rat*
- *  @run driver FilterMangleTest SDE-p*angle.rats
- *  @run driver FilterMangleTest SDE-f*Incl.rat
- *  @run driver FilterMangleTest SDE-ffred
- *  @run driver FilterMangleTest SDE-f*ratsx
- *  @run driver FilterMangleTest SDE-fMangle.javax*
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
+ * @run compile FilterMangleTest.java
+ * @run compile -g onion/pickle/Mangle.java
+ * @run driver FilterMangleTest
+ * @run driver FilterMangleTest SDE-pMangle.java*
+ * @run driver FilterMangleTest SDE-pMangle.jav*
+ * @run driver FilterMangleTest SDE-pMangle.j*
+ * @run driver FilterMangleTest SDE-p*Mangle.java
+ * @run driver FilterMangleTest SDE-p*angle.java
+ * @run driver FilterMangleTest SDE-p*java
+ * @run driver FilterMangleTest SDE-pMangle.xyz
+ * @run driver FilterMangleTest SDE-pIncl.rats*
+ * @run driver FilterMangleTest SDE-pIncl.rat*
+ * @run driver FilterMangleTest SDE-p*angle.rats
+ * @run driver FilterMangleTest SDE-f*Incl.rat
+ * @run driver FilterMangleTest SDE-ffred
+ * @run driver FilterMangleTest SDE-f*ratsx
+ * @run driver FilterMangleTest SDE-fMangle.javax*
  */
 
 /*
--- a/jdk/test/com/sun/jdi/sde/MangleStepTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/sde/MangleStepTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,21 +1,20 @@
 /**
- *  @test
- *  @bug 4390869
- *  @bug 4460328
- *  @summary Test Stepping in the new SourceDebugExtension facility
+ * @test
+ * @bug 4390869
+ * @bug 4460328
+ * @summary Test Stepping in the new SourceDebugExtension facility
+ * @author Robert Field
  *
- *  @author Robert Field
+ * @library ..
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
- *  @run compile MangleStepTest.java
- *  @run compile -g  onion/pickle/Mangle.java
- *  @run driver MangleStepTest unset
- *  @run driver MangleStepTest Java
- *  @run driver MangleStepTest XYZ
- *  @run driver MangleStepTest Rats
- *  @run driver MangleStepTest bogus
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
+ * @run compile MangleStepTest.java
+ * @run compile -g  onion/pickle/Mangle.java
+ * @run driver MangleStepTest unset
+ * @run driver MangleStepTest Java
+ * @run driver MangleStepTest XYZ
+ * @run driver MangleStepTest Rats
+ * @run driver MangleStepTest bogus
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/sde/MangleTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/sde/MangleTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,17 +1,16 @@
 /**
- *  @test
- *  @bug 4390869
- *  @bug 4460328
- *  @summary Test the new SourceDebugExtension facility
+ * @test
+ * @bug 4390869
+ * @bug 4460328
+ * @summary Test the new SourceDebugExtension facility
+ * @author Robert Field
  *
- *  @author Robert Field
+ * @library ..
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
- *  @run compile MangleTest.java
- *  @run compile -g onion/pickle/Mangle.java
- *  @run driver MangleTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
+ * @run compile MangleTest.java
+ * @run compile -g onion/pickle/Mangle.java
+ * @run driver MangleTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/sde/SourceDebugExtensionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/sde/SourceDebugExtensionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,17 +1,16 @@
 /**
- *  @test
- *  @bug 4390869
- *  @bug 4460328
- *  @summary Test the new SourceDebugExtension facility
+ * @test
+ * @bug 4390869
+ * @bug 4460328
+ * @summary Test the new SourceDebugExtension facility
+ * @author Robert Field
  *
- *  @author Robert Field
+ * @library ..
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
- *  @run compile SourceDebugExtensionTest.java
- *  @run compile -g SourceDebugExtensionTarg.java
- *  @run driver SourceDebugExtensionTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
+ * @run compile SourceDebugExtensionTest.java
+ * @run compile -g SourceDebugExtensionTarg.java
+ * @run driver SourceDebugExtensionTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/jdi/sde/TemperatureTableTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/jdi/sde/TemperatureTableTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,17 +1,16 @@
 /**
- *  @test
- *  @bug 4390869
- *  @bug 4460328
- *  @summary Test the new SourceDebugExtension facility
+ * @test
+ * @bug 4390869
+ * @bug 4460328
+ * @summary Test the new SourceDebugExtension facility
+ * @author Robert Field
  *
- *  @author Robert Field
+ * @library ..
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE HelloWorld
- *  @run compile TemperatureTableTest.java
- *  @run compile -g TemperatureTableServlet.java
- *  @run driver TemperatureTableTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE HelloWorld
+ * @run compile TemperatureTableTest.java
+ * @run compile -g TemperatureTableServlet.java
+ * @run driver TemperatureTableTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- a/jdk/test/com/sun/management/DiagnosticCommandMBean/DcmdMBeanDoubleInvocationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/DiagnosticCommandMBean/DcmdMBeanDoubleInvocationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Basic Test for the DiagnosticCommandMBean
  * @author  Frederic Parain, Shanliang JIANG
  *
- * @modules jdk.management
  * @run main/othervm DcmdMBeanDoubleInvocationTest
  */
 
--- a/jdk/test/com/sun/management/DiagnosticCommandMBean/DcmdMBeanInvocationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/DiagnosticCommandMBean/DcmdMBeanInvocationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Basic Test for the DiagnosticCommandMBean
  * @author  Frederic Parain, Shanliang JIANG
  *
- * @modules jdk.management
  * @run main/othervm DcmdMBeanInvocationTest
  */
 
--- a/jdk/test/com/sun/management/DiagnosticCommandMBean/DcmdMBeanPermissionsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/DiagnosticCommandMBean/DcmdMBeanPermissionsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,9 @@
  * @summary Permissions Tests for the DiagnosticCommandMBean
  * @author  Frederic Parain
  *
- * @modules jdk.management
+ * @modules java.logging
+ *          java.management
+ *
  * @run main/othervm DcmdMBeanPermissionsTest
  */
 
--- a/jdk/test/com/sun/management/DiagnosticCommandMBean/DcmdMBeanTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/DiagnosticCommandMBean/DcmdMBeanTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Basic Test for the DiagnosticCommandMBean
  * @author  Frederic Parain, Shanliang JIANG
  *
- * @modules jdk.management
  * @run main/othervm DcmdMBeanTest
  */
 
--- a/jdk/test/com/sun/management/GarbageCollectorMXBean/LastGCInfo.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/GarbageCollectorMXBean/LastGCInfo.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Sanity Test for GarbageCollectorMXBean.getLastGcInfo().
  * @author  Mandy Chung
  *
- * @modules jdk.management
  * @run main/othervm -XX:-ExplicitGCInvokesConcurrent LastGCInfo
  */
 // Passing "-XX:-ExplicitGCInvokesConcurrent" to force System.gc()
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticOptions.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticOptions.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticOptions()
  * @author  Daniel Fuchs
  *
- * @modules jdk.management
  * @run main GetDiagnosticOptions
  */
 
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetDoubleVMOption.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetDoubleVMOption.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Basic Test for HotSpotDiagnosticMXBean.getVMOption() and double values
  * @author  Jaroslav Bachorik
  *
- * @modules jdk.management
  * @run main/othervm -XX:CompileThresholdScaling=0.14 GetDoubleVMOption
  */
 
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Basic Test for HotSpotDiagnosticMXBean.getVMOption()
  * @author  Mandy Chung
  *
- * @modules jdk.management
  * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError GetVMOption
  */
 
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/SetAllVMOptions.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/SetAllVMOptions.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Basic Test for HotSpotDiagnosticMXBean.setVMOption()
  * @author  Tomas Hurka, Daniel Fuchs
  *
- * @modules jdk.management
  * @run main SetAllVMOptions
  */
 
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,6 @@
  * @author  Mandy Chung
  * @author  Jaroslav Bachorik
  *
- * @modules jdk.management
  * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError SetVMOption
  */
 
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/GetCommittedVirtualMemorySize.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/GetCommittedVirtualMemorySize.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     4858522 6191542
  * @summary Basic unit test of OperatingSystemMXBean.getCommittedVirtualMemorySize()
  * @author  Steve Bohne
- * @modules jdk.management
  */
 
 /*
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/GetFreePhysicalMemorySize.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/GetFreePhysicalMemorySize.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     4858522
  * @summary Basic unit test of OperatingSystemMXBean.getFreePhysicalMemorySize()
  * @author  Steve Bohne
- * @modules jdk.management
  */
 
 /*
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/GetFreeSwapSpaceSize.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/GetFreeSwapSpaceSize.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     4858522
  * @summary Basic unit test of OperatingSystemMXBean.getFreeSwapSpaceSize()
  * @author  Steve Bohne
- * @modules jdk.management
  */
 
 /*
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     7028071
  * @summary Basic unit test of OperatingSystemMXBean.getProcessCpuLoad()
  *
- * @modules jdk.management
  * @run main GetProcessCpuLoad
  */
 
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/GetProcessCpuTime.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/GetProcessCpuTime.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     4858522
  * @summary Basic unit test of OperatingSystemMXBean.getProcessCpuTime()
  * @author  Steve Bohne
- * @modules jdk.management
  */
 
 /*
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     7028071
  * @summary Basic unit test of OperatingSystemMXBean.getProcessCpuLoad()
  *
- * @modules jdk.management
  * @run main GetSystemCpuLoad
  */
 
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/GetTotalPhysicalMemorySize.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/GetTotalPhysicalMemorySize.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     4858522
  * @summary Basic unit test of OperatingSystemMXBean.getTotalPhysicalMemorySize()
  * @author  Steve Bohne
- * @modules jdk.management
  */
 
 /*
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/MemoryStatusOverflow.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/MemoryStatusOverflow.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,6 @@
  *      the GlobalMemoryStatus function can return incorrect information,
  *      reporting a value of -1 to indicate an overflow.
  *
- * @modules jdk.management
  * @run main MemoryStatusOverflow
  */
 
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,14 +25,13 @@
  * @test
  * @bug     4858522
  * @summary Basic unit test of OperatingSystemMXBean.getTotalSwapSpaceSize()
+ * @author  Steve Bohne
+ * @author  Jaroslav Bachorik
  *
  * @library /lib/testlibrary
- * @modules jdk.management
+ *
  * @build TestTotalSwap jdk.testlibrary.*
  * @run main TestTotalSwap
- *
- * @author  Steve Bohne
- * @author  Jaroslav Bachorik
  */
 
 /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/management/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.management
+
--- a/jdk/test/com/sun/management/ThreadMXBean/ThreadAllocatedMemory.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/ThreadMXBean/ThreadAllocatedMemory.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     6173675
  * @summary Basic test of ThreadMXBean.getThreadAllocatedBytes
  * @author  Paul Hohensee
- * @modules jdk.management
  */
 
 import java.lang.management.*;
--- a/jdk/test/com/sun/management/ThreadMXBean/ThreadAllocatedMemoryArray.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/ThreadMXBean/ThreadAllocatedMemoryArray.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     6173675
  * @summary Basic test of ThreadMXBean.getThreadAllocatedBytes(long[])
  * @author  Paul Hohensee
- * @modules jdk.management
  */
 
 import java.lang.management.*;
--- a/jdk/test/com/sun/management/ThreadMXBean/ThreadCpuTimeArray.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/ThreadMXBean/ThreadCpuTimeArray.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,11 +24,10 @@
 /*
  * @test
  * @bug     6173675
+ * @key randomness
  * @summary Basic test of ThreadMXBean.getThreadCpuTime(long[]) and
  *          getThreadUserTime(long[]).
  * @author  Paul Hohensee
- * @key randomness
- * @modules jdk.management
  */
 
 import java.lang.management.*;
--- a/jdk/test/com/sun/management/UnixOperatingSystemMXBean/GetMaxFileDescriptorCount.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/UnixOperatingSystemMXBean/GetMaxFileDescriptorCount.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -24,10 +24,9 @@
 #
 # @test
 # @bug     4858522
-# @summary 
+# @summary
 # @author  Steve Bohne
 #
-# @modules jdk.management
 # @run shell GetMaxFileDescriptorCount.sh
 #
 
@@ -40,7 +39,7 @@
 fi
 
 runOne()
-{ 
+{
    echo "runOne $@"
    $COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d $TESTCLASSES \
        $TESTSRC/$@.java || exit 2
--- a/jdk/test/com/sun/management/UnixOperatingSystemMXBean/GetOpenFileDescriptorCount.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/UnixOperatingSystemMXBean/GetOpenFileDescriptorCount.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -24,10 +24,9 @@
 #
 # @test
 # @bug     4858522
-# @summary 
+# @summary
 # @author  Steve Bohne
 #
-# @modules jdk.management
 # @run shell GetOpenFileDescriptorCount.sh
 #
 
@@ -39,7 +38,7 @@
     COMPILEJAVA="${TESTJAVA}"
 fi
 runOne()
-{ 
+{
    echo "runOne $@"
    $COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d $TESTCLASSES \
        $TESTSRC/$@.java || exit 2
--- a/jdk/test/com/sun/management/VMOptionOpenDataTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/management/VMOptionOpenDataTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -38,7 +38,6 @@
  * @test
  * @bug     8042901
  * @summary Check that MappedMXBeanType.toOpenTypeData supports VMOption
- * @modules jdk.management/com.sun.management
  * @author  Shanliang Jiang
  */
 public class VMOptionOpenDataTest {
--- a/jdk/test/com/sun/tools/attach/BasicTests.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/BasicTests.java	Wed Jul 05 23:09:40 2017 +0200
@@ -40,16 +40,17 @@
 /*
  * @test
  * @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
- * @summary Basic unit tests for the VM attach mechanism.
  * @key intermittent
+ * @summary Basic unit tests for the VM attach mechanism. This test will perform
+ * a number of basic attach tests.
+ *
  * @library /lib/testlibrary
  * @modules java.instrument
- *          java.management
+ *          jdk.attach
  *          jdk.jartool/sun.tools.jar
+ *
  * @run build jdk.testlibrary.* Agent BadAgent RedefineAgent Application RedefineDummy RunnerUtil
  * @run main BasicTests
- *
- * This test will perform a number of basic attach tests.
  */
 public class BasicTests {
 
--- a/jdk/test/com/sun/tools/attach/PermissionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/PermissionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -31,17 +31,15 @@
 /*
  * @test
  * @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
- * @summary Basic unit tests for the VM attach mechanism.
- * @modules jdk.jartool/sun.tools.jar
+ * @summary Basic unit tests for the VM attach mechanism. Unit test for Attach
+ * API - this checks that a SecurityException is thrown as expected.
+ *
  * @library /lib/testlibrary
- * @modules java.management
- *          jdk.attach
+ * @modules jdk.attach
  *          jdk.jartool/sun.tools.jar
+ *
  * @run build jdk.testlibrary.* Application
  * @run main PermissionTest
- *
- * Unit test for Attach API -
- * this checks that a SecurityException is thrown as expected.
  */
 public class PermissionTest {
 
--- a/jdk/test/com/sun/tools/attach/ProviderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/ProviderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -31,16 +31,15 @@
 /*
  * @test
  * @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
- * @summary Basic unit tests for the VM attach mechanism.
- * @modules jdk.jartool/sun.tools.jar
+ * @summary Basic unit tests for the VM attach mechanism. The test will attach
+ * and detach to/from the running Application.
+ *
  * @library /lib/testlibrary
- * @modules java.management
- *          jdk.attach
+ * @modules jdk.attach
  *          jdk.jartool/sun.tools.jar
+ *
  * @run build jdk.testlibrary.* SimpleProvider
  * @run main ProviderTest
- *
- * The test will attach and detach to/from the running Application.
  */
 public class ProviderTest {
 
--- a/jdk/test/com/sun/tools/attach/StartManagementAgent.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/StartManagementAgent.java	Wed Jul 05 23:09:40 2017 +0200
@@ -39,11 +39,12 @@
 /*
  * @test
  * @summary Test for VirtualMachine.startManagementAgent and VirtualMachine.startLocalManagementAgent
- * @modules jdk.jartool/sun.tools.jar
+ *
  * @library /lib/testlibrary
- * @modules jdk.management.agent
+ * @modules java.management
  *          jdk.attach
  *          jdk.jartool/sun.tools.jar
+ *
  * @run build Application SimpleProvider jdk.testlibrary.*
  * @run main/timeout=300 StartManagementAgent
  */
--- a/jdk/test/com/sun/tools/attach/TempDirTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/TempDirTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -37,10 +37,11 @@
  * @test
  * @bug 8033104
  * @summary Test to make sure attach and jvmstat works correctly when java.io.tmpdir is set
- * @modules jdk.jartool/sun.tools.jar
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ * @modules jdk.attach
  *          jdk.jartool/sun.tools.jar
+ *
  * @run build jdk.testlibrary.* Application RunnerUtil
  * @run main/timeout=200 TempDirTest
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,125 @@
+/*
+ * 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.awt.Choice;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+
+/**
+ * @test
+ * @bug 8176448
+ * @run main/timeout=300 ChoicePopupLocation
+ */
+public final class ChoicePopupLocation {
+
+    private static final int SIZE = 350;
+    private static int frameWidth;
+
+    public static void main(final String[] args) throws Exception {
+        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+        GraphicsDevice[] sds = ge.getScreenDevices();
+        Point left = null;
+        Point right = null;
+        for (GraphicsDevice sd : sds) {
+            GraphicsConfiguration gc = sd.getDefaultConfiguration();
+            Rectangle bounds = gc.getBounds();
+            if (left == null || left.x > bounds.x) {
+                left = new Point(bounds.x, bounds.y + bounds.height / 2);
+            }
+            if (right == null || right.x < bounds.x + bounds.width) {
+                right = new Point(bounds.x + bounds.width,
+                                  bounds.y + bounds.height / 2);
+            }
+
+            Point point = new Point(bounds.x, bounds.y);
+            Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
+            while (point.y < bounds.y + bounds.height - insets.bottom - SIZE ) {
+                while (point.x < bounds.x + bounds.width - insets.right - SIZE) {
+                    test(point);
+                    point.translate(bounds.width / 5, 0);
+                }
+                point.setLocation(bounds.x, point.y + bounds.height / 5);
+            }
+
+        }
+        if (left != null) {
+            left.translate(-50, 0);
+            test(left);
+        }
+        if (right != null) {
+            right.translate(-frameWidth + 50, 0);
+            test(right);
+        }
+    }
+
+    private static void test(final Point tmp) throws Exception {
+        Choice choice = new Choice();
+        for (int i = 1; i < 7; i++) {
+            choice.add("Long-long-long-long-long text in the item-" + i);
+        }
+        Frame frame = new Frame();
+        try {
+            frame.setAlwaysOnTop(true);
+            frame.setLayout(new FlowLayout());
+            frame.add(choice);
+            frame.pack();
+            frameWidth = frame.getWidth();
+            frame.setSize(frameWidth, SIZE);
+            frame.setVisible(true);
+            frame.setLocation(tmp.x, tmp.y);
+            openPopup(choice);
+        } finally {
+            frame.dispose();
+        }
+    }
+
+    private static void openPopup(final Choice choice) throws Exception {
+        Robot robot = new Robot();
+        robot.setAutoDelay(100);
+        robot.setAutoWaitForIdle(true);
+        robot.waitForIdle();
+        Point pt = choice.getLocationOnScreen();
+        robot.mouseMove(pt.x + choice.getWidth() / 2,
+                        pt.y + choice.getHeight() / 2);
+        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+        int x = pt.x + choice.getWidth() / 2;
+        int y = pt.y + choice.getHeight() / 2 + 70;
+        robot.mouseMove(x, y);
+        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+        robot.waitForIdle();
+        if (choice.getSelectedIndex() == 0) {
+            throw new RuntimeException();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/PopupMenu/PopupMenuLocation.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,126 @@
+/*
+ * 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.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.PopupMenu;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.*;
+
+/**
+ * @test
+ * @bug 8160270
+ * @run main/timeout=300 PopupMenuLocation
+ */
+public final class PopupMenuLocation {
+
+    private static final int SIZE = 350;
+    public static final String TEXT =
+            "Long-long-long-long-long-long-long text in the item-";
+    private static volatile boolean action = false;
+
+    public static void main(final String[] args) throws Exception {
+        GraphicsEnvironment ge =
+                GraphicsEnvironment.getLocalGraphicsEnvironment();
+        GraphicsDevice[] sds = ge.getScreenDevices();
+        for (GraphicsDevice sd : sds) {
+            GraphicsConfiguration gc = sd.getDefaultConfiguration();
+            Rectangle bounds = gc.getBounds();
+            Point point = new Point(bounds.x, bounds.y);
+            Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
+            while (point.y < bounds.y + bounds.height - insets.bottom - SIZE) {
+                while (point.x
+                        < bounds.x + bounds.width - insets.right - SIZE) {
+                    test(point);
+                    point.translate(bounds.width / 5, 0);
+                }
+                point.setLocation(bounds.x, point.y + bounds.height / 5);
+            }
+        }
+    }
+
+    private static void test(final Point tmp) throws Exception {
+        PopupMenu pm = new PopupMenu();
+        for (int i = 1; i < 7; i++) {
+            pm.add(TEXT + i);
+        }
+        pm.addActionListener(e -> action = true);
+        Frame frame = new Frame();
+        try {
+            frame.setAlwaysOnTop(true);
+            frame.setLayout(new FlowLayout());
+            frame.add(pm);
+            frame.pack();
+            frame.setSize(SIZE, SIZE);
+            frame.setVisible(true);
+            frame.setLocation(tmp.x, tmp.y);
+            frame.addMouseListener(new MouseAdapter() {
+                public void mousePressed(MouseEvent e) {
+                    show(e);
+                }
+
+                public void mouseReleased(MouseEvent e) {
+                    show(e);
+                }
+
+                private void show(MouseEvent e) {
+                    if (e.isPopupTrigger()) {
+                        pm.show(frame, 0, 50);
+                    }
+                }
+            });
+            openPopup(frame);
+        } finally {
+            frame.dispose();
+        }
+    }
+
+    private static void openPopup(final Frame frame) throws Exception {
+        Robot robot = new Robot();
+        robot.setAutoDelay(200);
+        robot.waitForIdle();
+        Point pt = frame.getLocationOnScreen();
+        robot.mouseMove(pt.x + frame.getWidth() / 2, pt.y + 50);
+        robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
+        robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
+        int x = pt.x + frame.getWidth() / 2;
+        int y = pt.y + 130;
+        robot.mouseMove(x, y);
+        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+        robot.waitForIdle();
+        if (!action) {
+            throw new RuntimeException();
+        }
+        action = false;
+    }
+}
--- a/jdk/test/java/io/FileInputStream/LargeFileAvailable.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/io/FileInputStream/LargeFileAvailable.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, 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
@@ -27,6 +27,7 @@
  * @key intermittent
  * @summary Test if available returns correct value when reading
  *          a large file.
+ * @run main/timeout=300 LargeFileAvailable
  */
 
 import java.io.*;
@@ -34,6 +35,7 @@
 import java.nio.channels.*;
 import java.nio.file.Files;
 import static java.nio.file.StandardOpenOption.*;
+import java.util.concurrent.TimeUnit;
 
 public class LargeFileAvailable {
     public static void main(String args[]) throws Exception {
@@ -110,7 +112,12 @@
                               CREATE_NEW, WRITE, SPARSE)) {
             ByteBuffer bb = ByteBuffer.allocate(1).put((byte)1);
             bb.rewind();
+            System.out.println("  Writing large file...");
+            long t0 = System.nanoTime();
             int rc = fc.write(bb, filesize - 1);
+            long t1 = System.nanoTime();
+            System.out.printf("  Wrote large file in %d ns (%d ms) %n",
+                t1 - t0, TimeUnit.NANOSECONDS.toMillis(t1 - t0));
 
             if (rc != 1) {
                 throw new RuntimeException("Failed to write 1 byte"
--- a/jdk/test/java/io/FilePermission/ReadFileOnPath.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/io/FilePermission/ReadFileOnPath.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8164705
  * @library /lib/testlibrary /test/lib
  * @modules java.base/jdk.internal.misc
- *          java.compiler
+ *          jdk.compiler
  * @run main ReadFileOnPath
  * @summary Still able to read file on the same path
  */
--- a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java	Wed Jul 05 23:09:40 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
@@ -380,6 +380,7 @@
             permissions.add(new RuntimePermission("closeClassLoader"));
             permissions.add(new RuntimePermission("getClassLoader"));
             permissions.add(new RuntimePermission("accessDeclaredMembers"));
+            permissions.add(new RuntimePermission("accessSystemModules"));
             permissions.add(new ReflectPermission("suppressAccessChecks"));
             permissions.add(new PropertyPermission("*", "read"));
             permissions.add(new FilePermission("<<ALL FILES>>", "read"));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ClassLoader/getResource/automaticmodules/Driver.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @library /lib/testlibrary
+ * @build Driver Main JarUtils jdk.testlibrary.ProcessTools
+ * @run main Driver
+ * @summary Test ClassLoader.getResourceXXX to locate resources in an automatic
+ *          module
+ */
+
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import jdk.testlibrary.ProcessTools;
+
+/**
+ * The driver creates a JAR file containing p/Foo.class, p/foo.properties,
+ * and p/resources/bar.properties. This ensures there are is a resource in
+ * a module package and a resource that is not in the module package. The
+ * test is then launched to locate every resource in the JAR file.
+ */
+
+public class Driver {
+
+    private static final String TEST_CLASSES = System.getProperty("test.classes");
+
+    public static void main(String[] args) throws Exception {
+        // create content for JAR file
+        Path dir = Files.createTempDirectory("classes");
+        Path p = Files.createDirectory(dir.resolve("p"));
+        Files.createFile(p.resolve("Foo.class"));
+        Files.createFile(p.resolve("foo.properties"));
+        Path resources = Files.createDirectory(p.resolve("resources"));
+        Files.createFile(resources.resolve("bar.properties"));
+
+        // create the JAR file, including a manifest
+        Path jarFile = Paths.get("library-1.0.jar");
+        Manifest man = new Manifest();
+        Attributes attrs = man.getMainAttributes();
+        attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0.0");
+        JarUtils.createJarFile(jarFile, man, dir, p);
+
+        // get the module name
+        ModuleFinder finder = ModuleFinder.of(jarFile);
+        ModuleReference mref = finder.findAll().stream().findAny().orElse(null);
+        if (mref == null)
+            throw new RuntimeException("Module not found!!!");
+        String name = mref.descriptor().name();
+
+        // launch the test with the JAR file on the module path
+        if (ProcessTools.executeTestJava("-p", jarFile.toString(),
+                                         "--add-modules", name,
+                                         "-cp", TEST_CLASSES,
+                                         "Main", name)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue() != 0)
+            throw new RuntimeException("Test failed - see output");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ClassLoader/getResource/automaticmodules/Main.java	Wed Jul 05 23:09:40 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.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.module.ModuleReader;
+import java.lang.module.ModuleReference;
+import java.lang.module.ResolvedModule;
+import java.lang.reflect.Layer;
+import java.net.URL;
+import java.util.Enumeration;
+
+/**
+ * Usage: Main $MODULE
+ *
+ * Finds $MODULE in the boot layer and then tests that it can locate every
+ * resource in the module content (JAR file).
+ */
+
+public class Main {
+
+    static void testFind(String name) throws Exception {
+        // getResource
+        URL url = Main.class.getClassLoader().getResource(name);
+        if (url == null)
+            throw new RuntimeException("Unable to locate: " + name);
+        System.out.println(name + " => " + url);
+
+        // getResources
+        Enumeration<URL> urls = Main.class.getClassLoader().getResources(name);
+        if (!urls.hasMoreElements())
+            throw new RuntimeException("Unable to locate: " + name);
+        URL first = urls.nextElement();
+        if (!first.toURI().equals(url.toURI()))
+            throw new RuntimeException("found " + first + " ???");
+
+        // getResourceAsStream
+        if (!url.toString().endsWith("/")) {
+            InputStream in = Main.class.getClassLoader().getResourceAsStream(name);
+            if (in == null)
+                throw new RuntimeException("Unable to locate: " + name);
+            in.close();
+        }
+    }
+
+    static void testFindUnchecked(String name) {
+        try {
+            testFind(name);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        String mn = args[0];
+
+        ModuleReference mref = Layer.boot()
+                .configuration()
+                .findModule(mn)
+                .map(ResolvedModule::reference)
+                .orElseThrow(() -> new RuntimeException(mn + " not resolved!!"));
+
+        try (ModuleReader reader = mref.open()) {
+            reader.list().forEach(name -> {
+                testFindUnchecked(name);
+
+                // if the resource is a directory then find without trailing slash
+                if (name.endsWith("/")) {
+                    testFindUnchecked(name.substring(0, name.length() - 1));
+                }
+            });
+        }
+    }
+}
--- a/jdk/test/java/lang/Package/annotation/PackageInfoTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/Package/annotation/PackageInfoTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,8 +25,7 @@
  * @test
  * @summary Basic test of package-info in named module and duplicate
  *          package-info in unnamed module
- * @modules java.compiler
- *          java.desktop
+ * @modules java.desktop
  *          jdk.compiler
  *          jdk.xml.dom
  * @build jdk.xml.dom/org.w3c.dom.css.Fake
--- a/jdk/test/java/lang/ProcessHandle/JavaChild.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/ProcessHandle/JavaChild.java	Wed Jul 05 23:09:40 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,7 +28,6 @@
 import java.io.InputStreamReader;
 import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.PrintStream;
 import java.io.Reader;
 import java.io.PrintWriter;
 import java.lang.InterruptedException;
@@ -39,9 +38,11 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.Optional;
 import java.util.function.Consumer;
 
 
@@ -437,6 +438,11 @@
                     case "threaddump":
                         Thread.dumpStack();
                         break;
+                    case "waitpid":
+                        long pid = Long.parseLong(args[nextArg++]);
+                        Optional<String> s = ProcessHandle.of(pid).map(ph -> waitAlive(ph));
+                        sendResult(action, s.orElse("pid not valid: " + pid));
+                        break;
                     default:
                         throw new Error("JavaChild action unknown: " + action);
                 }
@@ -447,6 +453,17 @@
         }
     }
 
+    private static String waitAlive(ProcessHandle ph) {
+        String status;
+        try {
+            boolean isAlive = ph.onExit().get().isAlive();
+            status = Boolean.toString(isAlive);
+        } catch (InterruptedException | ExecutionException ex ) {
+            status = "interrupted";
+        }
+        return status;
+    }
+
     static synchronized void sendRaw(String s) {
         System.out.println(s);
         System.out.flush();
@@ -476,6 +493,7 @@
         System.err.println("  spawn <n> command... - spawn n new children and send command");
         System.err.println("  child command... - send command to all live children");
         System.err.println("  child_eof - send eof to all live children");
+        System.err.println("  waitpid <pid> - wait for the pid to exit");
         System.err.println("  exit <exitcode>");
         System.err.println("  out arg...");
         System.err.println("  err arg...");
--- a/jdk/test/java/lang/ProcessHandle/OnExitTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/ProcessHandle/OnExitTest.java	Wed Jul 05 23:09:40 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
@@ -26,9 +26,11 @@
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
 
 import jdk.test.lib.Utils;
 
@@ -196,4 +198,95 @@
         }
     }
 
+    /**
+     * Verify that onExit completes for a non-child process only when
+     * the process has exited.
+     * Spawn a child (A) waiting to be commanded to exit.
+     * Spawn a child (B) to wait for that process to exit.
+     * Command (A) to exit.
+     * Check that (B) does not complete until (A) has exited.
+     */
+    @Test
+    public static void peerOnExitTest() {
+        String line = null;
+        ArrayBlockingQueue<String> alines = new ArrayBlockingQueue<>(100);
+        ArrayBlockingQueue<String> blines = new ArrayBlockingQueue<>(100);
+        JavaChild A = null;
+        try {
+            String[] split;
+            A = JavaChild.spawnJavaChild("stdin");
+            A.forEachOutputLine(l -> alines.add(l));
+
+            // Verify A is running
+            A.sendAction("pid");
+            do {
+                split = getSplitLine(alines);
+            } while (!"pid".equals(split[1]));
+
+            JavaChild B = null;
+            try {
+                B = JavaChild.spawnJavaChild("stdin");
+                B.forEachOutputLine(l -> blines.add(l));
+
+                // Verify B is running
+                B.sendAction("pid");
+                do {
+                    split = getSplitLine(blines);
+                } while (!"pid".equals(split[1]));
+
+                // Tell B to wait for A's pid
+                B.sendAction("waitpid", A.getPid());
+
+                // Wait a bit to see if B will prematurely report the termination of A
+                try {
+                    line = blines.poll(5L, TimeUnit.SECONDS);
+                } catch (InterruptedException ie) {
+                    Assert.fail("interrupted", ie);
+                }
+                Assert.assertNull(line, "waitpid didn't wait");
+
+                A.sendAction("exit", 0L);
+
+                // Look for B to report that A has exited
+                do {
+                    split = getSplitLine(blines);
+                } while (!"waitpid".equals(split[1]));
+
+                Assert.assertEquals(split[2], "false",  "Process A should not be alive");
+
+                B.sendAction("exit", 0L);
+            } catch (IOException ioe) {
+                Assert.fail("unable to start JavaChild B", ioe);
+            } finally {
+                B.destroyForcibly();
+            }
+        } catch (IOException ioe2) {
+            Assert.fail("unable to start JavaChild A", ioe2);
+        } finally {
+            A.destroyForcibly();
+        }
+    }
+
+    private static boolean DEBUG = true;
+
+    /**
+     * Get a line from the queue and split into words on whitespace.
+     * Log to stdout if requested.
+     * @param queue a queue of strings
+     * @return the words split from the line.
+     */
+    private static String[] getSplitLine(ArrayBlockingQueue<String> queue) {
+        try {
+            String line = queue.take();
+            String[] split = line.split("\\s");
+            if (DEBUG) {
+                System.out.printf("  Child Output: %s%n", line);
+            }
+            return split;
+        } catch (InterruptedException ie) {
+            Assert.fail("interrupted", ie);
+            return null;
+        }
+    }
+
 }
--- a/jdk/test/java/lang/Runtime/Version/Basic.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/Runtime/Version/Basic.java	Wed Jul 05 23:09:40 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
  * @summary Unit test for java.lang.Runtime.Version.
- * @bug 8072379 8144062 8161236
+ * @bug 8072379 8144062 8161236 8160956
  */
 
 import java.lang.reflect.InvocationTargetException;
@@ -129,6 +129,9 @@
         testEHC("9",          "10",               false, false, -1,   -1);
         testEHC("9",          "8",                false, false,  1,    1);
 
+        testEHC("10.512.1",   "10.512.2",         false, false, -1,   -1);
+        testEHC("512.10.1",   "512.11.1",         false, false, -1,   -1);
+
         // $OPT comparison
         testEHC("9",          "9+-oink",          false, true,  -1,    0);
         testEHC("9+-ribbit",  "9+-moo",           false, true,   1,    0);
@@ -140,7 +143,7 @@
         testEHC("9.1.1.2-2a", "9.1.1.2-12",       false, false,  1,    1);
         testEHC("9.1.1.2-12", "9.1.1.2-4",        false, false,  1,    1);
 
-        testEHC("27.16",      "27.16+120",        false, false,  1,    1);
+        testEHC("27.16",      "27.16+120",        false, false, -1,   -1);
         testEHC("10",         "10-ea",            false, false,  1,    1);
         testEHC("10.1+1",     "10.1-ea+1",        false, false,  1,    1);
         testEHC("10.0.1+22",  "10.0.1+21",        false, false,  1,    1);
@@ -152,7 +155,7 @@
         testEHC("9-internal", "9",                false, false, -1,   -1);
         testEHC("9-ea+120",   "9+120",            false, false, -1,   -1);
         testEHC("9-ea+120",   "9+120",            false, false, -1,   -1);
-        testEHC("9+101",      "9",                false, false, -1,   -1);
+        testEHC("9+101",      "9",                false, false,  1,    1);
         testEHC("9+101",      "9+102",            false, false, -1,   -1);
         testEHC("1.9-ea",     "9-ea",             false, false, -1,   -1);
 
--- a/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -50,7 +50,7 @@
         if (args.length > 0 && args[0].equals("sm")) {
             sm = true;
             PermissionCollection perms = new Permissions();
-            perms.add(new StackFramePermission("retainClassReference"));
+            perms.add(new RuntimePermission("getStackWalkerWithClassReference"));
             Policy.setPolicy(new Policy() {
                 @Override
                 public boolean implies(ProtectionDomain domain, Permission p) {
--- a/jdk/test/java/lang/StackWalker/GetCallerClassTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/StackWalker/GetCallerClassTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -55,7 +55,7 @@
     public static void main(String... args) throws Exception {
         if (args.length > 0 && args[0].equals("sm")) {
             PermissionCollection perms = new Permissions();
-            perms.add(new StackFramePermission("retainClassReference"));
+            perms.add(new RuntimePermission("getStackWalkerWithClassReference"));
             Policy.setPolicy(new Policy() {
                 @Override
                 public boolean implies(ProtectionDomain domain, Permission p) {
--- a/jdk/test/java/lang/StackWalker/stackwalk.policy	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/StackWalker/stackwalk.policy	Wed Jul 05 23:09:40 2017 +0200
@@ -1,4 +1,4 @@
 grant {
-  permission java.lang.StackFramePermission "retainClassReference";
+  permission java.lang.RuntimePermission "getStackWalkerWithClassReference";
 };
 
--- a/jdk/test/java/lang/StackWalker/stackwalktest.policy	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/StackWalker/stackwalktest.policy	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 grant {
-  permission java.lang.StackFramePermission "retainClassReference";
+  permission java.lang.RuntimePermission "getStackWalkerWithClassReference";
   permission java.util.PropertyPermission "seed", "read";
 };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
+import java.lang.System.LoggerFinder;
+import java.lang.reflect.Module;
+import java.util.Enumeration;
+import java.util.Locale;
+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
+ * @summary Checks that the DefaultLoggerFinder and LoggingProviderImpl
+ *          implementations of the System.LoggerFinder conform to the
+ *          LoggerFinder specification, in particular with respect to
+ *          throwing NullPointerException. The test uses --limit-module
+ *          to force the selection of one or the other.
+ * @author danielfuchs
+ * @build LoggerFinderAPI
+ * @run main/othervm --limit-modules java.base,java.logging
+ *          -Djava.util.logging.SimpleFormatter.format=LOG-%4$s:-[%2$s]-%5$s%6$s%n
+ *          LoggerFinderAPI
+ * @run main/othervm -Djdk.system.logger.format=LOG-%4$s:-[%2$s]-%5$s%6$s%n
+ *          --limit-modules java.base
+ *          LoggerFinderAPI
+ */
+public class LoggerFinderAPI {
+
+    // Simplified log format string. No white space for main/othervm line
+    static final String TEST_FORMAT = "LOG-%4$s:-[%2$s]-%5$s%6$s%n";
+    static final String JDK_FORMAT_PROP_KEY = "jdk.system.logger.format";
+    static final String JUL_FORMAT_PROP_KEY =
+        "java.util.logging.SimpleFormatter.format";
+
+    static class RecordStream extends OutputStream {
+        static final Object LOCK = new Object[0];
+        final PrintStream out;
+        final PrintStream err;
+        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        boolean record;
+        RecordStream(PrintStream out, PrintStream err) {
+            this.out = out;
+            this.err = err;
+        }
+
+        @Override
+        public void write(int i) throws IOException {
+            if (record) {
+                bos.write(i);
+                out.write(i);
+            } else {
+                err.write(i);
+            }
+        }
+
+        void startRecording() {
+            out.flush();
+            err.flush();
+            bos.reset();
+            record = true;
+        }
+        byte[] stopRecording() {
+            out.flush();
+            err.flush();
+            record = false;
+            return bos.toByteArray();
+        }
+    }
+
+    static final PrintStream ERR = System.err;
+    static final PrintStream OUT = System.out;
+    static final RecordStream LOG_STREAM = new RecordStream(OUT, ERR);
+    static {
+        Locale.setDefault(Locale.US);
+        PrintStream perr = new PrintStream(LOG_STREAM);
+        System.setErr(perr);
+    }
+
+    public static class MyResourceBundle extends ResourceBundle {
+        final ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
+        @Override
+        protected Object handleGetObject(String string) {
+            return map.computeIfAbsent(string, s -> "[localized] " + s);
+        }
+
+        @Override
+        public Enumeration<String> getKeys() {
+            return map.keys();
+        }
+
+    }
+
+    public static void main(String[] args) {
+        // Set on the command line, to ensure that the test will fail if
+        // the 'wrong' provider gets selected.
+        // System.setProperty(JDK_FORMAT_PROP_KEY, TEST_FORMAT);
+        // System.setProperty(JUL_FORMAT_PROP_KEY, TEST_FORMAT);
+        LoggerFinder finder = System.LoggerFinder.getLoggerFinder();
+        System.out.println("LoggerFinder is " + finder.getClass().getName());
+
+        LoggerFinderAPI apiTest = new LoggerFinderAPI();
+        for (Object[] params : getLoggerDataProvider()) {
+            apiTest.testGetLogger((String)params[0],
+                                  (String)params[1],
+                                  (Module)params[2],
+                                  Throwable.class.getClass().cast(params[3]));
+        }
+        for (Object[] params : getLocalizedLoggerDataProvider()) {
+            apiTest.testGetLocalizedLogger((String)params[0],
+                                  (String)params[1],
+                                  (ResourceBundle)params[2],
+                                  (Module)params[3],
+                                  Throwable.class.getClass().cast(params[4]));
+        }
+    }
+
+    //Can't use testng because testng requires java.logging
+    //@Test(dataProvider = "testGetLoggerDataProvider")
+    void testGetLogger(String desc, String name, Module mod, Class<? extends Throwable> thrown) {
+        try {
+            LoggerFinder finder = System.LoggerFinder.getLoggerFinder();
+            Logger logger = finder.getLogger(name, mod);
+            if (thrown != null) {
+                throw new AssertionError("Exception " + thrown.getName()
+                        + " not thrown for "
+                        + "LoggerFinder.getLogger"
+                        + " with " + desc);
+            }
+            // Make sure we don't fail if tests are run in parallel
+            synchronized(RecordStream.LOCK) {
+                LOG_STREAM.startRecording();
+                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");
+                }
+            }
+        } catch (Throwable x) {
+            if (thrown != null && thrown.isInstance(x)) {
+                System.out.printf("Got expected exception for %s with %s: %s\n",
+                        "LoggerFinder.getLogger", desc, String.valueOf(x));
+            } else throw x;
+        }
+    }
+
+    //Can't use testng because testng requires java.logging
+    //@Test(dataProvider = "getLocalizedLoggerDataProvider")
+    void testGetLocalizedLogger(String desc, String name, ResourceBundle bundle,
+                                Module mod, Class<? extends Throwable> thrown) {
+        try {
+            LoggerFinder finder = System.LoggerFinder.getLoggerFinder();
+            Logger logger = finder.getLocalizedLogger(name, bundle, mod);
+            if (thrown != null) {
+                throw new AssertionError("Exception " + thrown.getName()
+                        + " not thrown for "
+                        + "LoggerFinder.getLocalizedLogger"
+                        + " with " + desc);
+            }
+            // Make sure we don't fail if tests are run in parallel
+            synchronized(RecordStream.LOCK) {
+                LOG_STREAM.startRecording();
+                try {
+                    logger.log(Level.INFO, "{0} with {1}: PASSED",
+                              "LoggerFinder.getLocalizedLogger",
+                              desc);
+                } finally {
+                    byte[] logged = LOG_STREAM.stopRecording();
+                    check(logged, "testGetLocalizedLogger", desc, bundle,
+                          "LoggerFinder.getLocalizedLogger");
+                }
+            }
+        } catch (Throwable x) {
+            if (thrown != null && thrown.isInstance(x)) {
+                System.out.printf("Got expected exception for %s with %s: %s\n",
+                        "LoggerFinder.getLocalizedLogger", desc, String.valueOf(x));
+            } else throw x;
+        }
+    }
+
+    private void check(byte[] logged, String test, String desc,
+                       ResourceBundle bundle, String meth) {
+        String msg = new String(logged);
+        String expected = String.format(TEST_FORMAT, null,
+                "LoggerFinderAPI " + test, null, Level.INFO.name(),
+                (bundle==null?"":"[localized] ") + meth + " with " + desc + ": PASSED",
+                "");
+        if (!Objects.equals(msg, expected)) {
+            throw new AssertionError("Expected log message not found: "
+                                     + "\n\texpected:  " + expected
+                                     + "\n\tretrieved: " + msg);
+        }
+    }
+
+
+    static final Module MODULE = LoggerFinderAPI.class.getModule();
+    static final ResourceBundle BUNDLE = new MyResourceBundle();
+    static final Object[][] GET_LOGGER = {
+        {"null name", null, MODULE , NullPointerException.class},
+        {"null module", "foo", null, NullPointerException.class},
+        {"null name and module", null, null, NullPointerException.class},
+        {"non null name and module", "foo", MODULE, null},
+    };
+    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 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},
+    };
+    public static Object[][] getLoggerDataProvider() {
+        return GET_LOGGER;
+    }
+    public static Object[][] getLocalizedLoggerDataProvider() {
+        return GET_LOCALIZED_LOGGER;
+    }
+}
--- a/jdk/test/java/lang/instrument/RedefineModuleTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/instrument/RedefineModuleTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,7 +24,7 @@
 /**
  * @test
  * @summary Basic test for redefineModule
- * @modules java.instrument
+ *
  * @build java.base/java.lang.TestProvider
  *        java.base/jdk.internal.test.TestProviderImpl1
  *        java.base/jdk.internal.test.TestProviderImpl2
--- a/jdk/test/java/lang/instrument/TestAgentWithLimitMods.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/instrument/TestAgentWithLimitMods.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @test
  * @summary Tests that the -javaagent option adds the java.instrument into
  * the module graph
- * @modules java.instrument
+ *
  * @run shell MakeJAR3.sh SimpleAgent
  * @run main/othervm -javaagent:SimpleAgent.jar --limit-modules java.base TestAgentWithLimitMods
  *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/DefineClassTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @modules java.base/java.lang:open
+ *          java.base/jdk.internal.org.objectweb.asm
+ * @run testng/othervm test.DefineClassTest
+ * @summary Basic test for java.lang.invoke.MethodHandles.Lookup.defineClass
+ */
+
+package test;
+
+import java.lang.invoke.MethodHandles.Lookup;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodHandles.Lookup.*;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import static jdk.internal.org.objectweb.asm.Opcodes.*;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+public class DefineClassTest {
+    private static final String THIS_PACKAGE = DefineClassTest.class.getPackageName();
+
+    /**
+     * Test that a class has the same class loader, and is in the same package and
+     * protection domain, as a lookup class.
+     */
+    void testSameAbode(Class<?> clazz, Class<?> lc) {
+        assertTrue(clazz.getClassLoader() == lc.getClassLoader());
+        assertEquals(clazz.getPackageName(), lc.getPackageName());
+        assertTrue(clazz.getProtectionDomain() == lc.getProtectionDomain());
+    }
+
+    /**
+     * Tests that a class is discoverable by name using Class.forName and
+     * lookup.findClass
+     */
+    void testDiscoverable(Class<?> clazz, Lookup lookup) throws Exception {
+        String cn = clazz.getName();
+        ClassLoader loader = clazz.getClassLoader();
+        assertTrue(Class.forName(cn, false, loader) == clazz);
+        assertTrue(lookup.findClass(cn) == clazz);
+    }
+
+    /**
+     * Basic test of defineClass to define a class in the same package as test.
+     */
+    @Test
+    public void testDefineClass() throws Exception {
+        final String CLASS_NAME = THIS_PACKAGE + ".Foo";
+        Lookup lookup = lookup().dropLookupMode(PRIVATE);
+        Class<?> clazz = lookup.defineClass(generateClass(CLASS_NAME));
+
+        // test name
+        assertEquals(clazz.getName(), CLASS_NAME);
+
+        // test loader/package/protection-domain
+        testSameAbode(clazz, lookup.lookupClass());
+
+        // test discoverable
+        testDiscoverable(clazz, lookup);
+
+        // attempt defineClass again
+        try {
+            lookup.defineClass(generateClass(CLASS_NAME));
+            assertTrue(false);
+        } catch (LinkageError expected) { }
+    }
+
+    /**
+     * Test public/package/protected/private access from class defined with defineClass.
+     */
+    @Test
+    public void testAccess() throws Exception {
+        final String THIS_CLASS = this.getClass().getName();
+        final String CLASS_NAME = THIS_PACKAGE + ".Runner";
+        Lookup lookup = lookup().dropLookupMode(PRIVATE);
+
+        // public
+        byte[] classBytes = generateRunner(CLASS_NAME + nextNumber(), THIS_CLASS, "method1");
+        testInvoke(lookup.defineClass(classBytes));
+
+        // package
+        classBytes = generateRunner(CLASS_NAME + nextNumber(), THIS_CLASS, "method2");
+        testInvoke(lookup.defineClass(classBytes));
+
+        // protected (same package)
+        classBytes = generateRunner(CLASS_NAME + nextNumber(), THIS_CLASS, "method3");
+        testInvoke(lookup.defineClass(classBytes));
+
+        // private
+        classBytes = generateRunner(CLASS_NAME + nextNumber(), THIS_CLASS, "method4");
+        Class<?> clazz = lookup.defineClass(classBytes);
+        Runnable r = (Runnable) clazz.newInstance();
+        try {
+            r.run();
+            assertTrue(false);
+        } catch (IllegalAccessError expected) { }
+    }
+
+    public static void method1() { }
+    static void method2() { }
+    protected static void method3() { }
+    private static void method4() { }
+
+    void testInvoke(Class<?> clazz) throws Exception {
+        Object obj = clazz.newInstance();
+        ((Runnable) obj).run();
+    }
+
+    /**
+     * Test that defineClass does not run the class initializer
+     */
+    @Test
+    public void testInitializerNotRun() throws Exception {
+        final String THIS_CLASS = this.getClass().getName();
+        final String CLASS_NAME = THIS_PACKAGE + ".ClassWithClinit";
+
+        byte[] classBytes = generateClassWithInitializer(CLASS_NAME, THIS_CLASS, "fail");
+        Lookup lookup = lookup().dropLookupMode(PRIVATE);
+
+        Class<?> clazz = lookup.defineClass(classBytes);
+        // trigger initializer to run
+        try {
+            clazz.newInstance();
+            assertTrue(false);
+        } catch (ExceptionInInitializerError e) {
+            assertTrue(e.getCause() instanceof IllegalCallerException);
+        }
+    }
+
+    static void fail() { throw new IllegalCallerException(); }
+
+
+    /**
+     * Test defineClass to define classes in a package containing classes with
+     * different protection domains.
+     */
+    @Test
+    public void testTwoProtectionDomains() throws Exception {
+        // p.C1 in one exploded directory
+        Path dir1 = Files.createTempDirectory("classes");
+        Path p = Files.createDirectory(dir1.resolve("p"));
+        Files.write(p.resolve("C1.class"), generateClass("p.C1"));
+        URL url1 = dir1.toUri().toURL();
+
+        // p.C2 in another exploded directory
+        Path dir2 = Files.createTempDirectory("classes");
+        p = Files.createDirectory(dir2.resolve("p"));
+        Files.write(p.resolve("C2.class"), generateClass("p.C2"));
+        URL url2 = dir2.toUri().toURL();
+
+        // load p.C1 and p.C2
+        ClassLoader loader = new URLClassLoader(new URL[] { url1, url2 });
+        Class<?> target1 = Class.forName("p.C1", false, loader);
+        Class<?> target2 = Class.forName("p.C2", false, loader);
+        assertTrue(target1.getClassLoader() == loader);
+        assertTrue(target1.getClassLoader() == loader);
+        assertNotEquals(target1.getProtectionDomain(), target2.getProtectionDomain());
+
+        // protection domain 1
+        Lookup lookup1 = privateLookupIn(target1, lookup()).dropLookupMode(PRIVATE);
+
+        Class<?> clazz = lookup1.defineClass(generateClass("p.Foo"));
+        testSameAbode(clazz, lookup1.lookupClass());
+        testDiscoverable(clazz, lookup1);
+
+        // protection domain 2
+        Lookup lookup2 = privateLookupIn(target2, lookup()).dropLookupMode(PRIVATE);
+
+        clazz = lookup2.defineClass(generateClass("p.Bar"));
+        testSameAbode(clazz, lookup2.lookupClass());
+        testDiscoverable(clazz, lookup2);
+    }
+
+    /**
+     * Test defineClass defining a class to the boot loader
+     */
+    @Test
+    public void testBootLoader() throws Exception {
+        Lookup lookup = privateLookupIn(Thread.class, lookup()).dropLookupMode(PRIVATE);
+        assertTrue(lookup.getClass().getClassLoader() == null);
+
+        Class<?> clazz = lookup.defineClass(generateClass("java.lang.Foo"));
+        assertEquals(clazz.getName(), "java.lang.Foo");
+        testSameAbode(clazz, Thread.class);
+        testDiscoverable(clazz, lookup);
+    }
+
+    @Test(expectedExceptions = { IllegalArgumentException.class })
+    public void testWrongPackage() throws Exception {
+        Lookup lookup = lookup().dropLookupMode(PRIVATE);
+        lookup.defineClass(generateClass("other.C"));
+    }
+
+    @Test(expectedExceptions = { IllegalAccessException.class })
+    public void testNoPackageAccess() throws Exception {
+        Lookup lookup = lookup().dropLookupMode(PACKAGE);
+        lookup.defineClass(generateClass(THIS_PACKAGE + ".C"));
+    }
+
+    @Test(expectedExceptions = { UnsupportedOperationException.class })
+    public void testHasPrivateAccess() throws Exception {
+        Lookup lookup = lookup();
+        assertTrue(lookup.hasPrivateAccess());
+        lookup.defineClass(generateClass(THIS_PACKAGE + ".C"));
+    }
+
+    @Test(expectedExceptions = { ClassFormatError.class })
+    public void testTruncatedClassFile() throws Exception {
+        Lookup lookup = lookup().dropLookupMode(PRIVATE);
+        lookup.defineClass(new byte[0]);
+    }
+
+    @Test(expectedExceptions = { NullPointerException.class })
+    public void testNull() throws Exception {
+        Lookup lookup = lookup().dropLookupMode(PRIVATE);
+        lookup.defineClass(null);
+    }
+
+    /**
+     * Generates a class file with the given class name
+     */
+    byte[] generateClass(String className) {
+        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
+                                         + ClassWriter.COMPUTE_FRAMES);
+        cw.visit(V1_9,
+                ACC_PUBLIC + ACC_SUPER,
+                className.replace(".", "/"),
+                null,
+                "java/lang/Object",
+                null);
+
+        // <init>
+        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+        mv.visitVarInsn(ALOAD, 0);
+        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
+        mv.visitInsn(RETURN);
+        mv.visitMaxs(0, 0);
+        mv.visitEnd();
+
+        cw.visitEnd();
+        return cw.toByteArray();
+    }
+
+    /**
+     * Generate a class file with the given class name. The class implements Runnable
+     * with a run method to invokestatic the given targetClass/targetMethod.
+     */
+    byte[] generateRunner(String className,
+                          String targetClass,
+                          String targetMethod) throws Exception {
+
+        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
+                                         + ClassWriter.COMPUTE_FRAMES);
+        cw.visit(V1_9,
+                ACC_PUBLIC + ACC_SUPER,
+                className.replace(".", "/"),
+                null,
+                "java/lang/Object",
+                new String[] { "java/lang/Runnable" });
+
+        // <init>
+        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+        mv.visitVarInsn(ALOAD, 0);
+        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
+        mv.visitInsn(RETURN);
+        mv.visitMaxs(0, 0);
+        mv.visitEnd();
+
+        // run()
+        String tc = targetClass.replace(".", "/");
+        mv = cw.visitMethod(ACC_PUBLIC, "run", "()V", null, null);
+        mv.visitMethodInsn(INVOKESTATIC, tc, targetMethod, "()V", false);
+        mv.visitInsn(RETURN);
+        mv.visitMaxs(0, 0);
+        mv.visitEnd();
+
+        cw.visitEnd();
+        return cw.toByteArray();
+    }
+
+    /**
+     * Generate a class file with the given class name. The class will initializer
+     * to invokestatic the given targetClass/targetMethod.
+     */
+    byte[] generateClassWithInitializer(String className,
+                                        String targetClass,
+                                        String targetMethod) throws Exception {
+
+        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
+                                         + ClassWriter.COMPUTE_FRAMES);
+        cw.visit(V1_9,
+                ACC_PUBLIC + ACC_SUPER,
+                className.replace(".", "/"),
+                null,
+                "java/lang/Object",
+                null);
+
+        // <init>
+        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+        mv.visitVarInsn(ALOAD, 0);
+        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
+        mv.visitInsn(RETURN);
+        mv.visitMaxs(0, 0);
+        mv.visitEnd();
+
+        // <clinit>
+        String tc = targetClass.replace(".", "/");
+        mv = cw.visitMethod(ACC_STATIC, "<clinit>", "()V", null, null);
+        mv.visitMethodInsn(INVOKESTATIC, tc, targetMethod, "()V", false);
+        mv.visitInsn(RETURN);
+        mv.visitMaxs(0, 0);
+        mv.visitEnd();
+
+        cw.visitEnd();
+        return cw.toByteArray();
+    }
+
+    private int nextNumber() {
+        return ++nextNumber;
+    }
+
+    private int nextNumber;
+}
--- a/jdk/test/java/lang/management/ClassLoadingMXBean/LoadCounts.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ClassLoadingMXBean/LoadCounts.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  *                             ClassLoadingMXBean.getTotalLoadedClassCount()
  *                             ClassLoadingMXBean.getUnloadedClassCount()
  * @author  Alexei Guibadoulline
- * @modules java.management
+ *
  * @run main/othervm LoadCounts
  */
 
--- a/jdk/test/java/lang/management/CompilationMXBean/Basic.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/CompilationMXBean/Basic.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 5011189 8004928
  * @summary Unit test for java.lang.management.CompilationMXBean
  *
- * @modules java.management
  * @run main/othervm -Xcomp -Xbatch Basic
  */
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/CompositeData/MemoryUsageCompositeData.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/CompositeData/MemoryUsageCompositeData.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          or throw exception if the input CompositeData is invalid.
  * @author  Mandy Chung
  *
- * @modules java.management
  * @build MemoryUsageCompositeData
  * @run main MemoryUsageCompositeData
  */
--- a/jdk/test/java/lang/management/CompositeData/ThreadInfoCompositeData.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/CompositeData/ThreadInfoCompositeData.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,6 @@
  *          the input CompositeData is invalid.
  * @author  Mandy Chung
  *
- * @modules java.management
  * @compile OpenTypeConverter.java
  * @build ThreadInfoCompositeData
  * @run main ThreadInfoCompositeData
--- a/jdk/test/java/lang/management/ManagementFactory/GetObjectName.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/GetObjectName.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @summary Test if getObjectName handles properly when called by
  *          multiple threads simultaneously. Run in othervm mode to
  *          make sure the object name is not initialized to begin with.
- * @modules java.management
+ *
  * @run main/othervm GetObjectName
  */
 
--- a/jdk/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          methods and PlatformManagedObject.getObjectName()
  * @author  Mandy Chung
  *
- * @modules jdk.management
  * @run main GetPlatformMXBeans
  */
 
--- a/jdk/test/java/lang/management/ManagementFactory/GetPlatformManagementInterfaces.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/GetPlatformManagementInterfaces.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          ManagementFactory.getPlatformManagementInterfaces() method
  * @author  Frederic Parain
  *
- * @modules jdk.management
  * @run main GetPlatformManagementInterfaces
  */
 
--- a/jdk/test/java/lang/management/ManagementFactory/MBeanServerMXBeanUnsupportedTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/MBeanServerMXBeanUnsupportedTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that all the platform MXBeans are wrapped in StandardMBean so
  *          an MBeanServer which does not have support for MXBeans can be used.
  * @author Luis-Miguel Alventosa
- * @modules jdk.management
+ *
  * @run clean MBeanServerMXBeanUnsupportedTest
  * @run build MBeanServerMXBeanUnsupportedTest
  * @run main/othervm MBeanServerMXBeanUnsupportedTest
--- a/jdk/test/java/lang/management/ManagementFactory/MXBeanException.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/MXBeanException.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,6 @@
  *
  * @author  Mandy Chung
  *
- * @modules jdk.management
  * @build MXBeanException
  * @run main MXBeanException
  */
--- a/jdk/test/java/lang/management/ManagementFactory/MXBeanProxyTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/MXBeanProxyTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,9 +25,9 @@
  * @test
  * @bug     5024531
  * @summary Basic Test for ManagementFactory.newPlatformMXBean().
- * @modules jdk.management
+ * @author  Mandy Chung
+ *
  * @run main/othervm MXBeanProxyTest
- * @author  Mandy Chung
  */
 import javax.management.*;
 import java.lang.management.ClassLoadingMXBean;
--- a/jdk/test/java/lang/management/ManagementFactory/PlatformMBeanServerTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/PlatformMBeanServerTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,9 @@
  * @bug     4947536
  * @summary Basic unit test of ManagementFactory.getPlatformMBeanServer()
  * @author  Mandy Chung
- * @modules jdk.management
+ *
+ * @modules java.logging
+ *          jdk.management
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/ManagementFactory/ProxyExceptions.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/ProxyExceptions.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Test type mapping of the platform MXBean proxy
  *          returned from Management.newPlatformMXBeanProxy().
  * @author  Mandy Chung
- * @modules jdk.management
  */
 import java.lang.management.*;
 import javax.management.*;
--- a/jdk/test/java/lang/management/ManagementFactory/ProxyTypeMapping.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/ProxyTypeMapping.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          returned from Management.newPlatformMXBeanProxy().
  * @author  Mandy Chung
  *
- * @modules jdk.management
  * @compile ProxyTypeMapping.java
  * @run main/othervm -verbose:gc ProxyTypeMapping
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.management
+
--- a/jdk/test/java/lang/management/ManagementFactory/ThreadMXBeanProxy.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/ThreadMXBeanProxy.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,10 +26,8 @@
  * @bug     5086470 6358247 7193302
  * @summary Test type conversion when invoking ThreadMXBean.dumpAllThreads
  *          through proxy.
- *
  * @author  Mandy Chung
  *
- * @modules jdk.management
  * @run main ThreadMXBeanProxy
  */
 
--- a/jdk/test/java/lang/management/ManagementFactory/ValidateOpenTypes.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ManagementFactory/ValidateOpenTypes.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          MBeanServer.
  * @author  Mandy Chung
  *
- * @modules jdk.management
  * @compile ValidateOpenTypes.java
  * @run main/othervm -verbose:gc ValidateOpenTypes
  */
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,16 +27,15 @@
  * @summary Basic unit test of memory management testing:
  *          1) setUsageThreshold() and getUsageThreshold()
  *          2) test low memory detection on the old generation.
- *
  * @author  Mandy Chung
  *
- * @library /lib/testlibrary/
- * @modules java.management
- * @build jdk.testlibrary.* LowMemoryTest MemoryUtil RunUtil
- * @run main/timeout=600 LowMemoryTest
  * @requires vm.gc == "null"
  * @requires vm.opt.ExplicitGCInvokesConcurrent != "true"
  * @requires vm.opt.DisableExplicitGC != "true"
+ * @library /lib/testlibrary/
+ *
+ * @build jdk.testlibrary.* LowMemoryTest MemoryUtil RunUtil
+ * @run main/timeout=600 LowMemoryTest
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -25,8 +25,9 @@
 # @test
 # @bug     4982128
 # @summary Test low memory detection of non-heap memory pool
+#
 # @requires vm.gc=="null"
-# @modules java.management
+#
 # @run build LowMemoryTest2 MemoryUtil
 # @run shell/timeout=600 LowMemoryTest2.sh
 #
@@ -51,10 +52,10 @@
 }
 
 # Run test with each GC configuration
-# 
+#
 # Notes: To ensure that metaspace fills up we disable class unloading.
 # Also we set the max metaspace to 16MB - otherwise the test takes too
-# long to run. 
+# long to run.
 
 go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseSerialGC LowMemoryTest2
 go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseParallelGC LowMemoryTest2
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -26,8 +26,9 @@
 # @bug     4530538
 # @summary Run MemoryManagement test with concurrent mark sweep GC
 # @author  Mandy Chung
+#
 # @requires vm.gc=="ConcMarkSweep" | vm.gc=="null"
-# @modules java.management
+#
 # @run build MemoryManagement
 # @run shell/timeout=600 MemoryManagementConcMarkSweepGC.sh
 #
@@ -42,7 +43,7 @@
 fi
 
 runOne()
-{ 
+{
    echo "runOne $@"
    $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2
 }
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -26,8 +26,9 @@
 # @bug     4530538
 # @summary Run MemoryManagement test with parallel GC
 # @author  Mandy Chung
+#
 # @requires vm.gc=="Parallel" | vm.gc=="null"
-# @modules java.management
+#
 # @run build MemoryManagement
 # @run shell/timeout=600 MemoryManagementParallelGC.sh
 #
@@ -42,7 +43,7 @@
 fi
 
 runOne()
-{ 
+{
    echo "runOne $@"
    $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2
 }
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -26,8 +26,9 @@
 # @bug     4530538
 # @summary Run MemoryManagement test with serial GC
 # @author  Mandy Chung
+#
 # @requires vm.gc=="Serial" | vm.gc=="null"
-# @modules java.management
+#
 # @run build MemoryManagement
 # @run shell/timeout=600 MemoryManagementSerialGC.sh
 #
@@ -42,7 +43,7 @@
 fi
 
 runOne()
-{ 
+{
    echo "runOne $@"
    $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2
 }
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -24,10 +24,11 @@
 #
 # @test
 # @bug     4530538
-# @summary 
+# @summary
 # @author  Mandy Chung
+#
 # @requires vm.gc=="Parallel" | vm.gc=="null"
-# @modules java.management
+#
 # @run compile MemoryTest.java
 # @run shell MemoryTestAllGC.sh
 #
@@ -42,7 +43,7 @@
 fi
 
 runOne()
-{ 
+{
    echo "runOne $@"
    $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@ || exit 2
 }
--- a/jdk/test/java/lang/management/MemoryMXBean/Pending.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/MemoryMXBean/Pending.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,8 +24,6 @@
 /*
  * @test
  * @bug     4530538
- * @modules java.base/jdk.internal.misc
- *          java.management
  * @summary Basic unit test of
  *          RuntimeMXBean.getObjectPendingFinalizationCount()
  *          1. GC and runFinalization() to get the current pending number
@@ -34,6 +32,9 @@
  *          4. GC and runFinalization() and the finalizable objects should
  *             be garbage collected.
  * @author  Alexei Guibadoulline and Mandy Chung
+ *
+ * @modules java.base/jdk.internal.misc
+ *          java.management
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	Wed Jul 05 23:09:40 2017 +0200
@@ -32,12 +32,13 @@
  * @summary Basic Test for MemoryPool.resetPeakUsage()
  * @author  Mandy Chung
  *
+ * @requires vm.opt.ExplicitGCInvokesConcurrent != "true"
+ * @requires vm.opt.DisableExplicitGC != "true"
  * @library /lib/testlibrary/
  * @modules jdk.management
+ *
  * @build jdk.testlibrary.* ResetPeakMemoryUsage MemoryUtil RunUtil
  * @run main ResetPeakMemoryUsage
- * @requires vm.opt.ExplicitGCInvokesConcurrent != "true"
- * @requires vm.opt.DisableExplicitGC != "true"
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          MemoryPoolMXBean.isCollectionThresholdExceeded().
  * @author  Mandy Chung
  *
- * @modules java.management
  * @run main/othervm ThresholdTest
  */
 
--- a/jdk/test/java/lang/management/OperatingSystemMXBean/TestSystemLoadAvg.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/OperatingSystemMXBean/TestSystemLoadAvg.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -23,11 +23,10 @@
 
 #
 # @test
+# @bug      6336608 6367473 6511738
 # @summary  Tests OperatingSystemMXBean.getSystemLoadAverage() api.
 # @author   Mandy Chung
-# @bug      6336608 6367473 6511738
 #
-# @modules java.management
 # @run build GetSystemLoadAverage
 # @run shell/timeout=300 TestSystemLoadAvg.sh
 #
--- a/jdk/test/java/lang/management/PlatformLoggingMXBean/LoggingMXBeanTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/PlatformLoggingMXBean/LoggingMXBeanTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Test if proxy for PlatformLoggingMXBean is equivalent
  *          to proxy for LoggingMXBean
  *
- * @modules jdk.management
  * @build LoggingMXBeanTest
  * @run main LoggingMXBeanTest
  */
--- a/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,12 +24,10 @@
 /*
  * @test
  * @bug     6876135 7024172 7067691
- *
  * @summary Test PlatformLoggingMXBean
  *          This test performs similar testing as
  *          java/util/logging/LoggingMXBeanTest.
  *
- * @modules jdk.management
  * @build PlatformLoggingMXBeanTest
  * @run main PlatformLoggingMXBeanTest
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/management/PlatformLoggingMXBean/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = java.logging
+
--- a/jdk/test/java/lang/management/RuntimeMXBean/GetSystemProperties.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/RuntimeMXBean/GetSystemProperties.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     4990512
  * @summary Basic Test for RuntimeMXBean.getSystemProperties().
  * @author  Mandy Chung
- * @modules java.management
  */
 
 import java.lang.management.ManagementFactory;
--- a/jdk/test/java/lang/management/RuntimeMXBean/PropertiesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/RuntimeMXBean/PropertiesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          properties contain another list of properties as the defaults.
  * @author  Mandy Chung
  *
- * @modules java.management
  * @run build PropertiesTest
  * @run main  PropertiesTest
  */
--- a/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -24,9 +24,9 @@
 #
 # @test
 # @bug     4530538
-# @summary 
+# @summary
 # @author  Mandy Chung
-# @modules java.management
+#
 # @run compile InputArgument.java
 # @run shell TestInputArgument.sh
 #
@@ -41,12 +41,12 @@
 fi
 
 runOne()
-{ 
+{
    echo "runOne $@"
    $TESTJAVA/bin/java $TESTVMOPTS -classpath $TESTCLASSES "$@" || exit 2
 }
 
-runOne InputArgument 
+runOne InputArgument
 
 runOne -XX:+UseFastJNIAccessors -Xlog:gc*=debug InputArgument
 runOne -XX:+UseFastJNIAccessors -Xlog:gc*=debug InputArgument -XX:+UseFastJNIAccessors
--- a/jdk/test/java/lang/management/RuntimeMXBean/UpTime.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/RuntimeMXBean/UpTime.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug     4530538
  * @summary Basic unit test of RuntimeMXBean.getUptime()
  * @author  Alexei Guibadoulline
- * @modules java.management
  */
 
 import java.lang.management.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/management/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = java.management
+
--- a/jdk/test/java/lang/management/ThreadMXBean/AllThreadIds.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/AllThreadIds.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,11 +24,10 @@
 /*
  * @test
  * @bug     4530538
+ * @key intermittent
  * @summary Basic unit test of ThreadMXBean.getAllThreadIds()
  * @author  Alexei Guibadoulline and Mandy Chung
  *
- * @key intermittent
- * @modules java.management
  * @run main/othervm AllThreadIds
  */
 
--- a/jdk/test/java/lang/management/ThreadMXBean/DisableTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/DisableTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary The capability is disabled regardless of number of times
  *          it was enabled.
  * @author  Mandy Chung
- * @modules java.management
  */
 
 import java.lang.management.ThreadMXBean;
--- a/jdk/test/java/lang/management/ThreadMXBean/EnableTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/EnableTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,6 @@
  *          and ThreadMXBean.setThreadCpuTimeEnabled().
  * @author  Mandy Chung
  *
- * @modules java.management
  * @run main EnableTest
  */
 
--- a/jdk/test/java/lang/management/ThreadMXBean/FindDeadlocks.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/FindDeadlocks.java	Wed Jul 05 23:09:40 2017 +0200
@@ -31,7 +31,6 @@
  *          - ThreadMXBean.findMonitorDeadlockedThreads()
  * @author  Mandy Chung
  *
- * @modules java.management
  * @build MonitorDeadlock
  * @build SynchronizerDeadlock
  * @build ThreadDump
--- a/jdk/test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          - ThreadMXBean.findMonitorDeadlockedThreads()
  * @author  Mandy Chung
  *
- * @modules java.management
  * @build MonitorDeadlock
  * @build ThreadDump
  * @run main/othervm FindMonitorDeadlock
--- a/jdk/test/java/lang/management/ThreadMXBean/InvalidThreadID.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/InvalidThreadID.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          if id <= 0 and returns -1 if the thread doesn't exist.
  * @author  Mandy Chung
  *
- * @modules java.management
  * @run main InvalidThreadID
  */
 
--- a/jdk/test/java/lang/management/ThreadMXBean/LockedMonitors.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/LockedMonitors.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,7 +34,6 @@
  *
  * @author  Mandy Chung
  *
- * @modules java.management
  * @build Barrier
  * @build LockingThread
  * @build ThreadDump
--- a/jdk/test/java/lang/management/ThreadMXBean/LockedSynchronizers.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/LockedSynchronizers.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,7 +30,6 @@
  *
  * @author  Mandy Chung
  *
- * @modules java.management
  * @build Barrier
  * @build SynchronizerLockingThread
  * @build ThreadDump
--- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,11 +26,11 @@
  * @bug     4530538
  * @summary Basic unit test of ThreadInfo.getLockName()
  *          and ThreadInfo.getLockOwnerName()
- * @library /lib/testlibrary
  * @author  Mandy Chung
  * @author  Jaroslav Bachorik
  *
- * @modules java.management
+ * @library /lib/testlibrary
+ *
  * @build jdk.testlibrary.*
  * @run main/othervm Locks
  */
--- a/jdk/test/java/lang/management/ThreadMXBean/MyOwnSynchronizer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/MyOwnSynchronizer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          and getThreadInfo of customized JSR-166 synchronizers.
  * @author  Mandy Chung
  *
- * @modules java.management
  * @build Barrier
  * @build ThreadDump
  * @run main/othervm MyOwnSynchronizer
--- a/jdk/test/java/lang/management/ThreadMXBean/ResetPeakThreadCount.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ResetPeakThreadCount.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,6 @@
  * @author  Mandy Chung
  * @author  Jaroslav Bachorik
  *
- * @modules java.management
  * @build ResetPeakThreadCount
  * @build ThreadDump
  * @run main/othervm ResetPeakThreadCount
--- a/jdk/test/java/lang/management/ThreadMXBean/SharedSynchronizer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/SharedSynchronizer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          in shared mode which has no owner when a thread is parked.
  * @author  Mandy Chung
  *
- * @modules java.management
  * @run main/othervm SharedSynchronizer
  */
 
--- a/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,11 +25,9 @@
  * @test
  * @bug     4530538
  * @summary Basic unit test of the synchronization statistics support:
- *
  * @author  Mandy Chung
  * @author  Jaroslav Bachorik
  *
- * @modules java.management
  * @run main/othervm SynchronizationStatistics
  */
 
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadBlockedCount.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadBlockedCount.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Basic unit test of ThreadInfo.getBlockedCount()
  * @author  Alexei Guibadoulline and Mandy Chung
  * @author  Jaroslav Bachorik
- * @modules java.management
+ *
  * @run main ThreadBlockedCount
  */
 
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadCounts.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadCounts.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,7 +30,6 @@
  *                             mbean.getDaemonThreadCount()
  * @author  Alexei Guibadoulline
  *
- * @modules java.management
  * @run main ThreadCounts
  */
 
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadCpuTime.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadCpuTime.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Basic test of ThreadMXBean.getThreadCpuTime and
  *          getCurrentThreadCpuTime.
  * @author  Mandy Chung
- * @modules java.management
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadDaemonTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadDaemonTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -31,7 +31,6 @@
  * @bug     6588467
  * @summary Basic test of ThreadInfo.isDaemon
  * @author  Jeremy Manson
- * @modules java.management
  */
 public class ThreadDaemonTest {
 
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadLists.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadLists.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 5047639
  * @summary Check that the "java-level" APIs provide a consistent view of
  *          the thread list
- * @modules java.management
  */
 import java.lang.management.ManagementFactory;
 import java.lang.management.ThreadMXBean;
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,12 +27,11 @@
  * @summary Basic unit test of thread states returned by
  *          ThreadMXBean.getThreadInfo.getThreadState().
  *          It also tests lock information returned by ThreadInfo.
- *
  * @author  Mandy Chung
  *
  * @library ../../Thread
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @build jdk.testlibrary.*
  * @build ThreadMXBeanStateTest ThreadStateController
  * @run main ThreadMXBeanStateTest
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadStackTrace.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadStackTrace.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,6 @@
  *          ThreadInfo.getThreadState()
  * @author  Mandy Chung
  *
- * @modules java.management
  * @run build Utils
  * @run main ThreadStackTrace
  */
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadUserTime.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadUserTime.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Basic test of ThreadMXBean.getThreadUserTime and
  *          getCurrentThreadUserTime.
  * @author  Mandy Chung
- * @modules java.management
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/module/AutomaticModulesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/module/AutomaticModulesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -773,9 +773,6 @@
         // test miscellaneous methods
         assertTrue(m.isAutomatic());
         assertFalse(m.modifiers().contains(ModuleDescriptor.Modifier.SYNTHETIC));
-        assertFalse(m.osName().isPresent());
-        assertFalse(m.osArch().isPresent());
-        assertFalse(m.osVersion().isPresent());
     }
 
 
--- a/jdk/test/java/lang/module/ConfigurationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/module/ConfigurationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,25 +25,31 @@
  * @test
  * @library /lib/testlibrary
  * @modules java.base/jdk.internal.misc
+ *          java.base/jdk.internal.module
  * @build ConfigurationTest ModuleUtils
  * @run testng ConfigurationTest
  * @summary Basic tests for java.lang.module.Configuration
  */
 
+import java.io.IOException;
+import java.io.OutputStream;
 import java.lang.module.Configuration;
 import java.lang.module.FindException;
 import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleDescriptor.Builder;
 import java.lang.module.ModuleDescriptor.Requires;
 import java.lang.module.ModuleFinder;
 import java.lang.module.ResolutionException;
 import java.lang.module.ResolvedModule;
 import java.lang.reflect.Layer;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
 
 import jdk.internal.misc.SharedSecrets;
+import jdk.internal.module.ModuleInfoWriter;
+import jdk.internal.module.ModuleTarget;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
@@ -438,70 +444,6 @@
 
 
     /**
-     * Basic test of "requires transitive" with configurations.
-     *
-     * The test consists of three configurations:
-     * - Configuration cf1: m1, m2 requires transitive m1
-     * - Configuration cf2: m1, m3 requires transitive m1
-     * - Configuration cf3(cf1,cf2): m4 requires m2, m3
-     */
-    public void testRequiresTransitive6() {
-        ModuleDescriptor descriptor1 = newBuilder("m1")
-                .build();
-
-        ModuleDescriptor descriptor2 = newBuilder("m2")
-                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
-                .build();
-
-        ModuleDescriptor descriptor3 = newBuilder("m3")
-                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
-                .build();
-
-        ModuleDescriptor descriptor4 = newBuilder("m4")
-                .requires("m2")
-                .requires("m3")
-                .build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
-        Configuration cf1 = resolve(finder1, "m2");
-        assertTrue(cf1.modules().size() == 2);
-        assertTrue(cf1.findModule("m1").isPresent());
-        assertTrue(cf1.findModule("m2").isPresent());
-        assertTrue(cf1.parents().size() == 1);
-        assertTrue(cf1.parents().get(0) == Configuration.empty());
-
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor3);
-        Configuration cf2 = resolve(finder2, "m3");
-        assertTrue(cf2.modules().size() == 2);
-        assertTrue(cf2.findModule("m3").isPresent());
-        assertTrue(cf2.findModule("m1").isPresent());
-        assertTrue(cf2.parents().size() == 1);
-        assertTrue(cf2.parents().get(0) == Configuration.empty());
-
-        ModuleFinder finder3 = ModuleUtils.finderOf(descriptor4);
-        Configuration cf3 = Configuration.resolve(finder3,
-                List.of(cf1, cf2),
-                ModuleFinder.of(),
-                Set.of("m4"));
-        assertTrue(cf3.modules().size() == 1);
-        assertTrue(cf3.findModule("m4").isPresent());
-
-        ResolvedModule m1_l = cf1.findModule("m1").get();
-        ResolvedModule m1_r = cf2.findModule("m1").get();
-        ResolvedModule m2 = cf1.findModule("m2").get();
-        ResolvedModule m3 = cf2.findModule("m3").get();
-        ResolvedModule m4 = cf3.findModule("m4").get();
-        assertTrue(m4.configuration() == cf3);
-
-        assertTrue(m4.reads().size() == 4);
-        assertTrue(m4.reads().contains(m1_l));
-        assertTrue(m4.reads().contains(m1_r));
-        assertTrue(m4.reads().contains(m2));
-        assertTrue(m4.reads().contains(m3));
-    }
-
-
-    /**
      * Basic test of "requires static":
      *     m1 requires static m2
      *     m2 is not observable
@@ -1603,6 +1545,76 @@
 
 
     /**
+     * Basic test to detect reading a module with the same name as itself
+     *
+     * The test consists of three configurations:
+     * - Configuration cf1: m1, m2 requires transitive m1
+     * - Configuration cf2: m1 requires m2
+     */
+    @Test(expectedExceptions = { ResolutionException.class })
+    public void testReadModuleWithSameNameAsSelf() {
+        ModuleDescriptor descriptor1_v1 = newBuilder("m1")
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
+                .build();
+
+        ModuleDescriptor descriptor1_v2 = newBuilder("m1")
+                .requires("m2")
+                .build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1_v1, descriptor2);
+        Configuration cf1 = resolve(finder1, "m2");
+        assertTrue(cf1.modules().size() == 2);
+
+        // resolve should throw ResolutionException
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1_v2);
+        resolve(cf1, finder2, "m1");
+    }
+
+
+    /**
+     * Basic test to detect reading two modules with the same name
+     *
+     * The test consists of three configurations:
+     * - Configuration cf1: m1, m2 requires transitive m1
+     * - Configuration cf2: m1, m3 requires transitive m1
+     * - Configuration cf3(cf1,cf2): m4 requires m2, m3
+     */
+    @Test(expectedExceptions = { ResolutionException.class })
+    public void testReadTwoModuleWithSameName() {
+        ModuleDescriptor descriptor1 = newBuilder("m1")
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
+                .build();
+
+        ModuleDescriptor descriptor3 = newBuilder("m3")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
+                .build();
+
+        ModuleDescriptor descriptor4 = newBuilder("m4")
+                .requires("m2")
+                .requires("m3")
+                .build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+        Configuration cf1 = resolve(finder1, "m2");
+        assertTrue(cf1.modules().size() == 2);
+
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor3);
+        Configuration cf2 = resolve(finder2, "m3");
+        assertTrue(cf2.modules().size() == 2);
+
+        // should throw ResolutionException as m4 will read modules named "m1".
+        ModuleFinder finder3 = ModuleUtils.finderOf(descriptor4);
+        Configuration.resolve(finder3, List.of(cf1, cf2), ModuleFinder.of(), Set.of("m4"));
+    }
+
+
+    /**
      * Test two modules exporting package p to a module that reads both.
      */
     @Test(expectedExceptions = { ResolutionException.class })
@@ -1832,26 +1844,17 @@
     public Object[][] createPlatformMatches() {
         return new Object[][]{
 
-            { "linux-*-*",       "*-*-*" },
-            { "*-arm-*",         "*-*-*" },
-            { "*-*-2.6",         "*-*-*" },
-
-            { "linux-arm-*",     "*-*-*" },
-            { "linux-*-2.6",     "*-*-*" },
-            { "*-arm-2.6",       "*-*-*" },
-
-            { "linux-arm-2.6",   "*-*-*" },
-
-            { "linux-*-*",       "linux-*-*" },
-            { "*-arm-*",         "*-arm-*"   },
-            { "*-*-2.6",         "*-*-2.6"   },
-
-            { "linux-arm-*",     "linux-arm-*" },
-            { "linux-arm-*",     "linux-*-*"   },
-            { "linux-*-2.6",     "linux-*-2.6" },
-            { "linux-*-2.6",     "linux-arm-*" },
-
-            { "linux-arm-2.6",   "linux-arm-2.6" },
+            { "linux-arm",     "*-*" },
+            { "linux-*",       "*-*" },
+            { "*-arm",         "*-*" },
+
+            { "linux-*",       "linux-*" },
+            { "linux-arm",     "linux-*" },
+
+            { "*-arm",         "*-arm" },
+            { "linux-arm",     "*-arm" },
+
+            { "linux-arm",   "linux-arm" },
 
         };
 
@@ -1861,9 +1864,10 @@
     public Object[][] createBad() {
         return new Object[][] {
 
-            { "linux-*-*",        "solaris-*-*"   },
-            { "linux-x86-*",      "linux-arm-*"   },
-            { "linux-*-2.4",      "linux-x86-2.6" },
+            { "linux-*",        "solaris-*"     },
+            { "*-arm",          "*-sparc"       },
+            { "linux-x86",      "solaris-sparc" },
+
         };
     }
 
@@ -1871,21 +1875,25 @@
      * Test creating a configuration containing platform specific modules.
      */
     @Test(dataProvider = "platformmatch")
-    public void testPlatformMatch(String s1, String s2) {
-
-        Builder builder = newBuilder("m1").requires("m2");
-        addPlatformConstraints(builder, s1);
-        ModuleDescriptor descriptor1 = builder.build();
-
-        builder = newBuilder("m2");
-        addPlatformConstraints(builder, s2);
-        ModuleDescriptor descriptor2 = builder.build();
-
-        ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2);
+    public void testPlatformMatch(String s1, String s2) throws IOException {
+
+        ModuleDescriptor base =  ModuleDescriptor.newModule("java.base").build();
+        Path system = writeModule(base, "*-*");
+
+        ModuleDescriptor descriptor1 = ModuleDescriptor.newModule("m1")
+                .requires("m2")
+                .build();
+        Path dir1 = writeModule(descriptor1, s1);
+
+        ModuleDescriptor descriptor2 = ModuleDescriptor.newModule("m2").build();
+        Path dir2 = writeModule(descriptor2, s2);
+
+        ModuleFinder finder = ModuleFinder.of(system, dir1, dir2);
 
         Configuration cf = resolve(finder, "m1");
 
-        assertTrue(cf.modules().size() == 2);
+        assertTrue(cf.modules().size() == 3);
+        assertTrue(cf.findModule("java.base").isPresent());
         assertTrue(cf.findModule("m1").isPresent());
         assertTrue(cf.findModule("m2").isPresent());
     }
@@ -1896,11 +1904,10 @@
      */
     @Test(dataProvider = "platformmismatch",
           expectedExceptions = FindException.class )
-    public void testPlatformMisMatch(String s1, String s2) {
+    public void testPlatformMisMatch(String s1, String s2) throws IOException {
         testPlatformMatch(s1, s2);
     }
 
-
     // no parents
 
     @Test(expectedExceptions = { IllegalArgumentException.class })
@@ -1917,21 +1924,23 @@
 
 
     // parents with modules for specific platforms
-
     @Test(dataProvider = "platformmatch")
-    public void testResolveRequiresWithCompatibleParents(String s1, String s2) {
-        Builder builder = newBuilder("m1");
-        addPlatformConstraints(builder, s1);
-        ModuleDescriptor descriptor1 = builder.build();
-
-        builder = newBuilder("m2");
-        addPlatformConstraints(builder, s2);
-        ModuleDescriptor descriptor2 = builder.build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+    public void testResolveRequiresWithCompatibleParents(String s1, String s2)
+        throws IOException
+    {
+        ModuleDescriptor base =  ModuleDescriptor.newModule("java.base").build();
+        Path system = writeModule(base, "*-*");
+
+        ModuleDescriptor descriptor1 = ModuleDescriptor.newModule("m1").build();
+        Path dir1 = writeModule(descriptor1, s1);
+
+        ModuleDescriptor descriptor2 = ModuleDescriptor.newModule("m2").build();
+        Path dir2 = writeModule(descriptor2, s2);
+
+        ModuleFinder finder1 = ModuleFinder.of(system, dir1);
         Configuration cf1 = resolve(finder1, "m1");
 
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
+        ModuleFinder finder2 = ModuleFinder.of(system, dir2);
         Configuration cf2 = resolve(finder2, "m2");
 
         Configuration cf3 = Configuration.resolve(ModuleFinder.of(),
@@ -1941,32 +1950,16 @@
         assertTrue(cf3.parents().size() == 2);
     }
 
+
     @Test(dataProvider = "platformmismatch",
           expectedExceptions = IllegalArgumentException.class )
-    public void testResolveRequiresWithConflictingParents(String s1, String s2) {
-        Builder builder = newBuilder("m1");
-        addPlatformConstraints(builder, s1);
-        ModuleDescriptor descriptor1 = builder.build();
-
-        builder = newBuilder("m2");
-        addPlatformConstraints(builder, s2);
-        ModuleDescriptor descriptor2 = builder.build();
-
-        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
-        Configuration cf1 = resolve(finder1, "m1");
-
-        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
-        Configuration cf2 = resolve(finder2, "m2");
-
-        // should throw IAE
-        Configuration.resolve(ModuleFinder.of(),
-                              List.of(cf1, cf2),
-                              ModuleFinder.of(),
-                              Set.of());
+    public void testResolveRequiresWithConflictingParents(String s1, String s2)
+        throws IOException
+    {
+        testResolveRequiresWithCompatibleParents(s1, s2);
     }
 
 
-
     // null handling
 
     // finder1, finder2, roots
@@ -2121,30 +2114,23 @@
 
 
     /**
-     * Returns {@code true} if the configuration contains module mn1
-     * that reads module mn2.
-     */
-    static boolean reads(Configuration cf, String mn1, String mn2) {
-        Optional<ResolvedModule> om1 = cf.findModule(mn1);
-        if (!om1.isPresent())
-            return false;
-
-        return om1.get().reads().stream()
-                .map(ResolvedModule::name)
-                .anyMatch(mn2::equals);
-    }
-
-    /**
      * Decodes the platform string and calls the builder osName/osArch/osVersion
      * methods to set the platform constraints.
      */
-    static void addPlatformConstraints(Builder builder, String platformString) {
+    static Path writeModule(ModuleDescriptor descriptor, String platformString)
+        throws IOException
+    {
         String[] s = platformString.split("-");
-        if (!s[0].equals("*"))
-            builder.osName(s[0]);
-        if (!s[1].equals("*"))
-            builder.osArch(s[1]);
-        if (!s[2].equals("*"))
-            builder.osVersion(s[2]);
+        String osName = !s[0].equals("*") ? s[0] : null;
+        String osArch = !s[1].equals("*") ? s[1] : null;
+        ModuleTarget target = new ModuleTarget(osName, osArch);
+
+        String name = descriptor.name();
+        Path dir = Files.createTempDirectory(name);
+        Path mi = dir.resolve("module-info.class");
+        try (OutputStream out = Files.newOutputStream(mi)) {
+            ModuleInfoWriter.write(descriptor, target, out);
+        }
+        return dir;
     }
 }
--- a/jdk/test/java/lang/module/ModuleDescriptorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/module/ModuleDescriptorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -50,11 +50,13 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
 import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
 
+import jdk.internal.misc.JavaLangModuleAccess;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.module.ModuleInfoWriter;
 import org.testng.annotations.DataProvider;
@@ -988,6 +990,107 @@
     }
 
 
+    @DataProvider(name = "unparseableVersions")
+    public Object[][] unparseableVersions() {
+        return new Object[][]{
+
+                { null,  "A1" },    // no version < unparseable
+                { "A1",  "A2" },    // unparseable < unparseable
+                { "A1",  "1.0" },   // unparseable < parseable
+
+        };
+    }
+
+    /**
+     * Basic test for unparseable module versions
+     */
+    @Test(dataProvider = "unparseableVersions")
+    public void testUnparseableModuleVersion(String vs1, String vs2) {
+        ModuleDescriptor descriptor1 = newModule("m", vs1);
+        ModuleDescriptor descriptor2 = newModule("m", vs2);
+
+        if (vs1 != null && !isParsableVersion(vs1)) {
+            assertFalse(descriptor1.version().isPresent());
+            assertTrue(descriptor1.rawVersion().isPresent());
+            assertEquals(descriptor1.rawVersion().get(), vs1);
+        }
+
+        if (vs2 != null && !isParsableVersion(vs2)) {
+            assertFalse(descriptor2.version().isPresent());
+            assertTrue(descriptor2.rawVersion().isPresent());
+            assertEquals(descriptor2.rawVersion().get(), vs2);
+        }
+
+        assertFalse(descriptor1.equals(descriptor2));
+        assertFalse(descriptor2.equals(descriptor1));
+        assertTrue(descriptor1.compareTo(descriptor2) == -1);
+        assertTrue(descriptor2.compareTo(descriptor1) == 1);
+    }
+
+    /**
+     * Basic test for requiring a module with an unparseable version recorded
+     * at compile version.
+     */
+    @Test(dataProvider = "unparseableVersions")
+    public void testUnparseableCompiledVersion(String vs1, String vs2) {
+        Requires r1 = newRequires("m", vs1);
+        Requires r2 = newRequires("m", vs2);
+
+        if (vs1 != null && !isParsableVersion(vs1)) {
+            assertFalse(r1.compiledVersion().isPresent());
+            assertTrue(r1.rawCompiledVersion().isPresent());
+            assertEquals(r1.rawCompiledVersion().get(), vs1);
+        }
+
+        if (vs2 != null && !isParsableVersion(vs2)) {
+            assertFalse(r2.compiledVersion().isPresent());
+            assertTrue(r2.rawCompiledVersion().isPresent());
+            assertEquals(r2.rawCompiledVersion().get(), vs2);
+        }
+
+        assertFalse(r1.equals(r2));
+        assertFalse(r2.equals(r1));
+        assertTrue(r1.compareTo(r2) == -1);
+        assertTrue(r2.compareTo(r1) == 1);
+    }
+
+    private ModuleDescriptor newModule(String name, String vs) {
+        JavaLangModuleAccess JLMA = SharedSecrets.getJavaLangModuleAccess();
+        Builder builder = JLMA.newModuleBuilder(name, false, Set.of());
+        if (vs != null)
+            builder.version(vs);
+        builder.requires("java.base");
+        ByteBuffer bb = ModuleInfoWriter.toByteBuffer(builder.build());
+        return ModuleDescriptor.read(bb);
+    }
+
+    private Requires newRequires(String name, String vs) {
+        JavaLangModuleAccess JLMA = SharedSecrets.getJavaLangModuleAccess();
+        Builder builder = JLMA.newModuleBuilder("foo", false, Set.of());
+        if (vs == null) {
+            builder.requires(name);
+        } else {
+            JLMA.requires(builder, Set.of(), name, vs);
+        }
+        Set<ModuleDescriptor.Requires> requires = builder.build().requires();
+        Iterator<ModuleDescriptor.Requires> iterator = requires.iterator();
+        ModuleDescriptor.Requires r = iterator.next();
+        if (r.name().equals("java.base")) {
+            r = iterator.next();
+        }
+        return r;
+    }
+
+    private boolean isParsableVersion(String vs) {
+        try {
+            Version.parse(vs);
+            return true;
+        } catch (IllegalArgumentException e) {
+            return false;
+        }
+    }
+
+
     // toNameAndVersion
 
     public void testToNameAndVersion() {
@@ -1170,59 +1273,6 @@
     }
 
 
-    // osName
-
-    public void testOsName() {
-        String osName = ModuleDescriptor.newModule("foo").osName("Linux").build().osName().get();
-        assertEquals(osName, "Linux");
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void testNullOsName() {
-        ModuleDescriptor.newModule("foo").osName(null);
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void testEmptyOsName() {
-        ModuleDescriptor.newModule("foo").osName("");
-    }
-
-
-    // osArch
-
-    public void testOsArch() {
-        String osArch = ModuleDescriptor.newModule("foo").osName("arm").build().osName().get();
-        assertEquals(osArch, "arm");
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void testNullOsArch() {
-        ModuleDescriptor.newModule("foo").osArch(null);
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void testEmptyOsArch() {
-        ModuleDescriptor.newModule("foo").osArch("");
-    }
-
-
-    // osVersion
-
-    public void testOsVersion() {
-        String osVersion = ModuleDescriptor.newModule("foo").osName("11.2").build().osName().get();
-        assertEquals(osVersion, "11.2");
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void testNullOsVersion() {
-        ModuleDescriptor.newModule("foo").osVersion(null);
-    }
-
-    @Test(expectedExceptions = IllegalArgumentException.class)
-    public void testEmptyOsVersion() {
-        ModuleDescriptor.newModule("foo").osVersion("");
-    }
-
     // reads
 
     private static InputStream EMPTY_INPUT_STREAM = new InputStream() {
@@ -1239,7 +1289,9 @@
         }
     };
 
-    // basic test reading module-info.class
+    /**
+     * Basic test reading module-info.class
+     */
     public void testRead() throws Exception {
         Module base = Object.class.getModule();
 
@@ -1256,6 +1308,7 @@
             assertEquals(descriptor.name(), "java.base");
         }
     }
+
     /**
      * Test ModuleDescriptor with a packager finder
      */
--- a/jdk/test/java/lang/module/ModuleFinderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/module/ModuleFinderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -373,7 +373,7 @@
 
 
     /**
-     * Test ModuleModule with a JAR file containing a .class file in the top
+     * Test ModuleFinder with a JAR file containing a .class file in the top
      * level directory.
      */
     public void testOfOneJarFileWithTopLevelClass() throws Exception {
@@ -386,6 +386,7 @@
             assertTrue(false);
         } catch (FindException e) {
             assertTrue(e.getCause() instanceof InvalidModuleDescriptorException);
+            assertTrue(e.getCause().getMessage().contains("Mojo.class"));
         }
 
         finder = ModuleFinder.of(jar);
@@ -394,11 +395,12 @@
             assertTrue(false);
         } catch (FindException e) {
             assertTrue(e.getCause() instanceof InvalidModuleDescriptorException);
+            assertTrue(e.getCause().getMessage().contains("Mojo.class"));
         }
     }
 
     /**
-     * Test ModuleModule with a JAR file containing a .class file in the top
+     * Test ModuleFinder with a JAR file containing a .class file in the top
      * level directory.
      */
     public void testOfOneExplodedModuleWithTopLevelClass() throws Exception {
@@ -411,6 +413,7 @@
             assertTrue(false);
         } catch (FindException e) {
             assertTrue(e.getCause() instanceof InvalidModuleDescriptorException);
+            assertTrue(e.getCause().getMessage().contains("Mojo.class"));
         }
 
         finder = ModuleFinder.of(m_dir);
@@ -419,6 +422,7 @@
             assertTrue(false);
         } catch (FindException e) {
             assertTrue(e.getCause() instanceof InvalidModuleDescriptorException);
+            assertTrue(e.getCause().getMessage().contains("Mojo.class"));
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/module/ModuleFinderWithSecurityManager.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,70 @@
+/*
+ * 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
+ * @run main/othervm ModuleFinderWithSecurityManager allow
+ * @run main/othervm ModuleFinderWithSecurityManager deny
+ * @summary Basic test for ModuleFinder.ofSystem() with security manager
+ */
+
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Set;
+
+public class ModuleFinderWithSecurityManager {
+    public static void main(String[] args) throws Exception {
+        boolean allow = args[0].equals("allow");
+
+        // set security policy to allow access
+        if (allow) {
+            String testSrc = System.getProperty("test.src");
+            if (testSrc == null)
+                testSrc = ".";
+            Path policyFile = Paths.get(testSrc, "java.policy");
+            System.setProperty("java.security.policy", policyFile.toString());
+        }
+
+        System.setSecurityManager(new SecurityManager());
+
+        ModuleFinder finder = null;
+        try {
+            finder = ModuleFinder.ofSystem();
+            if (!allow) throw new RuntimeException("SecurityException expected");
+        } catch (SecurityException e) {
+            if (allow) throw new RuntimeException("SecurityException not expected");
+        }
+
+        // no additional permissions should be required to locate modules
+        if (finder != null) {
+            ModuleReference base = finder.find("java.base").orElse(null);
+            if (base == null)
+                throw new RuntimeException("java.base not found");
+            Set<ModuleReference> allModules = finder.findAll();
+            if (!allModules.contains(base))
+                throw new RuntimeException("java.base not in all modules");
+        }
+    }
+}
--- a/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -79,17 +79,21 @@
         "java/lang/Object.class"
     };
 
+    // (directory) resources that may be in the base module
+    private static final String[] MAYBE_BASE_RESOURCES = {
+        "java",
+        "java/",
+        "java/lang",
+        "java/lang/",
+    };
+
     // resource names that should not be found in the base module
-    private static final String[] BAD_BASE_RESOURCES = {
+    private static final String[] NOT_BASE_RESOURCES = {
         "NotFound",
-        "java",
         "/java",
         "//java",
-        "java/",
-        "java/lang",
         "/java/lang",
         "//java/lang",
-        "java/lang/",
         "java//lang",
         "/java/lang/Object.class",
         "//java/lang/Object.class",
@@ -109,13 +113,17 @@
         "p/Main.class"
     };
 
+    // (directory) resources that may be in the test module
+    private static final String[] MAYBE_TEST_RESOURCES = {
+        "p",
+        "p/"
+    };
+
     // resource names that should not be found in the test module
-    private static final String[] BAD_TEST_RESOURCES = {
+    private static final String[] NOT_TEST_RESOURCES = {
         "NotFound",
-        "p",
         "/p",
         "//p",
-        "p/",
         "/p/Main.class",
         "//p/Main.class",
         "p/Main.class/",
@@ -160,11 +168,19 @@
                 testOpen(reader, name, expectedBytes);
                 testRead(reader, name, expectedBytes);
                 testList(reader, name);
-
             }
 
-            // test "not found"
-            for (String name : BAD_BASE_RESOURCES) {
+            // test resources that may be in the base module
+            for (String name : MAYBE_BASE_RESOURCES) {
+                Optional<URI> ouri = reader.find(name);
+                ouri.ifPresent(uri -> {
+                    if (name.endsWith("/"))
+                        assertTrue(uri.toString().endsWith("/"));
+                });
+            }
+
+            // test "not found" in java.base module
+            for (String name : NOT_BASE_RESOURCES) {
                 assertFalse(reader.find(name).isPresent());
                 assertFalse(reader.open(name).isPresent());
                 assertFalse(reader.read(name).isPresent());
@@ -261,7 +277,7 @@
 
         try (reader) {
 
-            // test each of the known resources in the module
+            // test resources in test module
             for (String name : TEST_RESOURCES) {
                 byte[] expectedBytes
                     = Files.readAllBytes(MODS_DIR
@@ -274,8 +290,18 @@
                 testList(reader, name);
             }
 
-            // test "not found"
-            for (String name : BAD_TEST_RESOURCES) {
+            // test resources that may be in the test module
+            for (String name : MAYBE_TEST_RESOURCES) {
+                System.out.println(name);
+                Optional<URI> ouri = reader.find(name);
+                ouri.ifPresent(uri -> {
+                    if (name.endsWith("/"))
+                        assertTrue(uri.toString().endsWith("/"));
+                });
+            }
+
+            // test "not found" in test module
+            for (String name : NOT_TEST_RESOURCES) {
                 assertFalse(reader.find(name).isPresent());
                 assertFalse(reader.open(name).isPresent());
                 assertFalse(reader.read(name).isPresent());
@@ -394,9 +420,6 @@
         for (String e : names) {
             assertTrue(reader.find(e).isPresent());
         }
-
-        // should not contain directories
-        names.forEach(e -> assertFalse(e.endsWith("/")));
     }
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/module/java.policy	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,4 @@
+grant {
+    // ModuleFinder.ofSystem() needs this
+    permission java.lang.RuntimePermission "accessSystemModules";
+};
--- a/jdk/test/java/lang/reflect/Layer/BasicLayerTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/reflect/Layer/BasicLayerTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -45,6 +45,8 @@
 import java.util.stream.Collectors;
 
 import jdk.internal.misc.SharedSecrets;
+
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
@@ -670,6 +672,258 @@
 
 
     /**
+     * Test layers with a qualified export. The module exporting the package
+     * does not read the target module.
+     *
+     * m1 { exports p to m2 }
+     * m2 { }
+     */
+    public void testQualifiedExports1() {
+        ModuleDescriptor descriptor1 = newBuilder("m1").
+                exports("p", Set.of("m2"))
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration cf = resolve(finder1, "m1", "m2");
+
+        ClassLoader cl = new ClassLoader() { };
+        Layer layer = Layer.empty().defineModules(cf, mn -> cl);
+        assertTrue(layer.modules().size() == 2);
+
+        Module m1 = layer.findModule("m1").get();
+        Module m2 = layer.findModule("m2").get();
+
+        // check m1 exports p to m2
+        assertFalse(m1.isExported("p"));
+        assertTrue(m1.isExported("p", m2));
+        assertFalse(m1.isOpen("p", m2));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * reads the target module.
+     *
+     * m1 { exports p to m2; }
+     * m2 { requires m1; }
+     */
+    public void testQualifiedExports2() {
+        ModuleDescriptor descriptor1 = newBuilder("m1")
+                .exports("p", Set.of("m2"))
+                .build();
+
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires("m1")
+                .build();
+
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+
+        Configuration cf = resolve(finder1, "m2");
+        ClassLoader cl = new ClassLoader() { };
+        Layer layer = Layer.empty().defineModules(cf, mn -> cl);
+        assertTrue(layer.modules().size() == 2);
+
+        Module m1 = layer.findModule("m1").get();
+        Module m2 = layer.findModule("m2").get();
+
+        // check m1 exports p to m2
+        assertFalse(m1.isExported("p"));
+        assertTrue(m1.isExported("p", m2));
+        assertFalse(m1.isOpen("p", m2));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * does not read the target module in the parent layer.
+     *
+     * - Configuration/layer1: m1 { }
+     * - Configuration/layer2: m2 { exports p to m1; }
+     */
+    public void testQualifiedExports3() {
+        // create layer1 with m1
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        Configuration cf1 = resolve(finder1, "m1");
+        ClassLoader cl1 = new ClassLoader() { };
+        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+        assertTrue(layer1.modules().size() == 1);
+
+        // create layer2 with m2
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .exports("p", Set.of("m1"))
+                .build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
+        Configuration cf2 = resolve(cf1, finder2, "m2");
+        ClassLoader cl2 = new ClassLoader() { };
+        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+        assertTrue(layer2.modules().size() == 1);
+
+        Module m1 = layer1.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+
+        // check m2 exports p to layer1/m1
+        assertFalse(m2.isExported("p"));
+        assertTrue(m2.isExported("p", m1));
+        assertFalse(m2.isOpen("p", m1));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * reads the target module in the parent layer.
+     *
+     * - Configuration/layer1: m1 { }
+     * - Configuration/layer2: m2 { requires m1; exports p to m1; }
+     */
+    public void testQualifiedExports4() {
+        // create layer1 with m1
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        Configuration cf1 = resolve(finder1, "m1");
+        ClassLoader cl1 = new ClassLoader() { };
+        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+        assertTrue(layer1.modules().size() == 1);
+
+        // create layer2 with m2
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires("m1")
+                .exports("p", Set.of("m1"))
+                .build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
+        Configuration cf2 = resolve(cf1, finder2, "m2");
+        ClassLoader cl2 = new ClassLoader() { };
+        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+        assertTrue(layer2.modules().size() == 1);
+
+        Module m1 = layer1.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+
+        // check m2 exports p to layer1/m1
+        assertFalse(m2.isExported("p"));
+        assertTrue(m2.isExported("p", m1));
+        assertFalse(m2.isOpen("p", m1));
+    }
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * does not read the target module.
+     *
+     * - Configuration/layer1: m1
+     * - Configuration/layer2: m1, m2 { exports p to m1; }
+     */
+    public void testQualifiedExports5() {
+        // create layer1 with m1
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        Configuration cf1 = resolve(finder1, "m1");
+        ClassLoader cl1 = new ClassLoader() { };
+        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+        assertTrue(layer1.modules().size() == 1);
+
+        // create layer2 with m1 and m2
+        ModuleDescriptor descriptor2 = newBuilder("m2").exports("p", Set.of("m1")).build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor2);
+        Configuration cf2 = resolve(cf1, finder2, "m1", "m2");
+        ClassLoader cl2 = new ClassLoader() { };
+        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+        assertTrue(layer2.modules().size() == 2);
+
+        Module m1_v1 = layer1.findModule("m1").get();
+        Module m1_v2 = layer2.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+
+        // check m2 exports p to layer2/m2
+        assertFalse(m2.isExported("p"));
+        assertTrue(m2.isExported("p", m1_v2));
+        assertFalse(m2.isExported("p", m1_v1));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The module exporting the package
+     * reads the target module in the parent layer (due to requires transitive).
+     *
+     * - Configuration/layer1: m1, m2 { requires transitive m1; }
+     * - Configuration/layer2: m1, m3 { requires m2; exports p to m1; }
+     */
+    public void testQualifiedExports6() {
+        // create layer1 with m1 and m2
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .requires(Set.of(Requires.Modifier.TRANSITIVE), "m1")
+                .build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
+        Configuration cf1 = resolve(finder1, "m2");
+        ClassLoader loader1 = new ClassLoader() { };
+        Layer layer1 = Layer.empty().defineModules(cf1, mn -> loader1);
+        assertTrue(layer1.modules().size() == 2);
+
+        // create layer2 with m1 and m3
+        ModuleDescriptor descriptor3 = newBuilder("m3")
+                .requires("m2")
+                .exports("p", Set.of("m1"))
+                .build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor1, descriptor3);
+        Configuration cf2 = resolve(cf1, finder2, "m1", "m3");
+        ClassLoader loader2 = new ClassLoader() { };
+        Layer layer2 = layer1.defineModules(cf2, mn -> loader2);
+        assertTrue(layer2.modules().size() == 2);
+
+        Module m1_v1 = layer1.findModule("m1").get();
+        Module m2 = layer1.findModule("m2").get();
+
+        Module m1_v2 = layer2.findModule("m1").get();
+        Module m3 = layer2.findModule("m3").get();
+
+        assertTrue(m3.canRead(m1_v1));
+        assertFalse(m3.canRead(m1_v2));
+
+        assertFalse(m3.isExported("p"));
+        assertTrue(m3.isExported("p", m1_v1));
+        assertFalse(m3.isExported("p", m1_v2));
+        assertFalse(m3.isExported("p", m2));
+    }
+
+
+    /**
+     * Test layers with a qualified export. The target module is not in any layer.
+     *
+     * - Configuration/layer1: m1 { }
+     * - Configuration/layer2: m2 { exports p to m3; }
+     */
+    public void testQualifiedExports7() {
+        // create layer1 with m1
+        ModuleDescriptor descriptor1 = newBuilder("m1").build();
+        ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1);
+        Configuration cf1 = resolve(finder1, "m1");
+        ClassLoader cl1 = new ClassLoader() { };
+        Layer layer1 = Layer.empty().defineModules(cf1, mn -> cl1);
+        assertTrue(layer1.modules().size() == 1);
+
+        // create layer2 with m2
+        ModuleDescriptor descriptor2 = newBuilder("m2")
+                .exports("p", Set.of("m3"))
+                .build();
+        ModuleFinder finder2 = ModuleUtils.finderOf(descriptor2);
+        Configuration cf2 = resolve(cf1, finder2, "m2");
+        ClassLoader cl2 = new ClassLoader() { };
+        Layer layer2 = layer1.defineModules(cf2, mn -> cl2);
+        assertTrue(layer2.modules().size() == 1);
+
+        Module m1 = layer1.findModule("m1").get();
+        Module m2 = layer2.findModule("m2").get();
+
+        // check m2 does not export p to anyone
+        assertFalse(m2.isExported("p"));
+        assertFalse(m2.isExported("p", m1));
+    }
+
+    /**
      * Attempt to use Layer defineModules to create a layer with a module
      * defined to a class loader that already has a module of the same name
      * defined to the class loader.
@@ -796,29 +1050,31 @@
     }
 
 
+    @DataProvider(name = "javaPackages")
+    public Object[][] javaPackages() {
+        return new Object[][] { { "m1", "java" }, { "m2", "java.x" } };
+    }
+
     /**
-     * Attempt to create a Layer with a module containing a "java." package.
+     * Attempt to create a Layer with a module containing a "java" package.
      * This should only be allowed when the module is defined to the platform
      * class loader.
      */
-    @Test(enabled = false)
-    public void testLayerWithJavaPackage() {
-        ModuleDescriptor descriptor = newBuilder("foo")
-                .packages(Set.of("java.foo"))
-                .build();
-
+    @Test(dataProvider = "javaPackages")
+    public void testLayerWithJavaPackage(String mn, String pn) {
+        ModuleDescriptor descriptor = newBuilder(mn).packages(Set.of(pn)).build();
         ModuleFinder finder = ModuleUtils.finderOf(descriptor);
 
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolve(finder, ModuleFinder.of(), Set.of("foo"));
+                .resolve(finder, ModuleFinder.of(), Set.of(mn));
         assertTrue(cf.modules().size() == 1);
 
         ClassLoader pcl = ClassLoader.getPlatformClassLoader();
         ClassLoader scl = ClassLoader.getSystemClassLoader();
 
         try {
-            Layer.boot().defineModules(cf, mn -> new ClassLoader() { });
+            Layer.boot().defineModules(cf, _mn -> new ClassLoader() { });
             assertTrue(false);
         } catch (LayerInstantiationException e) { }
 
@@ -833,13 +1089,13 @@
         } catch (LayerInstantiationException e) { }
 
         // create layer with module defined to platform class loader
-        Layer layer = Layer.boot().defineModules(cf, mn -> pcl);
-        Optional<Module> om = layer.findModule("foo");
+        Layer layer = Layer.boot().defineModules(cf, _mn -> pcl);
+        Optional<Module> om = layer.findModule(mn);
         assertTrue(om.isPresent());
         Module foo = om.get();
         assertTrue(foo.getClassLoader() == pcl);
         assertTrue(foo.getPackages().length == 1);
-        assertTrue(foo.getPackages()[0].equals("java.foo"));
+        assertTrue(foo.getPackages()[0].equals(pn));
     }
 
 
--- a/jdk/test/java/lang/reflect/Module/allow.policy	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/reflect/Module/allow.policy	Wed Jul 05 23:09:40 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,5 +23,6 @@
 
 grant {
     permission java.lang.RuntimePermission "getClassLoader";
-    permission java.io.FilePermission "${java.home}/-", "read";
+    permission java.lang.RuntimePermission "accessSystemModules";
+    permission java.io.FilePermission "${java.home}/modules/-", "read";    // exploded build
 };
--- a/jdk/test/java/lang/reflect/PublicMethods/PublicMethodsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/lang/reflect/PublicMethods/PublicMethodsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -57,8 +57,7 @@
 /*
  * @test
  * @bug 8062389
- * @modules java.compiler
- *          jdk.compiler
+ * @modules jdk.compiler
  *          jdk.zipfs
  * @summary Nearly exhaustive test of Class.getMethod() and Class.getMethods()
  * @run main PublicMethodsTest
--- a/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java	Wed Jul 05 23:09:40 2017 +0200
@@ -53,8 +53,7 @@
 /*
  * @test
  * @bug 8064924
- * @modules java.compiler
- *          jdk.compiler
+ * @modules jdk.compiler
  * @summary Basic test for URLStreamHandlerProvider
  * @library /lib/testlibrary
  * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
--- a/jdk/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, 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
@@ -57,22 +57,11 @@
         return ip6Interfaces.get(nif);
     }
 
-    // IPv6 not supported for Windows XP/Server 2003
-    static boolean isIPv6Supported() {
-        if (System.getProperty("os.name").startsWith("Windows")) {
-            String ver = System.getProperty("os.version");
-            int major = Integer.parseInt(ver.split("\\.")[0]);
-            return (major >= 6);
-        }
-        return true;
-    }
-
     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>>();
-        boolean isIPv6Supported = isIPv6Supported();
 
         // find the interfaces that support IPv4 and IPv6
         List<NetworkInterface> nifs = Collections
@@ -92,7 +81,7 @@
                         }
                         list.add(addr);
                         ip4Interfaces.put(nif, list);
-                    } else if (isIPv6Supported && (addr instanceof Inet6Address)) {
+                    } else if (addr instanceof Inet6Address) {
                         List<InetAddress> list = ip6Interfaces.get(nif);
                         if (list == null) {
                             list = new LinkedList<InetAddress>();
--- a/jdk/test/java/nio/channels/FileChannel/LoopingTruncate.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/nio/channels/FileChannel/LoopingTruncate.java	Wed Jul 05 23:09:40 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
@@ -28,7 +28,7 @@
  * @summary (fc) Infinite loop FileChannel.truncate
  * @library /lib/testlibrary
  * @build jdk.testlibrary.Utils
- * @run main/othervm LoopingTruncate
+ * @run main/othervm/timeout=300 LoopingTruncate
  */
 
 import java.nio.ByteBuffer;
@@ -37,6 +37,7 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import static java.nio.file.StandardOpenOption.*;
+import java.util.concurrent.TimeUnit;
 import static jdk.testlibrary.Utils.adjustTimeout;
 
 public class LoopingTruncate {
@@ -51,11 +52,21 @@
         Path path = Files.createTempFile("LoopingTruncate.tmp", null);
         try (FileChannel fc = FileChannel.open(path, CREATE, WRITE)) {
             fc.position(FATEFUL_SIZE + 1L);
+            System.out.println("  Writing large file...");
+            long t0 = System.nanoTime();
             fc.write(ByteBuffer.wrap(new byte[] {0}));
+            long t1 = System.nanoTime();
+            System.out.printf("  Wrote large file in %d ns (%d ms) %n",
+                t1 - t0, TimeUnit.NANOSECONDS.toMillis(t1 - t0));
 
             Thread th = new Thread(() -> {
                 try {
+                    System.out.println("  Truncating large file...");
+                    long t2 = System.nanoTime();
                     fc.truncate(FATEFUL_SIZE);
+                    long t3 = System.nanoTime();
+                    System.out.printf("  Truncated large file in %d ns (%d ms) %n",
+                        t3 - t2, TimeUnit.NANOSECONDS.toMillis(t3 - t2));
                 } catch (ClosedByInterruptException ignore) {
                 } catch (Exception e) {
                     throw new RuntimeException(e);
--- a/jdk/test/java/nio/channels/FileChannel/Transfer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/nio/channels/FileChannel/Transfer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,30 +22,24 @@
  */
 
 /* @test
- * @bug 4434723 4482726 4559072 4638365 4795550 5081340 5103988 6253145
- *   6984545
+ * @bug 4434723 4482726 4559072 4795550 5081340 5103988 6984545
  * @key intermittent
  * @summary Test FileChannel.transferFrom and transferTo (use -Dseed=X to set PRNG seed)
  * @library ..
  * @library /lib/testlibrary/
  * @build jdk.testlibrary.*
- * @run testng Transfer
+ * @run testng/timeout=300 Transfer
  * @key randomness
  */
 
 import java.io.BufferedReader;
-import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStreamReader;
 import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
 import java.io.RandomAccessFile;
 import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
@@ -55,8 +49,6 @@
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
 import java.nio.channels.spi.SelectorProvider;
-import java.nio.file.StandardOpenOption;
-import java.nio.file.FileAlreadyExistsException;
 import java.util.Random;
 import java.util.concurrent.TimeUnit;
 
@@ -67,8 +59,6 @@
 public class Transfer {
 
     private static Random generator = RandomFactory.getRandom();
-    private static PrintStream err = System.err;
-    private static PrintStream out = System.out;
 
     @Test
     public void testFileChannel() throws Exception {
@@ -242,105 +232,7 @@
         dest.delete();
     }
 
-    // Test transferTo with large file
-    @Test
-    public void xferTest04() throws Exception { // for bug 4638365
-        // Windows and Linux can't handle the really large file sizes for a
-        // truncate or a positional write required by the test for 4563125
-        String osName = System.getProperty("os.name");
-        if (!(osName.startsWith("SunOS") || osName.contains("OS X")))
-            return;
-        File source = File.createTempFile("blah", null);
-        source.deleteOnExit();
-        long testSize = ((long)Integer.MAX_VALUE) * 2;
-        initTestFile(source, 10);
-        RandomAccessFile raf = new RandomAccessFile(source, "rw");
-        FileChannel fc = raf.getChannel();
-        fc.write(ByteBuffer.wrap("Use the source!".getBytes()), testSize - 40);
-        fc.close();
-        raf.close();
-
-        File sink = File.createTempFile("sink", null);
-        sink.deleteOnExit();
-
-        FileInputStream fis = new FileInputStream(source);
-        FileChannel sourceChannel = fis.getChannel();
-
-        raf = new RandomAccessFile(sink, "rw");
-        FileChannel sinkChannel = raf.getChannel();
-
-        long bytesWritten = sourceChannel.transferTo(testSize -40, 10,
-                                                     sinkChannel);
-        if (bytesWritten != 10) {
-            throw new RuntimeException("Transfer test 4 failed " +
-                                       bytesWritten);
-        }
-        sourceChannel.close();
-        sinkChannel.close();
-
-        source.delete();
-        sink.delete();
-    }
-
-    // Test transferFrom with large file
-    @Test
-    public void xferTest05() throws Exception { // for bug 4638365
-        // Create a source file & large sink file for the test
-        File source = File.createTempFile("blech", null);
-        source.deleteOnExit();
-        initTestFile(source, 100);
-
-        // Create the sink file as a sparse file if possible
-        File sink = null;
-        FileChannel fc = null;
-        while (fc == null) {
-            sink = File.createTempFile("sink", null);
-            // re-create as a sparse file
-            sink.delete();
-            try {
-                fc = FileChannel.open(sink.toPath(),
-                                      StandardOpenOption.CREATE_NEW,
-                                      StandardOpenOption.WRITE,
-                                      StandardOpenOption.SPARSE);
-            } catch (FileAlreadyExistsException ignore) {
-                // someone else got it
-            }
-        }
-        sink.deleteOnExit();
-
-        long testSize = ((long)Integer.MAX_VALUE) * 2;
-        try {
-            fc.write(ByteBuffer.wrap("Use the source!".getBytes()),
-                     testSize - 40);
-        } catch (IOException e) {
-            // Can't set up the test, abort it
-            err.println("xferTest05 was aborted.");
-            return;
-        } finally {
-            fc.close();
-        }
-
-        // Get new channels for the source and sink and attempt transfer
-        FileChannel sourceChannel = new FileInputStream(source).getChannel();
-        try {
-            FileChannel sinkChannel = new RandomAccessFile(sink, "rw").getChannel();
-            try {
-                long bytesWritten = sinkChannel.transferFrom(sourceChannel,
-                                                             testSize - 40, 10);
-                if (bytesWritten != 10) {
-                    throw new RuntimeException("Transfer test 5 failed " +
-                                               bytesWritten);
-                }
-            } finally {
-                sinkChannel.close();
-            }
-        } finally {
-            sourceChannel.close();
-        }
-
-        source.delete();
-        sink.delete();
-    }
+    // xferTest04() and xferTest05() moved to Transfer4GBFile.java
 
     static void checkFileData(File file, String expected) throws Exception {
         FileInputStream fis = new FileInputStream(file);
@@ -425,118 +317,7 @@
         source.delete();
     }
 
-
-    // Test transferTo with file positions larger than 2 and 4GB
-    @Test
-    public void xferTest08() throws Exception { // for bug 6253145
-        // Creating a sparse 6GB file on Windows takes too long
-        String osName = System.getProperty("os.name");
-        if (osName.startsWith("Windows"))
-            return;
-
-        final long G = 1024L * 1024L * 1024L;
-
-        // Create 6GB file
-
-        File file = File.createTempFile("source", null);
-        file.deleteOnExit();
-
-        RandomAccessFile raf = new RandomAccessFile(file, "rw");
-        FileChannel fc = raf.getChannel();
-
-        out.println("  Creating large file...");
-        long t0 = System.nanoTime();
-        try {
-            fc.write(ByteBuffer.wrap("0123456789012345".getBytes("UTF-8")), 6*G);
-            long t1 = System.nanoTime();
-            out.printf("  Created large file in %d ns (%d ms) %n",
-            t1 - t0, TimeUnit.NANOSECONDS.toMillis(t1 - t0));
-        } catch (IOException x) {
-            err.println("  Unable to create test file:" + x);
-            fc.close();
-            return;
-        }
-
-        // Setup looback connection and echo server
-
-        ServerSocketChannel ssc = ServerSocketChannel.open();
-        ssc.socket().bind(new InetSocketAddress(0));
-
-        InetAddress lh = InetAddress.getLocalHost();
-        InetSocketAddress isa = new InetSocketAddress(lh, ssc.socket().getLocalPort());
-        SocketChannel source = SocketChannel.open(isa);
-        SocketChannel sink = ssc.accept();
-
-        Thread thr = new Thread(new EchoServer(sink));
-        thr.start();
-
-        // Test data is array of positions and counts
-
-        long testdata[][] = {
-            { 2*G-1,    1 },
-            { 2*G-1,    10 },       // across 2GB boundary
-            { 2*G,      1 },
-            { 2*G,      10 },
-            { 2*G+1,    1 },
-            { 4*G-1,    1 },
-            { 4*G-1,    10 },       // across 4GB boundary
-            { 4*G,      1 },
-            { 4*G,      10 },
-            { 4*G+1,    1 },
-            { 5*G-1,    1 },
-            { 5*G-1,    10 },
-            { 5*G,      1 },
-            { 5*G,      10 },
-            { 5*G+1,    1 },
-            { 6*G,      1 },
-        };
-
-        ByteBuffer sendbuf = ByteBuffer.allocateDirect(100);
-        ByteBuffer readbuf = ByteBuffer.allocateDirect(100);
-
-        try {
-            byte value = 0;
-            for (int i=0; i<testdata.length; i++) {
-                long position = testdata[(int)i][0];
-                long count = testdata[(int)i][1];
-
-                // generate bytes
-                for (long j=0; j<count; j++) {
-                    sendbuf.put(++value);
-                }
-                sendbuf.flip();
-
-                // write to file and transfer to echo server
-                fc.write(sendbuf, position);
-                t0 = System.nanoTime();
-                fc.transferTo(position, count, source);
-                out.printf("  transferTo(%d, %2d, source): %d ns%n",
-                    position, count, System.nanoTime() - t0);
-
-                // read from echo server
-                long nread = 0;
-                while (nread < count) {
-                    int n = source.read(readbuf);
-                    if (n < 0)
-                        throw new RuntimeException("Premature EOF!");
-                    nread += n;
-                }
-
-                // check reply from echo server
-                readbuf.flip();
-                sendbuf.flip();
-                if (!readbuf.equals(sendbuf))
-                    throw new RuntimeException("Echoed bytes do not match!");
-                readbuf.clear();
-                sendbuf.clear();
-            }
-        } finally {
-            source.close();
-            ssc.close();
-            fc.close();
-            file.delete();
-        }
-    }
+    // xferTest08() moved to TransferTo6GBFile.java
 
     // Test that transferFrom with FileChannel source that is not readable
     // throws NonReadableChannelException
@@ -559,56 +340,4 @@
             fc2.close();
         }
     }
-
-    /**
-     * Creates file blah of specified size in bytes.
-     */
-    private static void initTestFile(File blah, long size) throws Exception {
-        if (blah.exists())
-            blah.delete();
-        FileOutputStream fos = new FileOutputStream(blah);
-        BufferedWriter awriter
-            = new BufferedWriter(new OutputStreamWriter(fos, "8859_1"));
-
-        for(int i=0; i<size; i++) {
-            awriter.write("e");
-        }
-        awriter.flush();
-        awriter.close();
-    }
-
-    /**
-     * Simple in-process server to echo bytes read by a given socket channel
-     */
-    static class EchoServer implements Runnable {
-        private SocketChannel sc;
-
-        public EchoServer(SocketChannel sc) {
-            this.sc = sc;
-        }
-
-        public void run() {
-            ByteBuffer bb = ByteBuffer.allocateDirect(1024);
-            try {
-                for (;;) {
-                    int n = sc.read(bb);
-                    if (n < 0)
-                        break;
-
-                    bb.flip();
-                    while (bb.remaining() > 0) {
-                        sc.write(bb);
-                    }
-                    bb.clear();
-                }
-            } catch (IOException x) {
-                x.printStackTrace();
-            } finally {
-                try {
-                    sc.close();
-                } catch (IOException ignore) { }
-            }
-        }
-    }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/FileChannel/Transfer4GBFile.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,174 @@
+/*
+ * 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 4638365
+ * @key intermittent
+ * @summary Test FileChannel.transferFrom and transferTo for 4GB files
+ * @run testng/timeout=300 Transfer4GBFile
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.file.StandardOpenOption;
+import java.nio.file.FileAlreadyExistsException;
+import java.util.concurrent.TimeUnit;
+
+import org.testng.annotations.Test;
+
+public class Transfer4GBFile {
+
+    private static PrintStream err = System.err;
+    private static PrintStream out = System.out;
+
+    // Test transferTo with large file
+    @Test
+    public void xferTest04() throws Exception { // for bug 4638365
+        File source = File.createTempFile("blah", null);
+        source.deleteOnExit();
+        long testSize = ((long)Integer.MAX_VALUE) * 2;
+        initTestFile(source, 10);
+        RandomAccessFile raf = new RandomAccessFile(source, "rw");
+        FileChannel fc = raf.getChannel();
+        out.println("  Writing large file...");
+        long t0 = System.nanoTime();
+        fc.write(ByteBuffer.wrap("Use the source!".getBytes()), testSize - 40);
+        long t1 = System.nanoTime();
+        out.printf("  Wrote large file in %d ns (%d ms) %n",
+            t1 - t0, TimeUnit.NANOSECONDS.toMillis(t1 - t0));
+
+        fc.close();
+        raf.close();
+
+        File sink = File.createTempFile("sink", null);
+        sink.deleteOnExit();
+
+        FileInputStream fis = new FileInputStream(source);
+        FileChannel sourceChannel = fis.getChannel();
+
+        raf = new RandomAccessFile(sink, "rw");
+        FileChannel sinkChannel = raf.getChannel();
+
+        long bytesWritten = sourceChannel.transferTo(testSize -40, 10,
+                                                     sinkChannel);
+        if (bytesWritten != 10) {
+            throw new RuntimeException("Transfer test 4 failed " +
+                                       bytesWritten);
+        }
+        sourceChannel.close();
+        sinkChannel.close();
+
+        source.delete();
+        sink.delete();
+    }
+
+    // Test transferFrom with large file
+    @Test
+    public void xferTest05() throws Exception { // for bug 4638365
+        // Create a source file & large sink file for the test
+        File source = File.createTempFile("blech", null);
+        source.deleteOnExit();
+        initTestFile(source, 100);
+
+        // Create the sink file as a sparse file if possible
+        File sink = null;
+        FileChannel fc = null;
+        while (fc == null) {
+            sink = File.createTempFile("sink", null);
+            // re-create as a sparse file
+            sink.delete();
+            try {
+                fc = FileChannel.open(sink.toPath(),
+                                      StandardOpenOption.CREATE_NEW,
+                                      StandardOpenOption.WRITE,
+                                      StandardOpenOption.SPARSE);
+            } catch (FileAlreadyExistsException ignore) {
+                // someone else got it
+            }
+        }
+        sink.deleteOnExit();
+
+        long testSize = ((long)Integer.MAX_VALUE) * 2;
+        try {
+            out.println("  Writing large file...");
+            long t0 = System.nanoTime();
+            fc.write(ByteBuffer.wrap("Use the source!".getBytes()),
+                     testSize - 40);
+            long t1 = System.nanoTime();
+            out.printf("  Wrote large file in %d ns (%d ms) %n",
+            t1 - t0, TimeUnit.NANOSECONDS.toMillis(t1 - t0));
+        } catch (IOException e) {
+            // Can't set up the test, abort it
+            err.println("xferTest05 was aborted.");
+            return;
+        } finally {
+            fc.close();
+        }
+
+        // Get new channels for the source and sink and attempt transfer
+        FileChannel sourceChannel = new FileInputStream(source).getChannel();
+        try {
+            FileChannel sinkChannel = new RandomAccessFile(sink, "rw").getChannel();
+            try {
+                long bytesWritten = sinkChannel.transferFrom(sourceChannel,
+                                                             testSize - 40, 10);
+                if (bytesWritten != 10) {
+                    throw new RuntimeException("Transfer test 5 failed " +
+                                               bytesWritten);
+                }
+            } finally {
+                sinkChannel.close();
+            }
+        } finally {
+            sourceChannel.close();
+        }
+
+        source.delete();
+        sink.delete();
+    }
+
+    /**
+     * Creates file blah of specified size in bytes.
+     */
+    private static void initTestFile(File blah, long size) throws Exception {
+        if (blah.exists())
+            blah.delete();
+        FileOutputStream fos = new FileOutputStream(blah);
+        BufferedWriter awriter
+            = new BufferedWriter(new OutputStreamWriter(fos, "8859_1"));
+
+        for(int i=0; i<size; i++) {
+            awriter.write("e");
+        }
+        awriter.flush();
+        awriter.close();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/FileChannel/TransferTo6GBFile.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,190 @@
+/*
+ * 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 6253145
+ * @key intermittent
+ * @summary Test FileChannel.transferTo with file positions up to 8GB
+ * @run testng/timeout=300 TransferTo6GBFile
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.RandomAccessFile;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.util.concurrent.TimeUnit;
+
+import org.testng.annotations.Test;
+
+public class TransferTo6GBFile {
+
+    private static PrintStream err = System.err;
+    private static PrintStream out = System.out;
+
+    // Test transferTo with file positions larger than 2 and 4GB
+    @Test
+    public void xferTest08() throws Exception { // for bug 6253145
+        final long G = 1024L * 1024L * 1024L;
+
+        // Create 6GB file
+
+        File file = File.createTempFile("source", null);
+        file.deleteOnExit();
+
+        RandomAccessFile raf = new RandomAccessFile(file, "rw");
+        FileChannel fc = raf.getChannel();
+
+        out.println("  Writing large file...");
+        long t0 = System.nanoTime();
+        try {
+            fc.write(ByteBuffer.wrap("0123456789012345".getBytes("UTF-8")), 6*G);
+            long t1 = System.nanoTime();
+            out.printf("  Wrote large file in %d ns (%d ms) %n",
+            t1 - t0, TimeUnit.NANOSECONDS.toMillis(t1 - t0));
+        } catch (IOException x) {
+            err.println("  Unable to create test file:" + x);
+            fc.close();
+            return;
+        }
+
+        // Setup looback connection and echo server
+
+        ServerSocketChannel ssc = ServerSocketChannel.open();
+        ssc.socket().bind(new InetSocketAddress(0));
+
+        InetAddress lh = InetAddress.getLocalHost();
+        InetSocketAddress isa = new InetSocketAddress(lh, ssc.socket().getLocalPort());
+        SocketChannel source = SocketChannel.open(isa);
+        SocketChannel sink = ssc.accept();
+
+        Thread thr = new Thread(new EchoServer(sink));
+        thr.start();
+
+        // Test data is array of positions and counts
+
+        long testdata[][] = {
+            { 2*G-1,    1 },
+            { 2*G-1,    10 },       // across 2GB boundary
+            { 2*G,      1 },
+            { 2*G,      10 },
+            { 2*G+1,    1 },
+            { 4*G-1,    1 },
+            { 4*G-1,    10 },       // across 4GB boundary
+            { 4*G,      1 },
+            { 4*G,      10 },
+            { 4*G+1,    1 },
+            { 5*G-1,    1 },
+            { 5*G-1,    10 },
+            { 5*G,      1 },
+            { 5*G,      10 },
+            { 5*G+1,    1 },
+            { 6*G,      1 },
+        };
+
+        ByteBuffer sendbuf = ByteBuffer.allocateDirect(100);
+        ByteBuffer readbuf = ByteBuffer.allocateDirect(100);
+
+        try {
+            byte value = 0;
+            for (int i=0; i<testdata.length; i++) {
+                long position = testdata[(int)i][0];
+                long count = testdata[(int)i][1];
+
+                // generate bytes
+                for (long j=0; j<count; j++) {
+                    sendbuf.put(++value);
+                }
+                sendbuf.flip();
+
+                // write to file and transfer to echo server
+                fc.write(sendbuf, position);
+                t0 = System.nanoTime();
+                fc.transferTo(position, count, source);
+                out.printf("  transferTo(%d, %2d, source): %d ns%n",
+                    position, count, System.nanoTime() - t0);
+
+                // read from echo server
+                long nread = 0;
+                while (nread < count) {
+                    int n = source.read(readbuf);
+                    if (n < 0)
+                        throw new RuntimeException("Premature EOF!");
+                    nread += n;
+                }
+
+                // check reply from echo server
+                readbuf.flip();
+                sendbuf.flip();
+                if (!readbuf.equals(sendbuf))
+                    throw new RuntimeException("Echoed bytes do not match!");
+                readbuf.clear();
+                sendbuf.clear();
+            }
+        } finally {
+            source.close();
+            ssc.close();
+            fc.close();
+            file.delete();
+        }
+    }
+
+    /**
+     * Simple in-process server to echo bytes read by a given socket channel
+     */
+    static class EchoServer implements Runnable {
+        private SocketChannel sc;
+
+        public EchoServer(SocketChannel sc) {
+            this.sc = sc;
+        }
+
+        public void run() {
+            ByteBuffer bb = ByteBuffer.allocateDirect(1024);
+            try {
+                for (;;) {
+                    int n = sc.read(bb);
+                    if (n < 0)
+                        break;
+
+                    bb.flip();
+                    while (bb.remaining() > 0) {
+                        sc.write(bb);
+                    }
+                    bb.clear();
+                }
+            } catch (IOException x) {
+                x.printStackTrace();
+            } finally {
+                try {
+                    sc.close();
+                } catch (IOException ignore) { }
+            }
+        }
+    }
+}
--- a/jdk/test/java/nio/channels/FileChannel/Transfers.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/nio/channels/FileChannel/Transfers.java	Wed Jul 05 23:09:40 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
@@ -26,6 +26,7 @@
  * @summary Comprehensive test for FileChannel.transfer{From,To}
  * @bug 4708120
  * @author Mark Reinhold
+ * @run main/timeout=300 Transfers
  */
 
 import java.io.*;
--- a/jdk/test/java/nio/channels/Selector/OutOfBand.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/nio/channels/Selector/OutOfBand.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 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
@@ -23,6 +23,9 @@
 
 /* @test
  * @bug 6213702
+ * @requires (os.family != "mac") | (os.version == "10.10.5")
+ *    | (os.simpleVersion != "10.8" & os.simpleVersion != "10.9"
+ *        & os.simpleVersion != "10.10")
  * @summary OOB data causes a SocketChannel, with OOBINLINE disabled, to be
  *    selected
  */
--- a/jdk/test/java/nio/channels/Selector/SelectAndClose.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/nio/channels/Selector/SelectAndClose.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2016, 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
@@ -29,19 +29,22 @@
 
 import java.nio.channels.*;
 import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
 
 public class SelectAndClose {
     static Selector selector;
-    static boolean awakened = false;
-    static boolean closed = false;
+    static volatile boolean awakened = false;
+    static volatile boolean closed = false;
 
     public static void main(String[] args) throws Exception {
         selector = Selector.open();
 
         // Create and start a selector in a separate thread.
+        final CountDownLatch selectLatch = new CountDownLatch(1);
         new Thread(new Runnable() {
                 public void run() {
                     try {
+                        selectLatch.countDown();
                         selector.select();
                         awakened = true;
                     } catch (IOException e) {
@@ -51,10 +54,11 @@
             }).start();
 
         // Wait for above thread to get to select() before we call close.
-        Thread.sleep(3000);
+        selectLatch.await();
+        Thread.sleep(2000);
 
         // Try to close. This should wakeup select.
-        new Thread(new Runnable() {
+        Thread closeThread = new Thread(new Runnable() {
                 public void run() {
                     try {
                         selector.close();
@@ -63,10 +67,11 @@
                         System.err.println(e);
                     }
                 }
-            }).start();
+            });
+        closeThread.start();
 
         // Wait for select() to be awakened, which should be done by close.
-        Thread.sleep(3000);
+        closeThread.join();
 
         if (!awakened)
             selector.wakeup();
--- a/jdk/test/java/nio/channels/Selector/SelectorLimit.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/nio/channels/Selector/SelectorLimit.java	Wed Jul 05 23:09:40 2017 +0200
@@ -66,15 +66,6 @@
     static final int MIN_KEYS = 100;
 
     public static void main(String[] args) throws Exception {
-        // win9X can't handle many connections at once
-        String osName = System.getProperty("os.name");
-        if (osName.toLowerCase().startsWith("win")) {
-            if (!(osName.equals("Windows NT")
-                  || osName.equals("Windows 2000")
-                  || osName.equals("Windows XP")))
-                return;
-        }
-
         ServerSocketChannel ssc = ServerSocketChannel.open();
         TestUtil.bind(ssc);
         Listener lth = new Listener(ssc);
--- a/jdk/test/java/security/cert/PKIXRevocationChecker/OcspUnauthorized.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/security/cert/PKIXRevocationChecker/OcspUnauthorized.java	Wed Jul 05 23:09:40 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:09:40 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:09:40 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	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/security/testlibrary/CertUtils.java	Wed Jul 05 23:09:40 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);
     }
 
     /**
--- a/jdk/test/java/util/ServiceLoader/basic/basic.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/util/ServiceLoader/basic/basic.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -76,6 +76,7 @@
       (cd $JARD; "$JAR" ${TESTTOOLVMOPTS} -cf ../p$n.jar *)
     done
 
+    cp p2.jar p2dup.jar
     mv p3.jar $EXTD
 
     cp $TESTCLASSES/Load.class $TESTD
@@ -117,6 +118,8 @@
 
 go ".${SEP}p2.jar" "" FooProvider2
 
+go ".${SEP}p2.jar${SEP}p2dup.jar" "" FooProvider2
+
 go "${P3JAR}${SEP}p2.jar" "" FooProvider3 FooProvider2
 
 go "$TESTD${SEP}p2.jar" "" FooProvider1 FooProvider2
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java	Wed Jul 05 23:09:40 2017 +0200
@@ -32,9 +32,14 @@
  * 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.CompletableFuture;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ForkJoinTask;
+import java.util.concurrent.Future;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -53,29 +58,43 @@
      */
     public void testCommonPoolThreadContextClassLoader() throws Throwable {
         if (!testImplementationDetails) return;
+
+        // Ensure common pool has at least one real thread
+        String prop = System.getProperty(
+            "java.util.concurrent.ForkJoinPool.common.parallelism");
+        if ("0".equals(prop)) return;
+
         VarHandle CCL =
             MethodHandles.privateLookupIn(Thread.class, MethodHandles.lookup())
             .findVarHandle(Thread.class, "contextClassLoader", ClassLoader.class);
         ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
         boolean haveSecurityManager = (System.getSecurityManager() != null);
-        CompletableFuture.runAsync(
-            () -> {
-                assertSame(systemClassLoader,
-                           Thread.currentThread().getContextClassLoader());
-                assertSame(systemClassLoader,
-                           CCL.get(Thread.currentThread()));
-                if (haveSecurityManager)
-                    assertThrows(
-                        SecurityException.class,
-                        () -> System.getProperty("foo"),
-                        () -> Thread.currentThread().setContextClassLoader(null));
-
-                // TODO ?
-//                 if (haveSecurityManager
-//                     && Thread.currentThread().getClass().getSimpleName()
-//                     .equals("InnocuousForkJoinWorkerThread"))
-//                     assertThrows(SecurityException.class, /* ?? */);
-            }).join();
+        CountDownLatch taskStarted = new CountDownLatch(1);
+        Runnable runInCommonPool = () -> {
+            taskStarted.countDown();
+            assertTrue(ForkJoinTask.inForkJoinPool());
+            assertSame(ForkJoinPool.commonPool(),
+                       ForkJoinTask.getPool());
+            assertSame(systemClassLoader,
+                       Thread.currentThread().getContextClassLoader());
+            assertSame(systemClassLoader,
+                       CCL.get(Thread.currentThread()));
+            if (haveSecurityManager)
+                assertThrows(
+                    SecurityException.class,
+                    () -> System.getProperty("foo"),
+                    () -> Thread.currentThread().setContextClassLoader(null));
+            // TODO ?
+//          if (haveSecurityManager
+//              && Thread.currentThread().getClass().getSimpleName()
+//                 .equals("InnocuousForkJoinWorkerThread"))
+//              assertThrows(SecurityException.class, /* ?? */);
+        };
+        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));
+        assertNull(f.get());
     }
 
 }
--- a/jdk/test/javax/management/ImplementationVersion/ImplVersionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ImplementationVersion/ImplVersionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,7 @@
  * test codebase has the java permission to read the "java.runtime.version"
  * system property.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ImplVersionTest ImplVersionCommand
  * @run build ImplVersionTest ImplVersionCommand ImplVersionReader
  * @run main ImplVersionTest
--- a/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,10 @@
  * @summary Test that having a security manager doesn't trigger a
  *          NotCompliantMBeanException
  * @author Daniel Fuchs, Yves Joan
- * @modules java.management
+ *
+ * @modules java.desktop
+ *          java.management
+ *
  * @run clean AnnotationSecurityTest Described UnDescribed DescribedMBean
  *            UnDescribedMBean SqeDescriptorKey DescribedMX DescribedMXBean
  * @run build AnnotationSecurityTest Described UnDescribed DescribedMBean
--- a/jdk/test/javax/management/Introspector/AnnotationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/AnnotationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that annotations in Standard MBean interfaces
  * correctly produce Descriptor entries
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean AnnotationTest
  * @run build AnnotationTest
  * @run main AnnotationTest
--- a/jdk/test/javax/management/Introspector/ChangingNotifsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/ChangingNotifsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Check that Standard MBeans can change their MBeanNotificationInfo[]
  * and MXBeans cannot
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ChangingNotifsTest
  * @run build ChangingNotifsTest
  * @run main ChangingNotifsTest
--- a/jdk/test/javax/management/Introspector/ClassLeakTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/ClassLeakTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4909536
  * @summary Ensure that the Introspector does not retain refs to classes
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ClassLeakTest
  * @run build ClassLeakTest
  * @run main ClassLeakTest
--- a/jdk/test/javax/management/Introspector/DuplicateGetterTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/DuplicateGetterTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Test that an MBean interface can inherit two methods with
  * the same signature from two unrelated parent interfaces
  * @author Eamonn McManus
- * @modules java.management
  */
 
 import java.util.*;
--- a/jdk/test/javax/management/Introspector/FeatureOrderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/FeatureOrderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,6 @@
  * @summary Test that attributes and operations appear in the same order
  * in MBeanInfo as they did in the Standard MBean or MXBean Interface.
  * @author Eamonn McManus
- * @modules java.management
  */
 
 /*
--- a/jdk/test/javax/management/Introspector/GetMBeanInfoExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/GetMBeanInfoExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that the exception thrown by DynamicMBean.getMBeanInfo()
  *          keeps the init cause.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean GetMBeanInfoExceptionTest
  * @run build GetMBeanInfoExceptionTest
  * @run main GetMBeanInfoExceptionTest
--- a/jdk/test/javax/management/Introspector/IdenticalMBeanInfoTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/IdenticalMBeanInfoTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Check that MBeans with the same class have identical MBeanInfo
  * unless they are NotificationBroadcasters
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean IdenticalMBeanInfoTest
  * @run build IdenticalMBeanInfoTest
  * @run main IdenticalMBeanInfoTest
--- a/jdk/test/javax/management/Introspector/ImmutableNotificationInfoTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/ImmutableNotificationInfoTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Check that a StandardMBean has immutableInfo=true if it is
  * a NotificationBroadcasterSupport that doesn't override getNotificationInfo()
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ImmutableNotificationInfoTest
  * @run build ImmutableNotificationInfoTest
  * @run main ImmutableNotificationInfoTest
--- a/jdk/test/javax/management/Introspector/InvokeGettersTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/InvokeGettersTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6317101
  * @summary Test that the jmx.invoke.getters system property works
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean InvokeGettersTest
  * @run build InvokeGettersTest
  * @run main InvokeGettersTest
--- a/jdk/test/javax/management/Introspector/IsMethodTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/IsMethodTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4947001 4954369 4954409 4954410
  * @summary Test that "Boolean isX()" and "int isX()" define operations
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean IsMethodTest
  * @run build IsMethodTest
  * @run main IsMethodTest
--- a/jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -37,8 +37,10 @@
  *          j.b.ConstructorProperties and j.m.ConstructorProperties annotations
  *          only j.m.ConstructorProperties annotation is considered.
  * @author Jaroslav Bachorik
- * @modules java.management
- *          java.desktop
+ *
+ * @modules java.desktop
+ *          java.management
+ *
  * @run main LegacyConstructorPropertiesTest
  */
 
--- a/jdk/test/javax/management/Introspector/NotAnMBeanTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/NotAnMBeanTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4914805
  * @summary Ensure that the right exception is thrown for illegal MBeans
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean NotAnMBeanTest
  * @run build NotAnMBeanTest
  * @run main NotAnMBeanTest
--- a/jdk/test/javax/management/Introspector/NotCompliantCauseTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/NotCompliantCauseTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that NotCompliantMBeanException has a cause in case of
  *          type mapping problems.
  * @author Daniel Fuchs, Alexander Shusherov
- * @modules java.management
+ *
  * @run clean NotCompliantCauseTest
  * @run build NotCompliantCauseTest
  * @run main NotCompliantCauseTest
@@ -40,7 +40,6 @@
  */
 
 import java.util.Random;
-import java.util.logging.Logger;
 
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
@@ -55,12 +54,6 @@
 public class NotCompliantCauseTest {
 
     /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(NotCompliantCauseTest.class.getName());
-
-    /**
      * Creates a new instance of NotCompliantCauseTest
      */
     public NotCompliantCauseTest() {
--- a/jdk/test/javax/management/Introspector/SetWrongTypeAttributeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/SetWrongTypeAttributeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Check that setting the wrong type of an attribute in a Standard
  * MBean or MXBean causes InvalidAttributeValueException
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean SetWrongTypeAttributeTest
  * @run build SetWrongTypeAttributeTest
  * @run main SetWrongTypeAttributeTest
--- a/jdk/test/javax/management/Introspector/UnregisterMBeanExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/Introspector/UnregisterMBeanExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  *          the supplied MBean although DynamicMBean.getMBeanInfo() throws
  *          a runtime exception.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean UnregisterMBeanExceptionTest
  * @run build UnregisterMBeanExceptionTest
  * @run main UnregisterMBeanExceptionTest
--- a/jdk/test/javax/management/MBeanInfo/EqualExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanInfo/EqualExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5071110
  * @summary Test whether an null descriptor will cause an NullPointerException.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean EqualExceptionTest
  * @run build EqualExceptionTest
  * @run main EqualExceptionTest
--- a/jdk/test/javax/management/MBeanInfo/MBeanInfoEqualsNPETest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanInfo/MBeanInfoEqualsNPETest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -36,7 +36,7 @@
  * @bug 8023954
  * @summary Test that MBean*Info.equals do not throw NPE
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean MBeanInfoEqualsNPETest
  * @run build MBeanInfoEqualsNPETest
  * @run main MBeanInfoEqualsNPETest
--- a/jdk/test/javax/management/MBeanInfo/MBeanInfoEqualsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanInfo/MBeanInfoEqualsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4719923
  * @summary Test that MBeanInfo.equals works even for mutable subclasses
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean MBeanInfoEqualsTest
  * @run build MBeanInfoEqualsTest
  * @run main MBeanInfoEqualsTest
--- a/jdk/test/javax/management/MBeanInfo/MBeanInfoHashCodeNPETest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanInfo/MBeanInfoHashCodeNPETest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -35,7 +35,7 @@
  * @bug 8023669
  * @summary Test that hashCode()throws NullPointerException
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean MBeanInfoHashCodeNPETest
  * @run build MBeanInfoHashCodeNPETest
  * @run main MBeanInfoHashCodeNPETest
--- a/jdk/test/javax/management/MBeanInfo/NullInfoArraysTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanInfo/NullInfoArraysTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that an MBeanInfo works even if it is deserialized from
  * an implementation where its array fields can be null.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean NullInfoArraysTest
  * @run build NullInfoArraysTest
  * @run main NullInfoArraysTest
--- a/jdk/test/javax/management/MBeanInfo/SerializationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanInfo/SerializationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6288100
  * @summary Test the new serialization/deserialization methods.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean SerializationTest
  * @run build SerializationTest
  * @run main SerializationTest
--- a/jdk/test/javax/management/MBeanInfo/SerializationTest1.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanInfo/SerializationTest1.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6783290
  * @summary Test correct reading of an empty Descriptor.
  * @author Jaroslav Bachorik
- * @modules java.management
+ *
  * @run clean SerializationTest1
  * @run build SerializationTest1
  * @run main SerializationTest1
--- a/jdk/test/javax/management/MBeanInfo/TooManyFooTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanInfo/TooManyFooTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that a method inherited from two different interfaces
  *          appears only once in MBeanInfo.
  * @author dfuchs
- * @modules java.management
+ *
  * @run clean TooManyFooTest
  * @run build TooManyFooTest
  * @run main TooManyFooTest
@@ -55,12 +55,6 @@
  */
 public class TooManyFooTest {
 
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(TooManyFooTest.class.getName());
-
     public static class NumberHolder {
         public Integer getNumber() { return 0;}
         public void setNumber(Integer n) {};
--- a/jdk/test/javax/management/MBeanServer/AttributeListTypeSafeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/AttributeListTypeSafeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6336968
  * @summary Test adding non-Attribute values to an AttributeList.
  * @author Eamonn McManus
- * @modules java.management
  */
 
 import java.util.Collections;
--- a/jdk/test/javax/management/MBeanServer/MBeanExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/MBeanExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,8 +28,7 @@
  * RuntimeMBeanException and (for Standard MBeans) that checked exceptions
  * are wrapped in MBeanException
  * @author Eamonn McManus
- * @modules java.management
- * @compile MBeanExceptionTest.java
+ *
  * @run main MBeanExceptionTest
  */
 
--- a/jdk/test/javax/management/MBeanServer/MBeanFallbackTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/MBeanFallbackTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -33,7 +33,7 @@
  *          It needs to be a separate class because the "jdk.jmx.mbeans.allowNonPublic"
  *          system property must be set before c.s.j.m.MBeanAnalyzer has been loaded.
  * @author Jaroslav Bachorik
- * @modules java.management
+ *
  * @run clean MBeanFallbackTest
  * @run build MBeanFallbackTest
  * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true MBeanFallbackTest
--- a/jdk/test/javax/management/MBeanServer/MBeanServerInvocationHandlerExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/MBeanServerInvocationHandlerExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5092515
  * @summary Test how to unwrap a user specific exception
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean MBeanServerInvocationHandlerExceptionTest
  * @run build MBeanServerInvocationHandlerExceptionTest
  * @run main MBeanServerInvocationHandlerExceptionTest
--- a/jdk/test/javax/management/MBeanServer/MBeanTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/MBeanTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -31,7 +31,7 @@
  * @bug 8010285
  * @summary General MBean test.
  * @author Jaroslav Bachorik
- * @modules java.management
+ *
  * @run clean MBeanTest
  * @run build MBeanTest
  * @run main MBeanTest
--- a/jdk/test/javax/management/MBeanServer/NewMBeanListenerTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/NewMBeanListenerTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4757273
  * @summary Test that registered notification is sent early enough
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean NewMBeanListenerTest
  * @run build NewMBeanListenerTest
  * @run main NewMBeanListenerTest
--- a/jdk/test/javax/management/MBeanServer/NotifDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/NotifDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4757273
  * @summary Test deadlock in MBeanServerDelegate listeners
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean NotifDeadlockTest
  * @run build NotifDeadlockTest
  * @run main NotifDeadlockTest
--- a/jdk/test/javax/management/MBeanServer/PostExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/PostExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,8 +27,7 @@
  * @summary Check behaviour of MBeanServer when postRegister and postDeregister
  *          throw exceptions.
  * @author Daniel Fuchs
- * @modules java.management
- * @compile PostExceptionTest.java
+ *
  * @run main PostExceptionTest
  */
 
--- a/jdk/test/javax/management/MBeanServer/PostRegisterDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/PostRegisterDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6417044
  * @summary Test deadlock in MBeanRegistration.postRegister method
  * @author Eamonn McManus, Daniel Fuchs
- * @modules java.management
+ *
  * @run clean PostRegisterDeadlockTest
  * @run build PostRegisterDeadlockTest
  * @run main PostRegisterDeadlockTest
--- a/jdk/test/javax/management/MBeanServer/PostRegisterDeadlockTest2.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/PostRegisterDeadlockTest2.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6417044
  * @summary Test that a failing MBean registration does not lead to a deadlock
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run main PostRegisterDeadlockTest2
  */
 
--- a/jdk/test/javax/management/MBeanServer/PreDeregisterDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/PreDeregisterDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6318664
  * @summary Test deadlock in MBeanRegistration.preDeregister method
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean PreDeregisterDeadlockTest
  * @run build PreDeregisterDeadlockTest
  * @run main PreDeregisterDeadlockTest
--- a/jdk/test/javax/management/MBeanServer/PreRegisterTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServer/PreRegisterTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4911846
  * @summary Test that MBeanRegistration can change caller ObjectName
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean PreRegisterTest
  * @run build PreRegisterTest
  * @run main PreRegisterTest
--- a/jdk/test/javax/management/MBeanServerFactory/ReleaseMBeanServerTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MBeanServerFactory/ReleaseMBeanServerTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that the releaseMBeanServer(MBeanServer mbeanServer) method
  *          throws IllegalArgumentException as expected
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ReleaseMBeanServerTest
  * @run build ReleaseMBeanServerTest
  * @run main ReleaseMBeanServerTest
--- a/jdk/test/javax/management/MustBeValidMBeanInfo/MustBeValidCommand.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/MustBeValidMBeanInfo/MustBeValidCommand.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  * IllegalArgumentException when attribute names, operation names, and
  * Java type names do not strictly follow the expected Java syntax.
  * @author Daniel Fuchs
- * @modules java.management
+ *
  * @run clean MustBeValidCommand
  * @run build MustBeValidCommand
  * @run main MustBeValidCommand
--- a/jdk/test/javax/management/ObjectInstance/MBeanInfoFailTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectInstance/MBeanInfoFailTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5001857
  * @summary Test queryNames() and queryMBeans() with a buggy DynamicMBean
  * @author Daniel Fuchs
- * @modules java.management
+ *
  * @run clean MBeanInfoFailTest
  * @run build MBeanInfoFailTest
  * @run main MBeanInfoFailTest
--- a/jdk/test/javax/management/ObjectInstance/ObjectInstanceNullTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectInstance/ObjectInstanceNullTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5015663
  * @summary Test ObjectInstance(name,null).hashCode() and .equals()
  * @author Daniel Fuchs
- * @modules java.management
+ *
  * @run clean ObjectInstanceNullTest
  * @run build ObjectInstanceNullTest
  * @run main ObjectInstanceNullTest
--- a/jdk/test/javax/management/ObjectInstance/ToStringMethodTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectInstance/ToStringMethodTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5080083
  * @summary Test new added method "toString"
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean ToStringMethodTest
  * @run build ToStringMethodTest
  * @run main ToStringMethodTest
--- a/jdk/test/javax/management/ObjectName/ApplyWildcardTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectName/ApplyWildcardTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test the ObjectName.apply(ObjectName) method
  *          with wildcards in the key properties value part.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ApplyWildcardTest
  * @run build ApplyWildcardTest
  * @run main ApplyWildcardTest
--- a/jdk/test/javax/management/ObjectName/ComparatorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectName/ComparatorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5036680
  * @summary Test the ObjectName.compareTo() method.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ComparatorTest
  * @run build ComparatorTest
  * @run main ComparatorTest
--- a/jdk/test/javax/management/ObjectName/DelegateNameWildcardNameTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectName/DelegateNameWildcardNameTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that MBeanServerDelegate.DELEGATE_NAME and ObjectName.WILDCARD
  *          public constants have been initialized properly.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean DelegateNameWildcardNameTest
  * @run build DelegateNameWildcardNameTest
  * @run main DelegateNameWildcardNameTest
--- a/jdk/test/javax/management/ObjectName/NullEmptyKeyValueTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectName/NullEmptyKeyValueTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6229396
  * @summary Test null/empty key/values in ObjectName constructors.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean NullEmptyKeyValueTest
  * @run build NullEmptyKeyValueTest
  * @run main NullEmptyKeyValueTest
--- a/jdk/test/javax/management/ObjectName/ObjectNameGetInstanceTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectName/ObjectNameGetInstanceTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4894801
  * @summary Test that ObjectName.getInstance(ObjectName) preserves key order
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ObjectNameGetInstanceTest
  * @run build ObjectNameGetInstanceTest
  * @run main ObjectNameGetInstanceTest
--- a/jdk/test/javax/management/ObjectName/RepositoryWildcardTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectName/RepositoryWildcardTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test if the repository supports correctly the use of
  *          wildcards in the ObjectName key properties value part.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean RepositoryWildcardTest
  * @run build RepositoryWildcardTest
  * @run main RepositoryWildcardTest
--- a/jdk/test/javax/management/ObjectName/SerialCompatTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectName/SerialCompatTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6211220 6616825
  * @summary Test that jmx.serial.form=1.0 works for ObjectName
  * @author Eamonn McManus, Daniel Fuchs
- * @modules java.management
+ *
  * @run clean SerialCompatTest
  * @run build SerialCompatTest
  * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true -Djmx.serial.form=1.0 SerialCompatTest
--- a/jdk/test/javax/management/ObjectName/ValueWildcardTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/ObjectName/ValueWildcardTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4716807
  * @summary Test wildcards in ObjectName key properties value part.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ValueWildcardTest
  * @run build ValueWildcardTest
  * @run main ValueWildcardTest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = java.management
+
--- a/jdk/test/javax/management/descriptor/DefaultDescriptorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/descriptor/DefaultDescriptorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6204469
  * @summary Test that MBean*Info can be constructed with default descriptor
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean DefaultDescriptorTest
  * @run build DefaultDescriptorTest
  * @run main DefaultDescriptorTest
--- a/jdk/test/javax/management/descriptor/DescriptorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/descriptor/DescriptorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6204469 6273765
  * @summary Test various aspects of the Descriptor interface
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean DescriptorTest
  * @run build DescriptorTest
  * @run main DescriptorTest
--- a/jdk/test/javax/management/descriptor/EqualsHashCodeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/descriptor/EqualsHashCodeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6255956
  * @summary Test equals and hashCode for descriptors
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean EqualsHashCodeTest
  * @run build EqualsHashCodeTest
  * @run main EqualsHashCodeTest
--- a/jdk/test/javax/management/descriptor/ImmutableArrayFieldTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/descriptor/ImmutableArrayFieldTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that immutability of ImmutableDescriptor cannot be
  * compromised by modifying field values that are arrays.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ImmutableArrayFieldTest
  * @run build ImmutableArrayFieldTest
  * @run main ImmutableArrayFieldTest
--- a/jdk/test/javax/management/descriptor/ImmutableDescriptorSerialTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/descriptor/ImmutableDescriptorSerialTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6204469
  * @summary Test ImmutableDescriptor serialization.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ImmutableDescriptorSerialTest
  * @run build ImmutableDescriptorSerialTest
  * @run main ImmutableDescriptorSerialTest
--- a/jdk/test/javax/management/descriptor/ImmutableDescriptorSetFieldsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/descriptor/ImmutableDescriptorSetFieldsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  * null name in it and calling setFields with a field names array with an
  * empty name in it throw the expected exceptions.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ImmutableDescriptorSetFieldsTest
  * @run build ImmutableDescriptorSetFieldsTest
  * @run main ImmutableDescriptorSetFieldsTest
--- a/jdk/test/javax/management/descriptor/MBeanInfoInteropTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/descriptor/MBeanInfoInteropTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6204469
  * @summary Check that descriptors have not broken serial interop.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean MBeanInfoInteropTest SerializedInfo
  * @run build MBeanInfoInteropTest SerializedInfo
  * @run main MBeanInfoInteropTest SerializedInfo
--- a/jdk/test/javax/management/descriptor/UnionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/descriptor/UnionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6273752
  * @summary Test ImmutableDescriptor.union
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean UnionTest
  * @run build UnionTest
  * @run main UnionTest
--- a/jdk/test/javax/management/generified/GenericTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/generified/GenericTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4847959 6191402
  * @summary Test newly-generified APIs
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean GenericTest
  * @run build GenericTest
  * @run main GenericTest
--- a/jdk/test/javax/management/generified/ListTypeCheckTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/generified/ListTypeCheckTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6250772
  * @summary Test that *List objects are checked after asList is called.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ListTypeCheckTest
  * @run build ListTypeCheckTest
  * @run main ListTypeCheckTest
--- a/jdk/test/javax/management/loading/ArrayClassTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/loading/ArrayClassTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that array classes can be found in signatures always
  * and can be deserialized by the deprecated MBeanServer.deserialize method
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ArrayClassTest
  * @run build ArrayClassTest
  * @run main ArrayClassTest
--- a/jdk/test/javax/management/loading/DocumentRootTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/loading/DocumentRootTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test parsing error when the mlet file is
  *          located in the web server's document root.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean DocumentRootTest
  * @run build DocumentRootTest
  * @run main DocumentRootTest
--- a/jdk/test/javax/management/loading/GetMBeansFromURLTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/loading/GetMBeansFromURLTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  *          given MLet instance throws a ServiceNotFoundException exception
  *          with a non null cause.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean GetMBeansFromURLTest
  * @run build GetMBeansFromURLTest
  * @run main GetMBeansFromURLTest
--- a/jdk/test/javax/management/loading/LibraryLoader/LibraryLoaderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/loading/LibraryLoader/LibraryLoaderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that the same native library coming from the same jar file can
  * be loaded twice by two different MLets on the same JVM without conflict.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean LibraryLoaderTest
  * @run build LibraryLoaderTest
  * @run main/othervm LibraryLoaderTest
--- a/jdk/test/javax/management/loading/MLetCLR/MLetCommand.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/loading/MLetCLR/MLetCommand.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  * for the test codebase as it is executed by the MLet code using
  * doPrivileged.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean MLetCommand
  * @run build MLetCommand
  * @run main/othervm/java.security.policy=policy MLetCommand
--- a/jdk/test/javax/management/loading/MLetContentTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/loading/MLetContentTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4796780
  * @summary The class MLetContentTest becomes public
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean MLetContentTest
  * @run build MLetContentTest
  * @run main MLetContentTest
--- a/jdk/test/javax/management/loading/MletParserLocaleTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/loading/MletParserLocaleTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 7065236
  * @summary Checking MletParser for Locale insensitive strings
  * @author Harsha Wardhana B
- * @modules java.management
+ *
  * @run clean MletParserLocaleTest
  * @run build MletParserLocaleTest
  * @run main/othervm/timeout=5 MletParserLocaleTest mlet4.html
--- a/jdk/test/javax/management/loading/ParserInfiniteLoopTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/loading/ParserInfiniteLoopTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,7 @@
  * terminated with the corresponding '>' and an opening '<' for
  * the subsequent tag is encountered.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ParserInfiniteLoopTest
  * @run build ParserInfiniteLoopTest
  * @run main/othervm/timeout=5 ParserInfiniteLoopTest mlet1.html
--- a/jdk/test/javax/management/loading/SystemClassLoaderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/loading/SystemClassLoaderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that a class can load MBeans from its class loader
  * (at least if it is the system class loader)
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean SystemClassLoaderTest
  * @run build SystemClassLoaderTest
  * @run main SystemClassLoaderTest
--- a/jdk/test/javax/management/modelmbean/AddAttributeChangeNotificationListenerTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/AddAttributeChangeNotificationListenerTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,7 +30,7 @@
  * no other attributes.
  * @author Yves Joan
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean AddAttributeChangeNotificationListenerTest
  * @run build AddAttributeChangeNotificationListenerTest
  * @run main AddAttributeChangeNotificationListenerTest
--- a/jdk/test/javax/management/modelmbean/DescriptorSupportSerialTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/DescriptorSupportSerialTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6332962
  * @summary Test that DescriptorSupport does not serialize targetObject
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean DescriptorSupportSerialTest
  * @run build DescriptorSupportSerialTest
  * @run main DescriptorSupportSerialTest
--- a/jdk/test/javax/management/modelmbean/DescriptorSupportTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/DescriptorSupportTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4883712 4869006 4894856 5016685
  * @summary Test that DescriptorSupport correctly validates fields
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean DescriptorSupportTest
  * @run build DescriptorSupportTest
  * @run main DescriptorSupportTest
--- a/jdk/test/javax/management/modelmbean/DescriptorSupportXMLLocaleTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/DescriptorSupportXMLLocaleTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 7065236
  * @summary Test for locale insensitive strings in DescriptorSupport class
  * @author Harsha Wardhana B
- * @modules java.management
+ *
  * @run clean DescriptorSupportXMLLocaleTest
  * @run build DescriptorSupportXMLLocaleTest
  * @run main DescriptorSupportXMLLocaleTest
--- a/jdk/test/javax/management/modelmbean/DescriptorSupportXMLTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/DescriptorSupportXMLTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that DescriptorSupport.toXMLString() can be used to
  * reconstruct an equivalent DescriptorSupport
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean DescriptorSupportXMLTest
  * @run build DescriptorSupportXMLTest
  * @run main DescriptorSupportXMLTest
--- a/jdk/test/javax/management/modelmbean/ExoticTargetTypeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/ExoticTargetTypeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that a custom ModelMBean implementation can have custom
  * targetType values in its ModelMBeanOperationInfo descriptors.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ExoticTargetTypeTest
  * @run build ExoticTargetTypeTest
  * @run main ExoticTargetTypeTest
--- a/jdk/test/javax/management/modelmbean/InfoSupportTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/InfoSupportTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,7 @@
  * that getDescriptors("mbean") works, and that default values for
  * MBean descriptors are correctly assigned.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean InfoSupportTest
  * @run build InfoSupportTest
  * @run main InfoSupportTest
--- a/jdk/test/javax/management/modelmbean/LoggingExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/LoggingExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,9 @@
  * when traces enabled and no attributes.
  * @author Luis-Miguel Alventosa
  * @author Paul Cheeseman
- * @modules java.management
+ *
+ * @modules java.logging
+ *          java.management
  */
 
 import java.util.logging.ConsoleHandler;
--- a/jdk/test/javax/management/modelmbean/ModelMBeanInfoSupport/GetAllDescriptorsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/ModelMBeanInfoSupport/GetAllDescriptorsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that  ModelMBeanInfoSupport.getDescriptors(null) also
  *          returns the MBean's descriptor.
  * @author Eamonn McManus, Daniel Fuchs
- * @modules java.management
+ *
  * @run clean GetAllDescriptorsTest
  * @run build GetAllDescriptorsTest
  * @run main/othervm/java.security.policy=policy  GetAllDescriptorsTest
--- a/jdk/test/javax/management/modelmbean/OnUnregisterTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/OnUnregisterTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Check that OnUnregister is an allowed value for persistPolicy
  * in ModelMBeanAttributeInfo
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean OnUnregisterTest
  * @run build OnUnregisterTest
  * @run main OnUnregisterTest
--- a/jdk/test/javax/management/modelmbean/RequiredModelMBeanGetAttributeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/RequiredModelMBeanGetAttributeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -36,7 +36,7 @@
  * - the declared name can be loaded by the value's class loader and
  *   produces a class to which the value can be assigned.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean RequiredModelMBeanGetAttributeTest
  * @run build RequiredModelMBeanGetAttributeTest
  * @run main RequiredModelMBeanGetAttributeTest
--- a/jdk/test/javax/management/modelmbean/RequiredModelMBeanMethodTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/RequiredModelMBeanMethodTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  * from the RequiredModelMBean class itself if they are not in the
  * ModelMBeanInfo
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean RequiredModelMBeanMethodTest
  * @run build RequiredModelMBeanMethodTest
  * @run main RequiredModelMBeanMethodTest
--- a/jdk/test/javax/management/modelmbean/RequiredModelMBeanSetAttributeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/RequiredModelMBeanSetAttributeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  * MBeanException wrapping a ServiceNotFoundException is thrown is setAttribute
  * called but no setMethod field has been provided.
  * @author Jean-Francois Denise
- * @modules java.management
+ *
  * @run clean RequiredModelMBeanSetAttributeTest
  * @run build RequiredModelMBeanSetAttributeTest
  * @run main RequiredModelMBeanSetAttributeTest
--- a/jdk/test/javax/management/modelmbean/SimpleModelMBean/SimpleModelMBeanCommand.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/modelmbean/SimpleModelMBean/SimpleModelMBeanCommand.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  * IllegalArgumentException when attribute names, operation names, and
  * Java type names do not strictly follow the expected Java syntax.
  * @author Eamonn McManus, Daniel Fuchs
- * @modules java.management
+ *
  * @run clean SimpleModelMBeanCommand
  * @run build SimpleModelMBeanCommand
  * @run main/othervm/java.security.policy=policy  SimpleModelMBeanCommand
--- a/jdk/test/javax/management/monitor/CounterMonitorDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/CounterMonitorDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that no locks are held when a monitor attribute is sampled
  * or notif delivered.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean CounterMonitorDeadlockTest
  * @run build CounterMonitorDeadlockTest
  * @run main CounterMonitorDeadlockTest 1
--- a/jdk/test/javax/management/monitor/CounterMonitorInitThresholdTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/CounterMonitorInitThresholdTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  *          objects added before the counter monitor is started as well as by
  *          the observed objects which are added once the monitor is started.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean CounterMonitorInitThresholdTest
  * @run build CounterMonitorInitThresholdTest
  * @run main CounterMonitorInitThresholdTest
--- a/jdk/test/javax/management/monitor/CounterMonitorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/CounterMonitorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that the counter monitor, when running in difference mode,
  *          emits a notification every time the threshold is exceeded.
  * @author Luis-Miguel Alventosa, Shanliang JIANG
- * @modules java.management
+ *
  * @run clean CounterMonitorTest
  * @run build CounterMonitorTest
  * @run main CounterMonitorTest
--- a/jdk/test/javax/management/monitor/CounterMonitorThresholdTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/CounterMonitorThresholdTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6229368 8025207
  * @summary Wrong threshold value in CounterMonitor with offset and modulus.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean CounterMonitorThresholdTest
  * @run build CounterMonitorThresholdTest
  * @run main CounterMonitorThresholdTest
--- a/jdk/test/javax/management/monitor/DerivedGaugeMonitorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/DerivedGaugeMonitorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6683213
  * @summary Test that the initial derived gauge is (Integer)0
  * @author Daniel Fuchs
- * @modules java.management
+ *
  * @run clean DerivedGaugeMonitorTest
  * @run build DerivedGaugeMonitorTest
  * @run main DerivedGaugeMonitorTest
--- a/jdk/test/javax/management/monitor/GaugeMonitorDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/GaugeMonitorDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,8 +27,9 @@
  * @summary Test that no locks are held when a monitor attribute is sampled
  * or notif delivered.
  * @author Eamonn McManus
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @run clean GaugeMonitorDeadlockTest
  * @run build GaugeMonitorDeadlockTest
  * @run main GaugeMonitorDeadlockTest 1
--- a/jdk/test/javax/management/monitor/MultiMonitorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/MultiMonitorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,13 +24,13 @@
 /*
  * @test
  * @bug 4984057
+ * @key randomness
  * @summary Test that monitors can sample a large number of attributes
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean MultiMonitorTest
  * @run build MultiMonitorTest
  * @run main MultiMonitorTest
- * @key randomness
  */
 
 import java.util.*;
--- a/jdk/test/javax/management/monitor/NonComparableAttributeValueTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/NonComparableAttributeValueTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  *          jmx.monitor.error.type notification when the attribute
  *          being monitored returns a non comparable value.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean NonComparableAttributeValueTest
  * @run build NonComparableAttributeValueTest
  * @run main NonComparableAttributeValueTest
--- a/jdk/test/javax/management/monitor/NullAttributeValueTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/NullAttributeValueTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,7 @@
  *          being monitored returns a null value.
  * @author Luis-Miguel Alventosa
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean NullAttributeValueTest
  * @run build NullAttributeValueTest
  * @run main NullAttributeValueTest
--- a/jdk/test/javax/management/monitor/ReflectionExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/ReflectionExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,11 +24,11 @@
 /*
  * @test
  * @bug 6205072
+ * @key intermittent
  * @summary Test that the jmx.monitor.error.runtime monitor notification
  *          is emitted when getAttribute throws ReflectionException.
  * @author Luis-Miguel Alventosa
- * @key intermittent
- * @modules java.management
+ *
  * @run clean ReflectionExceptionTest MBeanServerBuilderImpl
  *            MBeanServerForwarderInvocationHandler
  * @run build ReflectionExceptionTest MBeanServerBuilderImpl
--- a/jdk/test/javax/management/monitor/RuntimeExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/RuntimeExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that the jmx.monitor.error.runtime monitor notification
  *          is emitted when getAttribute throws RuntimeException.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean RuntimeExceptionTest MBeanServerBuilderImpl
  *            MBeanServerForwarderInvocationHandler
  * @run build RuntimeExceptionTest MBeanServerBuilderImpl
--- a/jdk/test/javax/management/monitor/StartStopTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/StartStopTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,8 +27,9 @@
  * @summary Test that tasks are cancelled properly when
  *          monitors are started and stopped in a loop.
  * @author Luis-Miguel Alventosa
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @build jdk.testlibrary.*
  * @run clean StartStopTest
  * @run build StartStopTest
--- a/jdk/test/javax/management/monitor/StringMonitorDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/StringMonitorDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,11 +24,11 @@
 /*
  * @test
  * @bug 6303187
+ * @key intermittent
  * @summary Test that no locks are held when a monitor attribute is sampled
  * or notif delivered.
  * @author Eamonn McManus
- * @key intermittent
- * @modules java.management
+ *
  * @run clean StringMonitorDeadlockTest
  * @run build StringMonitorDeadlockTest
  * @run main StringMonitorDeadlockTest 1
--- a/jdk/test/javax/management/monitor/ThreadPoolAccTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/ThreadPoolAccTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that each thread in the thread pool runs
  *          in the context of the monitor.start() caller.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ThreadPoolAccTest
  * @run build ThreadPoolAccTest
  * @run main ThreadPoolAccTest
--- a/jdk/test/javax/management/monitor/ThreadPoolTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/monitor/ThreadPoolTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that all monitors will be well started when sharing
  * a single thread pool.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ThreadPoolTest
  * @run build ThreadPoolTest
  * @run main/othervm/timeout=300 ThreadPoolTest 1
--- a/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6175517 6278707
  * @summary Test that ambiguous ConstructorProperties annotations are detected.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean AmbiguousConstructorTest
  * @run build AmbiguousConstructorTest
  * @run main AmbiguousConstructorTest
--- a/jdk/test/javax/management/mxbean/ComparatorExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/ComparatorExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6601652
  * @summary Test exception when SortedMap or SortedSet has non-null Comparator
  * @author Eamonn McManus
- * @modules java.management
  */
 
 import java.util.SortedMap;
--- a/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6713777
  * @summary Test that exception messages include all relevant information
  * @author Eamonn McManus
- * @modules java.management
  */
 
 import javax.management.ConstructorParameters;
--- a/jdk/test/javax/management/mxbean/GenericTypeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/GenericTypeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6376416 6406447
  * @summary Test use of generic types in MXBeans (mostly illegal).
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run main GenericTypeTest
  */
 
--- a/jdk/test/javax/management/mxbean/InvalidMXBeanRegistrationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/InvalidMXBeanRegistrationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Ensure the registration of an invalid MXBean
  *          throws NotCompliantMBeanException.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean InvalidMXBeanRegistrationTest
  * @run build InvalidMXBeanRegistrationTest
  * @run main InvalidMXBeanRegistrationTest
--- a/jdk/test/javax/management/mxbean/LeakTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/LeakTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,7 +25,7 @@
  * @bug 6482247
  * @summary Test that creating MXBeans does not introduce memory leaks.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run build LeakTest RandomMXBeanTest MerlinMXBean TigerMXBean
  * @run main LeakTest
  */
--- a/jdk/test/javax/management/mxbean/MBeanOperationInfoTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/MBeanOperationInfoTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6359948
  * @summary Check that MXBean operations have the expected ReturnType in MBeanOperationInfo
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean MBeanOperationInfoTest
  * @run build MBeanOperationInfoTest
  * @run main MBeanOperationInfoTest
--- a/jdk/test/javax/management/mxbean/MXBeanAnnotationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/MXBeanAnnotationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6316491
  * @summary Check that the MXBean annotation works as advertised
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean MXBeanAnnotationTest
  * @run build MXBeanAnnotationTest
  * @run main MXBeanAnnotationTest
--- a/jdk/test/javax/management/mxbean/MXBeanFallbackTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/MXBeanFallbackTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  *          It needs to be a separate class because the "jdk.jmx.mbeans.allowNonPublic"
  *          system property must be set before c.s.j.m.MBeanAnalyzer has been loaded.
  * @author Jaroslav Bachorik
- * @modules java.management
+ *
  * @run clean MXBeanFallbackTest
  * @run build MXBeanFallbackTest
  * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true MXBeanFallbackTest
--- a/jdk/test/javax/management/mxbean/MXBeanFlagTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/MXBeanFlagTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6335337
  * @summary Test correctness of mxbean flag in descriptor.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean MXBeanFlagTest
  * @run build MXBeanFlagTest
  * @run main MXBeanFlagTest
--- a/jdk/test/javax/management/mxbean/MXBeanLoadingTest1.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/MXBeanLoadingTest1.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,8 +26,9 @@
  * @bug 8058865
  * @summary Checks correct collection of MXBean's class after unregistration
  * @author Olivier Lagneau
- * @modules java.management
+ *
  * @library /lib/testlibrary
+ *
  * @run main/othervm/timeout=300 MXBeanLoadingTest1
  */
 
--- a/jdk/test/javax/management/mxbean/MXBeanPreRegisterTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/MXBeanPreRegisterTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Ensure that preRegister etc are called, but not when wrapped
  * by the class StandardMBean
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean MXBeanPreRegisterTest
  * @run build MXBeanPreRegisterTest
  * @run main MXBeanPreRegisterTest
--- a/jdk/test/javax/management/mxbean/MXBeanRefTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/MXBeanRefTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6296433 6283873
  * @summary Test that inter-MXBean references work as expected.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean MXBeanRefTest
  * @run build MXBeanRefTest
  * @run main MXBeanRefTest
--- a/jdk/test/javax/management/mxbean/MiscTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/MiscTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  *          interfaceClassName, openType, originalType, StandardMBean,
  *          StandardEmitterMBean.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean MiscTest
  * @run build MiscTest
  * @run main MiscTest
--- a/jdk/test/javax/management/mxbean/OperationImpactTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/OperationImpactTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6320104
  * @summary Check that MXBean operations have impact UNKNOWN.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean OperationImpactTest
  * @run build OperationImpactTest
  * @run main OperationImpactTest
--- a/jdk/test/javax/management/mxbean/OverloadTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/OverloadTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6175517
  * @summary Test that MXBean interfaces can contain overloaded methods
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean OverloadTest
  * @run build OverloadTest
  * @run main OverloadTest
--- a/jdk/test/javax/management/mxbean/PreRegisterNameTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/PreRegisterNameTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6448042
  * @summary Test that MXBeans can define their own names in preRegister
  * @author Eamonn McManus
- * @modules java.management
  */
 
 import java.lang.management.ManagementFactory;
--- a/jdk/test/javax/management/mxbean/PropertyNamesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/PropertyNamesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6175517
  * @summary Test the PropertyNames annotation with MXBeans
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean PropertyNamesTest
  * @run build PropertyNamesTest
  * @run main PropertyNamesTest
--- a/jdk/test/javax/management/mxbean/SameObjectTwoNamesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/SameObjectTwoNamesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  * names produces an exception
  * @author Alexander Shusherov
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run main SameObjectTwoNamesTest
  * @run main/othervm -Djmx.mxbean.multiname=true SameObjectTwoNamesTest
  */
--- a/jdk/test/javax/management/mxbean/StandardMBeanOverrideTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/StandardMBeanOverrideTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,7 @@
  *          getMBeanInfo and getNotificationInfo in StandardMBean and
  *          StandardEmitterMBean.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean StandardMBeanOverrideTest
  * @run build StandardMBeanOverrideTest
  * @run main StandardMBeanOverrideTest
--- a/jdk/test/javax/management/mxbean/ThreadMXBeanTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/ThreadMXBeanTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,13 +24,13 @@
 /*
  * @test
  * @bug 6305746
+ * @key randomness
  * @summary Test that the null values returned by the ThreadMXBean work.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ThreadMXBeanTest
  * @run build ThreadMXBeanTest
  * @run main ThreadMXBeanTest
- * @key randomness
  */
 
 import java.lang.management.*;
--- a/jdk/test/javax/management/mxbean/TypeNameTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/mxbean/TypeNameTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6757225 6763051
  * @summary Test that type names in MXBeans match their spec.
  * @author Eamonn McManus
- * @modules java.management
  */
 
 import java.lang.reflect.Field;
--- a/jdk/test/javax/management/notification/BroadcasterSupportDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/notification/BroadcasterSupportDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that NotificationBroadcasterSupport can be subclassed
  * and used with synchronized(this) without causing deadlock
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean BroadcasterSupportDeadlockTest
  * @run build BroadcasterSupportDeadlockTest
  * @run main BroadcasterSupportDeadlockTest
--- a/jdk/test/javax/management/notification/FilterExceptionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/notification/FilterExceptionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6244855 6244863
  * @summary Exception thrown by NotificationFilter should be ignored
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean FilterExceptionTest
  * @run build FilterExceptionTest
  * @run main FilterExceptionTest
--- a/jdk/test/javax/management/notification/NotifExecutorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/notification/NotifExecutorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4661545
  * @summary Tests to use an executor to send notifications.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean NotifExecutorTest
  * @run build NotifExecutorTest
  * @run main NotifExecutorTest
--- a/jdk/test/javax/management/notification/NotifInfoTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/notification/NotifInfoTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4506105 6303698
  * @summary NotificationBroadcasterSupport should have a ctor with MBeanNotificationInfo[]
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean NotifInfoTest
  * @run build NotifInfoTest
  * @run main NotifInfoTest
--- a/jdk/test/javax/management/openmbean/ArrayTypeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/ArrayTypeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5045358
  * @summary Test that Open MBeans support arrays of primitive types.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean ArrayTypeTest
  * @run build ArrayTypeTest
  * @run main ArrayTypeTest
--- a/jdk/test/javax/management/openmbean/BadConstraintTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/BadConstraintTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that Open MBean attributes and parameters cannot have
  * illegal constraints like min greater than max
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean BadConstraintTest
  * @run build BadConstraintTest
  * @run main BadConstraintTest
--- a/jdk/test/javax/management/openmbean/CompositeDataStringTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/CompositeDataStringTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6610174
  * @summary Test that CompositeDataSupport.toString() represents arrays correctly
  * @author Eamonn McManus
- * @modules java.management
  */
 
 import javax.management.openmbean.ArrayType;
--- a/jdk/test/javax/management/openmbean/ConstraintTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/ConstraintTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6204469
  * @summary Test that Open MBean attributes and parameters check constraints
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ConstraintTest
  * @run build ConstraintTest
  * @run main ConstraintTest
--- a/jdk/test/javax/management/openmbean/EqualsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/EqualsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5072174
  * @summary Test CompositeDataSupport.equals with ArrayType
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean EqualsTest
  * @run build EqualsTest
  * @run main EqualsTest
--- a/jdk/test/javax/management/openmbean/IsValueTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/IsValueTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 5072004
  * @summary Test new rules for isValue
  * @author Eamonn McManus
- * @modules java.management
  */
 
 import javax.management.openmbean.*;
--- a/jdk/test/javax/management/openmbean/NullConstructorParamsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/NullConstructorParamsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6434298
  * @summary Test IAE is thrown when typeName or description parameter is null for TabularType and CompositeType constructors
  * @author Joel FERAUD
- * @modules java.management
  */
 
 import javax.management.openmbean.*;
--- a/jdk/test/javax/management/openmbean/OpenMBeanInfoEqualsNPETest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/OpenMBeanInfoEqualsNPETest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -41,7 +41,7 @@
  * @bug 8023529
  * @summary Test that OpenMBean*Info.equals do not throw NPE
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean OpenMBeanInfoEqualsNPETest
  * @run build OpenMBeanInfoEqualsNPETest
  * @run main OpenMBeanInfoEqualsNPETest
--- a/jdk/test/javax/management/openmbean/OpenMBeanInfoHashCodeNPETest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/OpenMBeanInfoHashCodeNPETest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -40,7 +40,7 @@
  * @bug 8023529
  * @summary Test that OpenMBean*Info.hashCode do not throw NPE
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean OpenMBeanInfoHashCodeNPETest
  * @run build OpenMBeanInfoHashCodeNPETest
  * @run main OpenMBeanInfoHashCodeNPETest
--- a/jdk/test/javax/management/openmbean/OpenTypeDescriptorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/openmbean/OpenTypeDescriptorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  * @summary Test that Open*MBeanInfo classes include "openType" in descriptor
  *          and also test serial compatibility with Java 5.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean OpenTypeDescriptorTest
  * @run build OpenTypeDescriptorTest
  * @run main OpenTypeDescriptorTest
--- a/jdk/test/javax/management/proxy/JMXProxyFallbackTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/proxy/JMXProxyFallbackTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,7 +34,7 @@
  *          It needs to be a separate class because the "jdk.jmx.mbeans.allowNonPublic"
  *          system property must be set before c.s.j.m.MBeanAnalyzer has been loaded.
  * @author Jaroslav Bachorik
- * @modules java.management
+ *
  * @run clean JMXProxyFallbackTest
  * @run build JMXProxyFallbackTest
  * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true JMXProxyFallbackTest
--- a/jdk/test/javax/management/proxy/JMXProxyTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/proxy/JMXProxyTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -33,7 +33,7 @@
  * @summary Tests that javax.management.JMX creates proxies only for the
  *          compliant MBeans/MXBeans
  * @author Jaroslav Bachorik
- * @modules java.management
+ *
  * @run clean JMXProxyTest
  * @run build JMXProxyTest
  * @run main JMXProxyTest
--- a/jdk/test/javax/management/proxy/NotificationEmitterProxy.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/proxy/NotificationEmitterProxy.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @summary Test that we can create proxies which are NotificationEmitters.
  * @bug 6411747
  * @author Daniel Fuchs
- * @modules java.management
+ *
  * @run clean NotificationEmitterProxy
  * @run build NotificationEmitterProxy
  * @run main NotificationEmitterProxy
--- a/jdk/test/javax/management/proxy/ProxyObjectMethodsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/proxy/ProxyObjectMethodsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6177524
  * @summary Test how to execute the 3 Object methods by a Proxy.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean ProxyObjectMethodsTest
  * @run build ProxyObjectMethodsTest
  * @run main ProxyObjectMethodsTest
--- a/jdk/test/javax/management/query/CustomQueryTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/query/CustomQueryTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6692027
  * @summary Check that custom subclasses of QueryEval can be serialized.
  * @author Eamonn McManus
- * @modules java.management
  */
 
 import java.io.ByteArrayInputStream;
--- a/jdk/test/javax/management/query/InstanceOfExpTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/query/InstanceOfExpTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5072174 6335848
  * @summary test the new method javax.management.Query.isInstanceOf("className")
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean InstanceOfExpTest
  * @run build InstanceOfExpTest
  * @run main InstanceOfExpTest
--- a/jdk/test/javax/management/query/QueryExpStringTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/query/QueryExpStringTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4886011
  * @summary Test that QueryExp.toString() is reversible
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean QueryExpStringTest
  * @run build QueryExpStringTest
  * @run main QueryExpStringTest
--- a/jdk/test/javax/management/query/QueryMatchTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/query/QueryMatchTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6266438
  * @summary Query.match code for character sequences like [a-z] is wrong.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean QueryMatchTest
  * @run build QueryMatchTest
  * @run main QueryMatchTest
--- a/jdk/test/javax/management/query/QuerySubstringTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/query/QuerySubstringTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Query.{initial,any,final}SubString fail if the
  *          matching constraint string contains wildcards.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean QuerySubstringTest
  * @run build QuerySubstringTest
  * @run main QuerySubstringTest
--- a/jdk/test/javax/management/relation/NonArrayListTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/relation/NonArrayListTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4848474
  * @summary Test that relation service doesn't require List params to be ArrayList
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean NonArrayListTest
  * @run build NonArrayListTest
  * @run main NonArrayListTest
--- a/jdk/test/javax/management/relation/RelationNotificationSeqNoTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/relation/RelationNotificationSeqNoTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6701459
  * @summary Test sequence numbers in RelationService notifications.
  * @author Eamonn McManus
- * @modules java.management
  */
 
 /*
--- a/jdk/test/javax/management/relation/RelationNotificationSourceTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/relation/RelationNotificationSourceTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4892674
  * @summary Test that RelationNotification can be constructed with ObjectName.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean RelationNotificationSourceTest
  * @run build RelationNotificationSourceTest
  * @run main RelationNotificationSourceTest
--- a/jdk/test/javax/management/relation/RelationTypeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/relation/RelationTypeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4716675
  * @summary Test that relation type checking uses isInstanceOf
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean RelationTypeTest
  * @run build RelationTypeTest
  * @run main RelationTypeTest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/remote/mandatory/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = java.management.rmi
+
--- a/jdk/test/javax/management/remote/mandatory/URLTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/URLTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5057532
  * @summary Tests that host names are parsed correctly in URLs
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean URLTest
  * @run build URLTest
  * @run main URLTest
--- a/jdk/test/javax/management/remote/mandatory/connection/AddressableTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/AddressableTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6238815
  * @summary test the new interface Addressable
  * @author Shanliang JIANG
- * @modules java.management.rmi
+ *
  * @run clean AddressableTest
  * @run build AddressableTest
  * @run main AddressableTest
--- a/jdk/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,10 +24,10 @@
 /*
  * @test
  * @bug 4940957 8025205
+ * @key intermittent
  * @summary Tests behaviour when connections break
  * @author Eamonn McManus
- * @key intermittent
- * @modules java.management.rmi
+ *
  * @run clean BrokenConnectionTest
  * @run build BrokenConnectionTest
  * @run main BrokenConnectionTest
--- a/jdk/test/javax/management/remote/mandatory/connection/CloseFailedClientTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/CloseFailedClientTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4921888
  * @summary Tests that we do not get a NullPointException.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean CloseFailedClientTest
  * @run build CloseFailedClientTest
  * @run main CloseFailedClientTest
--- a/jdk/test/javax/management/remote/mandatory/connection/CloseServerTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/CloseServerTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4838640
  * @summary test server close in different conditions.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean CloseServerTest
  * @run build CloseServerTest
  * @run main CloseServerTest
--- a/jdk/test/javax/management/remote/mandatory/connection/CloseUnconnectedTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/CloseUnconnectedTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4897052
  * @summary Tests that opening and immediately closing a connector works
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean CloseUnconnectedTest
  * @run build CloseUnconnectedTest
  * @run main CloseUnconnectedTest
--- a/jdk/test/javax/management/remote/mandatory/connection/CloseableTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/CloseableTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  *          the method "void close() throws IOException;" extend
  *          or implement the java.io.Closeable interface.
  * @author Luis-Miguel Alventosa
- * @modules java.management.rmi
+ *
  * @run clean CloseableTest
  * @run build CloseableTest
  * @run main CloseableTest
--- a/jdk/test/javax/management/remote/mandatory/connection/ConnectionListenerNullTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/ConnectionListenerNullTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4943248
  * @summary Tests that NullPointerException is thrown when listener is null.
  * @author Daniel Fuchs
- * @modules java.management.rmi
+ *
  * @run clean ConnectionListenerNullTest
  * @run build ConnectionListenerNullTest
  * @run main ConnectionListenerNullTest
--- a/jdk/test/javax/management/remote/mandatory/connection/ConnectionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/ConnectionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4865397
  * @summary Tests remote JMX connections
  * @author Eamonn McManus
- * @modules java.management.rmi
+ *
  * @run clean ConnectionTest
  * @run build ConnectionTest
  * @run main ConnectionTest
--- a/jdk/test/javax/management/remote/mandatory/connection/DaemonRMIExporterTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/DaemonRMIExporterTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,7 +28,7 @@
  * @summary test the connector server option that causes it not to prevent the
  * VM from exiting
  * @author Shanliang JIANG, Eamonn McManus
- * @modules java.management.rmi
+ *
  * @run main/othervm DaemonRMIExporterTest
  */
 import java.util.Arrays;
--- a/jdk/test/javax/management/remote/mandatory/connection/DeadLockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/DeadLockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5039210
  * @summary test on a client notification deadlock.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean DeadLockTest
  * @run build DeadLockTest
  * @run main DeadLockTest
--- a/jdk/test/javax/management/remote/mandatory/connection/FailedConnectionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/FailedConnectionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 4939578
  * @summary test to get an IOException.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean FailedConnectionTest
  * @run build FailedConnectionTest
  * @run main FailedConnectionTest
--- a/jdk/test/javax/management/remote/mandatory/connection/GetConnectionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/GetConnectionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4951414
  * @summary Try to get an IOException.
  * @author Shanliang JIANG
- * @modules java.management.rmi
+ *
  * @run clean GetConnectionTest
  * @run build GetConnectionTest
  * @run main GetConnectionTest
--- a/jdk/test/javax/management/remote/mandatory/connection/IIOPURLTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/IIOPURLTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4886799
  * @summary Check that IIOP URLs have /ior/ in the path
  * @author Eamonn McManus
- * @modules java.management.rmi
+ *
  * @run clean IIOPURLTest
  * @run build IIOPURLTest
  * @run main IIOPURLTest
--- a/jdk/test/javax/management/remote/mandatory/connection/JMXServiceURLLocaleTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/JMXServiceURLLocaleTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 7065236
  * @summary Test for locale insensitive strings in JMXServiceURL class
  * @author Harsha Wardhana B
- * @modules java.management
+ *
  * @run clean JMXServiceURLLocaleTest
  * @run build JMXServiceURLLocaleTest
  * @run main JMXServiceURLLocaleTest
--- a/jdk/test/javax/management/remote/mandatory/connection/MultiOpenCloseTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/MultiOpenCloseTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 1234567
  * @summary Open, connect then close multi-connectors.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean MultiOpenCloseTest
  * @run build MultiOpenCloseTest
  * @run main MultiOpenCloseTest
--- a/jdk/test/javax/management/remote/mandatory/connection/MultiThreadDeadLockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/MultiThreadDeadLockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -45,7 +45,7 @@
  * @bug 6697180
  * @summary test on a client notification deadlock.
  * @author Shanliang JIANG
- * @modules java.management.rmi
+ *
  * @run clean MultiThreadDeadLockTest
  * @run build MultiThreadDeadLockTest
  * @run main MultiThreadDeadLockTest
--- a/jdk/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4901808 7183800
  * @summary Check that RMI connection ids include IP address of a client network interface
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean RMIConnectionIdTest
  * @run build RMIConnectionIdTest
  * @run main RMIConnectionIdTest
--- a/jdk/test/javax/management/remote/mandatory/connection/RMIConnectorLogAttributesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/RMIConnectorLogAttributesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -55,6 +55,9 @@
  * @bug 8147857
  * @summary Tests whether RMIConnector logs attribute names correctly.
  * @author Severin Gehwolf
+ *
+ * @modules java.logging
+ *          java.management.rmi
  */
 public class RMIConnectorLogAttributesTest {
 
--- a/jdk/test/javax/management/remote/mandatory/connection/RMIExitTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/RMIExitTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 4917237
  * @summary test that process exit immediately after stop() / close() called
  * @author Jean Francois Denise
- * @modules java.management.rmi
+ *
  * @run clean RMIExitTest
  * @run build RMIExitTest
  * @run main RMIExitTest
--- a/jdk/test/javax/management/remote/mandatory/connection/RMISerializeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/RMISerializeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @summary Tests to serialize RMIConnector
  * @bug 5032052
  * @author Shanliang JIANG
- * @modules java.management.rmi
+ *
  * @run clean RMISerializeTest
  * @run build RMISerializeTest
  * @run main RMISerializeTest
--- a/jdk/test/javax/management/remote/mandatory/connection/ReconnectTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connection/ReconnectTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4927217
  * @summary test to reconnect
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean ReconnectTest
  * @run build ReconnectTest
  * @run main ReconnectTest
--- a/jdk/test/javax/management/remote/mandatory/connectorServer/ConnectorStopDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connectorServer/ConnectorStopDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 6475157
  * @summary Tests deadlock in simultaneous connection and connector-server close
  * @author Eamonn McManus
- * @modules java.management.rmi
  */
 
 /* This test is somewhat dependent on implementation details.  If it suddenly
--- a/jdk/test/javax/management/remote/mandatory/connectorServer/JNDIFailureTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connectorServer/JNDIFailureTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Tests that JNDI bind failure doesn't leave an orphan RMI
  * Connector Server object
  * @author Eamonn McManus
- * @modules java.management.rmi
+ *
  * @run clean JNDIFailureTest
  * @run build JNDIFailureTest
  * @run main JNDIFailureTest
--- a/jdk/test/javax/management/remote/mandatory/connectorServer/MBSFPreStartPostStartTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/connectorServer/MBSFPreStartPostStartTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that setting an MBeanServerForwarder on an already
  *          started RMI connector server has the expected behavior.
  * @author Luis-Miguel Alventosa
- * @modules java.management.rmi
+ *
  * @run clean MBSFPreStartPostStartTest
  * @run build MBSFPreStartPostStartTest
  * @run main MBSFPreStartPostStartTest
--- a/jdk/test/javax/management/remote/mandatory/loading/DefaultProviderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/loading/DefaultProviderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4884913
  * @summary Tests that default protocols are loaded correctly
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean DefaultProviderTest
  * @run build DefaultProviderTest
  * @run main DefaultProviderTest
--- a/jdk/test/javax/management/remote/mandatory/loading/DeserializeEncodedURLTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/loading/DeserializeEncodedURLTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4924683
  * @summary Check RMI/JRMP stubs can be deserialized using user's loader
  * @author Eamonn McManus
- * @modules java.management.rmi
+ *
  * @run clean DeserializeEncodedURLTest SingleClassLoader
  * @run build DeserializeEncodedURLTest SingleClassLoader
  * @run main DeserializeEncodedURLTest
--- a/jdk/test/javax/management/remote/mandatory/loading/MethodResultTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/loading/MethodResultTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,8 +26,9 @@
  * @bug 4898478
  * @summary Tests client default class loader used before JSR 160 loader
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @library /lib/testlibrary
+ *
  * @run clean MethodResultTest
  * @run build MethodResultTest
  * @run main MethodResultTest
--- a/jdk/test/javax/management/remote/mandatory/loading/MissingClassTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/loading/MissingClassTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,13 +24,13 @@
 /*
  * @test
  * @bug 4915825 4921009 4934965 4977469 8019584
+ * @key randomness
  * @summary Tests behavior when client or server gets object of unknown class
  * @author Eamonn McManus
- * @modules java.management.rmi
+ *
  * @run clean MissingClassTest SingleClassLoader
  * @run build MissingClassTest SingleClassLoader
  * @run main MissingClassTest
- * @key randomness
  */
 
 /*
--- a/jdk/test/javax/management/remote/mandatory/loading/RMIDownloadTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/loading/RMIDownloadTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 5021246
  * @summary Check that class downloading is supported by RMI connector
  * @author Eamonn McManus
- * @modules java.management.rmi
+ *
  * @run main RMIDownloadTest receive without
  * @run main RMIDownloadTest send without
  * @run main RMIDownloadTest receive with
--- a/jdk/test/javax/management/remote/mandatory/loading/TargetMBeanTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/loading/TargetMBeanTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4910428
  * @summary Tests target MBean class loader used before JSR 160 loader
  * @author Eamonn McManus
- * @modules java.management.rmi
+ *
  * @run clean TargetMBeanTest
  * @run build TargetMBeanTest
  * @run main TargetMBeanTest
--- a/jdk/test/javax/management/remote/mandatory/loading/UserClassLoaderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/loading/UserClassLoaderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6356458
  * @summary test to not lose a user classloader
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean UserClassLoaderTest
  * @run build UserClassLoaderTest
  * @run main UserClassLoaderTest
--- a/jdk/test/javax/management/remote/mandatory/notif/AddRemoveTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/AddRemoveTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 4838640 4917194
  * @summary test on add/remove NotificationListener
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean AddRemoveTest
  * @run build AddRemoveTest
  * @run main AddRemoveTest
--- a/jdk/test/javax/management/remote/mandatory/notif/ConcurrentModificationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/ConcurrentModificationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 7120365
  * @summary test on Concurrent Modification
  * @author Shanliang JIANG
- * @modules java.management.rmi
+ *
  * @run main ConcurrentModificationTest
  */
 
--- a/jdk/test/javax/management/remote/mandatory/notif/DiffHBTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/DiffHBTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4911721
  * @summary test on add/remove NotificationListener
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean DiffHBTest
  * @run build DiffHBTest
  * @run main DiffHBTest
--- a/jdk/test/javax/management/remote/mandatory/notif/EmptyDomainNotificationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/EmptyDomainNotificationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Check that the expected notification is received by the JMX
  *          client even when the domain in the ObjectName is not specified
  * @author Shanliang JIANG
- * @modules java.management.rmi
+ *
  * @run clean EmptyDomainNotificationTest
  * @run build EmptyDomainNotificationTest
  * @run main EmptyDomainNotificationTest
--- a/jdk/test/javax/management/remote/mandatory/notif/ListenerScaleTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/ListenerScaleTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,9 +26,9 @@
  * @bug 6338874
  * @summary Check that notification dispatch is not linear in number of MBeans.
  * @author Eamonn McManus
- * @modules java.management.rmi
  *
  * @library /lib/testlibrary
+ *
  * @run build jdk.testlibrary.* ListenerScaleTest
  * @run main ListenerScaleTest
  */
--- a/jdk/test/javax/management/remote/mandatory/notif/NotSerializableNotifTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/NotSerializableNotifTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,10 +23,10 @@
 
 /*
  * @test
+ * @bug 5022196 8132003
  * @summary Tests to send a not serializable notification.
- * @bug 5022196 8132003
  * @author Shanliang JIANG
- * @modules java.management.rmi
+ *
  * @run clean NotSerializableNotifTest
  * @run build NotSerializableNotifTest
  * @run main NotSerializableNotifTest
--- a/jdk/test/javax/management/remote/mandatory/notif/NotifBufferSizePropertyNameTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/NotifBufferSizePropertyNameTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6174229
  * @summary Verify the property name specifying server notification buffer size.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean NotifBufferSizePropertyNameTest
  * @run build NotifBufferSizePropertyNameTest
  * @run main NotifBufferSizePropertyNameTest
--- a/jdk/test/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6199899
  * @summary Tests reconnection done by a fetching notif thread.
  * @author Shanliang JIANG
- * @modules java.management.rmi
+ *
  * @run clean NotifReconnectDeadlockTest
  * @run build NotifReconnectDeadlockTest
  * @run main NotifReconnectDeadlockTest
--- a/jdk/test/javax/management/remote/mandatory/notif/NotificationBufferCreationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/NotificationBufferCreationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 4934236
  * @summary Tests that NotificationBuffer is created when used.
  * @author jfd@...
- * @modules java.management.rmi
+ *
  * @run clean NotificationBufferCreationTest NotificationSender
  * @run build NotificationBufferCreationTest
  * @run main NotificationBufferCreationTest
--- a/jdk/test/javax/management/remote/mandatory/notif/NotificationBufferDeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/NotificationBufferDeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Tests NotificationBuffer doesn't hold locks when adding listeners,
  *  if test times out then deadlock is suspected.
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean NotificationBufferDeadlockTest
  * @run build NotificationBufferDeadlockTest
  * @run main NotificationBufferDeadlockTest
--- a/jdk/test/javax/management/remote/mandatory/notif/NotificationEmissionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/NotificationEmissionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,11 +24,11 @@
 /*
  * @test
  * @bug 5106721
+ * @key intermittent
  * @summary Check the emission of notifications when a Security Manager is
  * installed. Test the property "jmx.remote.x.check.notification.emission".
  * @author Luis-Miguel Alventosa
- * @key intermittent
- * @modules java.management.rmi
+ *
  * @run clean NotificationEmissionTest
  * @run build NotificationEmissionTest
  * @run main NotificationEmissionTest 1
--- a/jdk/test/javax/management/remote/mandatory/notif/RMINotifTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/RMINotifTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,9 +25,8 @@
  * @test
  * @bug 7654321
  * @summary Tests to receive notifications for opened and closed connections
-ions
  * @author sjiang
- * @modules java.management.rmi
+ *
  * @run clean RMINotifTest
  * @run build RMINotifTest
  * @run main RMINotifTest
--- a/jdk/test/javax/management/remote/mandatory/notif/ServerNotifs.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/ServerNotifs.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Tests the reception of the notifications for opened and closed
  * connections
  * @author sjiang
- * @modules java.management.rmi
+ *
  * @run clean ServerNotifs
  * @run build ServerNotifs
  * @run main ServerNotifs
--- a/jdk/test/javax/management/remote/mandatory/notif/UnexpectedNotifTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/UnexpectedNotifTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Tests whether a listener receives notifs emitted before the
  * listener is registered.
  * @author Shanliang JIANG
- * @modules java.management.rmi
+ *
  * @run clean UnexpectedNotifTest
  * @run build UnexpectedNotifTest
  * @run main UnexpectedNotifTest
--- a/jdk/test/javax/management/remote/mandatory/passwordAccessFile/NonJMXPrincipalsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/passwordAccessFile/NonJMXPrincipalsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Tests that MBeanServerFileAccessController supports
  *          principals other than JMXPrincipal.
  * @author Luis-Miguel Alventosa
- * @modules java.management.rmi
+ *
  * @run clean NonJMXPrincipalsTest SimpleStandard SimpleStandardMBean
  * @run build NonJMXPrincipalsTest SimpleStandard SimpleStandardMBean
  * @run main NonJMXPrincipalsTest
--- a/jdk/test/javax/management/remote/mandatory/passwordAccessFile/PasswordAccessFileTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/passwordAccessFile/PasswordAccessFileTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Tests the use of the "jmx.remote.x.password.file" and
  *          "jmx.remote.x.access.file" environment map properties.
  * @author Luis-Miguel Alventosa
- * @modules java.management.rmi
+ *
  * @run clean PasswordAccessFileTest SimpleStandard SimpleStandardMBean
  * @run build PasswordAccessFileTest SimpleStandard SimpleStandardMBean
  * @run main PasswordAccessFileTest
--- a/jdk/test/javax/management/remote/mandatory/provider/ProviderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/provider/ProviderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test ProviderTest.java
  * @summary Tests jar services provider are called
- * @modules java.management.rmi
+ *
  * @run clean ProviderTest provider.JMXConnectorProviderImpl provider.JMXConnectorServerProviderImpl
  * @run build ProviderTest provider.JMXConnectorProviderImpl provider.JMXConnectorServerProviderImpl
  * @run main ProviderTest
--- a/jdk/test/javax/management/remote/mandatory/socketFactories/RMISocketFactoriesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/socketFactories/RMISocketFactoriesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 7654321
  * @summary Tests the use of the custom RMI socket factories.
  * @author Luis-Miguel Alventosa
- * @modules java.management.rmi
+ *
  * @run clean RMISocketFactoriesTest
  * @run build RMISocketFactoriesTest RMIClientFactory RMIServerFactory
  * @run main RMISocketFactoriesTest test_server_factory
--- a/jdk/test/javax/management/remote/mandatory/threads/ExecutorShutdownTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/threads/ExecutorShutdownTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8141591
  * @summary Tests if notifications are received after executor is shutdown
  * @author Harsha Wardhana B
- * @modules java.management
+ *
  * @run clean ExecutorShutdownTest
  * @run build ExecutorShutdownTest
  * @run main ExecutorShutdownTest
--- a/jdk/test/javax/management/remote/mandatory/threads/ExecutorTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/threads/ExecutorTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6190873
  * @summary Tests that thread creation can use a user-supplied Executor
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean ExecutorTest
  * @run build ExecutorTest
  * @run main ExecutorTest
--- a/jdk/test/javax/management/remote/mandatory/threads/NoServerTimeoutTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/threads/NoServerTimeoutTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6192124
  * @summary Tests that you can turn off the server connection timeout thread
  * @author Eamonn McManus
- * @modules java.management
+ *
  * @run clean NoServerTimeoutTest
  * @run build NoServerTimeoutTest
  * @run main NoServerTimeoutTest
--- a/jdk/test/javax/management/remote/mandatory/version/ImplVersionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/remote/mandatory/version/ImplVersionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -29,7 +29,7 @@
  * test codebase has the java permission to read the "java.runtime.version"
  * system property.
  * @author Luis-Miguel Alventosa, Joel Feraud
- * @modules java.management
+ *
  * @run clean ImplVersionTest ImplVersionCommand
  * @run build ImplVersionTest ImplVersionCommand ImplVersionReader
  * @run main ImplVersionTest
--- a/jdk/test/javax/management/security/AvoidGetMBeanInfoCallsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/security/AvoidGetMBeanInfoCallsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Test that MBeanServer.queryNames doesn't call getMBeanInfo on every
  *          resultant MBean when there is no security manager installed.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean AvoidGetMBeanInfoCallsTest
  * @run build AvoidGetMBeanInfoCallsTest
  * @run main AvoidGetMBeanInfoCallsTest
--- a/jdk/test/javax/management/security/MBeanPermissionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/security/MBeanPermissionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6228749
  * @summary MBeanPermission(null,"") should throw IllegalArgumentException.
  * @author Luis-Miguel Alventosa
- * @modules java.management
+ *
  * @run clean MBeanPermissionTest
  * @run build MBeanPermissionTest
  * @run main MBeanPermissionTest
--- a/jdk/test/javax/management/standardmbean/DeadlockTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/standardmbean/DeadlockTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6331746
  * @summary Test a deadlock and will be blocked forever if the deadlock is present.
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run main DeadlockTest
  */
 
--- a/jdk/test/javax/management/timer/MissingNotificationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/timer/MissingNotificationTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,13 +24,13 @@
 /*
  * @test
  * @bug 6809322
+ * @key randomness
  * @summary Test for missing notifications in a high concurrency environment
  * @author Jaroslav Bachorik
- * @modules java.management
+ *
  * @run clean MissingNotificationTest
  * @run build MissingNotificationTest
  * @run main MissingNotificationTest
- * @key randomness
  */
 
 import java.util.Date;
--- a/jdk/test/javax/management/timer/StartTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/management/timer/StartTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6659215
  * @summary Test on timer start method with past notifications
  * @author Shanliang JIANG
- * @modules java.management
+ *
  * @run clean StartTest
  * @run build StartTest
  * @run main StartTest
--- a/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java	Wed Jul 05 23:09:40 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/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.java	Wed Jul 05 23:09:40 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 @@
 /*
  * @test
  * @bug 8050409
+ * @modules jdk.security.auth
  * @summary Tests with Subject.getPrivateCredentials to check permission checks with one or more principals.
  * @run testng/othervm/policy=MoreThenOnePrincipals.policy MoreThenOnePrincipals
  */
--- a/jdk/test/javax/security/auth/PrivateCredentialPermission/Subset.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/auth/PrivateCredentialPermission/Subset.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, 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
@@ -25,11 +25,15 @@
  * @test
  * @author  Ram Marti
  * @bug 4326852
+ * @modules jdk.security.auth
  * @summary Retrive a subset of private credentials can be accessed
  * @run main/othervm/policy=Subset.policy Subset
  */
 
-import java.util.*;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
 import com.sun.security.auth.SolarisPrincipal;
 import javax.security.auth.Subject;
 
--- a/jdk/test/javax/security/auth/Subject/Serial.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/auth/Subject/Serial.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,19 @@
 /*
  * @test
  * @bug 4364826
+ * @modules jdk.security.auth
  * @summary     Subject serialized principal set is
  *              implementation-dependent class
  * @run main/othervm/policy=Serial.policy Serial
  */
 
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashSet;
+import java.util.Set;
 import javax.security.auth.Subject;
-import java.io.*;
-import java.util.*;
 
 public class Serial implements java.io.Serializable {
 
--- a/jdk/test/javax/security/auth/SubjectDomainCombiner/Regression.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/auth/SubjectDomainCombiner/Regression.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,18 +24,20 @@
 /*
  * @test
  * @bug 4390546
+ * @modules jdk.security.auth
  * @summary     performance regression and other bugs in
  *              SubjectDomainCombiner.combine
  *
  * @run main/othervm/policy=Regression.policy -Djava.security.auth.debug=combiner Regression
  */
 
-import javax.security.auth.*;
 import java.security.ProtectionDomain;
 import java.security.CodeSource;
 import java.net.URL;
 import java.util.Set;
 import java.util.HashSet;
+import javax.security.auth.Subject;
+import javax.security.auth.SubjectDomainCombiner;
 
 public class Regression {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/kerberos/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,1 @@
+modules = java.security.jgss
--- a/jdk/test/javax/security/auth/login/Configuration/GetInstance.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/auth/login/Configuration/GetInstance.java	Wed Jul 05 23:09:40 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
@@ -25,16 +25,21 @@
  * @test
  * @bug 6268315
  * @bug 6273812
+ * @modules jdk.security.auth
  * @summary Configuration should be provider-based
  * @build GetInstanceConfigSpi GetInstanceProvider
  * @run main/othervm -Djava.security.auth.login.config==${test.src}${/}GetInstance.config GetInstance
  */
 
-import javax.security.auth.login.*;
-
-import java.security.*;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.URIParameter;
 import java.io.File;
 import java.net.URI;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
 
 public class GetInstance {
 
--- a/jdk/test/javax/security/auth/login/Configuration/GetInstanceSecurity.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/auth/login/Configuration/GetInstanceSecurity.java	Wed Jul 05 23:09:40 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,6 +24,7 @@
 /*
  * @test
  * @bug 6268315
+ * @modules jdk.security.auth
  * @summary Configuration should be provider-based
  * @build GetInstanceConfigSpi GetInstanceProvider
  * @run main/othervm/policy=GetInstanceSecurity.policy GetInstanceSecurity
@@ -31,8 +32,10 @@
 
 import java.io.File;
 import java.net.URI;
-import java.security.*;
-import javax.security.auth.login.*;
+import java.security.Policy;
+import java.security.Security;
+import java.security.URIParameter;
+import javax.security.auth.login.Configuration;
 
 public class GetInstanceSecurity {
 
--- a/jdk/test/javax/security/auth/login/LoginContext/ConfigConstructor.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/auth/login/LoginContext/ConfigConstructor.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, 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
@@ -21,9 +21,10 @@
  * questions.
  */
 
-/**
+/*
  * @test
  * @bug 4703361
+ * @modules jdk.security.auth
  * @summary can not specify Configuration to LoginContext constructor
  *
  * @run main/othervm/policy=ConfigConstructor.policy -Djava.security.auth.login.config=file:${test.src}/ConfigConstructor.config ConfigConstructor
@@ -37,10 +38,13 @@
  */
 
 import java.util.Map;
-import javax.security.auth.*;
-import javax.security.auth.login.*;
-import javax.security.auth.spi.*;
-import javax.security.auth.callback.*;
+import javax.security.auth.Subject;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+import javax.security.auth.callback.CallbackHandler;
 
 public class ConfigConstructor {
 
--- a/jdk/test/javax/security/auth/login/LoginContext/ConfigConstructorNoPerm.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/auth/login/LoginContext/ConfigConstructorNoPerm.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 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
@@ -21,9 +21,10 @@
  * questions.
  */
 
-/**
+/*
  * @test
  * @bug 4703361
+ * @modules jdk.security.auth
  * @summary can not specify Configuration to LoginContext constructor
  *
  * @run main/othervm/policy=ConfigConstructorNoPerm.policy -Djava.security.auth.login.config=file:${test.src}/ConfigConstructor.config ConfigConstructorNoPerm
@@ -36,10 +37,11 @@
  */
 
 import java.util.Map;
-import javax.security.auth.*;
-import javax.security.auth.login.*;
-import javax.security.auth.spi.*;
-import javax.security.auth.callback.*;
+import javax.security.auth.Subject;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.callback.CallbackHandler;
 
 public class ConfigConstructorNoPerm {
 
--- a/jdk/test/javax/security/auth/login/LoginContext/ModuleSubject.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/auth/login/LoginContext/ModuleSubject.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2001, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 4378100
+ * @modules jdk.security.auth
  * @summary LoginContext doesn't reinit modules with new Subject
  *      if authentication fails
  *
@@ -31,9 +32,9 @@
  * @run main/othervm -Djava.security.auth.login.config=file:${test.src}/ModuleSubject.config ModuleSubject
  */
 
-import javax.security.auth.*;
-import javax.security.auth.login.*;
 import java.security.Principal;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
 
 public class ModuleSubject {
 
--- a/jdk/test/javax/security/sasl/Sasl/PassSysProps.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/security/sasl/Sasl/PassSysProps.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, 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,10 +21,11 @@
  * questions.
  */
 
-/**
+/*
  * @test
  * @author Vincent Ryan
  * @bug 6228412
+ * @modules java.security.sasl
  * @summary Check that a Properties object can be passed to the Sasl create
  *          client and create server methods.
  */
@@ -32,8 +33,12 @@
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
-import javax.security.sasl.*;
-import javax.security.auth.callback.*;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
 import org.ietf.jgss.GSSException;
 
 public class PassSysProps {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,87 @@
+/*
+ * 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.awt.Color;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+/**
+ * @test
+ * @bug 8175301
+ * @summary Java GUI hangs on Windows when Display set to 125%
+ * @run main/othervm -Dsun.java2d.uiScale=2 ScaledFrameBackgroundTest
+ * @run main/othervm -Dsun.java2d.uiScale=2 -Dsun.java2d.d3d=true ScaledFrameBackgroundTest
+ * @run main/othervm -Dsun.java2d.uiScale=2 -Dsun.java2d.opengl=true ScaledFrameBackgroundTest
+ */
+public class ScaledFrameBackgroundTest {
+
+    private static final Color BACKGROUND = Color.RED;
+    private static JFrame frame;
+
+    public static void main(String[] args) throws Exception {
+
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
+        SwingUtilities.invokeAndWait(() -> {
+            frame = new JFrame();
+            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+            frame.setSize(400, 300);
+            JPanel panel = new JPanel();
+            panel.setBackground(BACKGROUND);
+            frame.getContentPane().add(panel);
+            frame.setVisible(true);
+        });
+
+        robot.waitForIdle();
+        Thread.sleep(200);
+
+        Rectangle[] rects = new Rectangle[1];
+        SwingUtilities.invokeAndWait(() -> {
+            rects[0] = frame.getBounds();
+        });
+
+        Rectangle bounds = rects[0];
+
+        int x = bounds.x + bounds.width / 4;
+        int y = bounds.y + bounds.height / 4;
+
+        Color color = robot.getPixelColor(x, y);
+
+        if (!BACKGROUND.equals(color)) {
+            throw new RuntimeException("Wrong backgound color!");
+        }
+
+        x = bounds.x + 3 * bounds.width / 4;
+        y = bounds.y + 3 * bounds.height / 4;
+
+        color = robot.getPixelColor(x, y);
+
+        if (!BACKGROUND.equals(color)) {
+            throw new RuntimeException("Wrong backgound color!");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/SwingContainer/SwingContainerIsForContainerOnly/SwingContainerIsForContainerOnly.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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.awt.Container;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import javax.swing.SwingContainer;
+
+/**
+ * @test
+ * @bug 8176177
+ */
+public final class SwingContainerIsForContainerOnly {
+
+    public static void main(String[] args) throws IOException {
+        FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
+        fs.getFileStores();
+        Files.walkFileTree(fs.getPath("/modules/java.desktop"), new SimpleFileVisitor<>() {
+            @Override
+            public FileVisitResult visitFile(Path file,
+                                             BasicFileAttributes attrs) {
+                file = file.subpath(2, file.getNameCount());
+                String name = file.toString();
+                if (name.endsWith(".class")) {
+                    name = name.substring(0, name.indexOf(".")).replace('/', '.');
+
+                    final Class<?> type;
+                    try {
+                        type = Class.forName(name, false, null);
+                    } catch (Throwable e) {
+                        return FileVisitResult.CONTINUE;
+                    }
+                    if (type.isAnnotationPresent(SwingContainer.class)) {
+                        if (!Container.class.isAssignableFrom(type)) {
+                            System.err.println("Wrong annotation for: " + type);
+                            throw new RuntimeException();
+                        }
+                    }
+                }
+                return FileVisitResult.CONTINUE;
+            };
+        });
+    }
+}
--- a/jdk/test/javax/swing/plaf/basic/BasicComboPopup/7072653/bug7072653.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/swing/plaf/basic/BasicComboPopup/7072653/bug7072653.java	Wed Jul 05 23:09:40 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,77 +24,78 @@
 /*
  * @test
  * @key headful
- * @bug 7072653 8144161
+ * @bug 7072653 8144161 8176448
  * @summary JComboBox popup mispositioned if its height exceeds the screen height
  * @run main bug7072653
  */
+
 import java.awt.FlowLayout;
 import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
 import java.awt.Insets;
+import java.awt.Rectangle;
 import java.awt.Robot;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
 import java.awt.Toolkit;
 import java.awt.Window;
-import java.util.Arrays;
+
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.JComboBox;
 import javax.swing.JFrame;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
 
 public class bug7072653 {
 
     private static JComboBox combobox;
     private static JFrame frame;
     private static Robot robot;
-    private static volatile String errorString = "";
 
     public static void main(String[] args) throws Exception {
         robot = new Robot();
-        robot.delay(100);
-        UIManager.LookAndFeelInfo[] lookAndFeelArray
-                = UIManager.getInstalledLookAndFeels();
-        for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
-            executeCase(lookAndFeelItem.getClassName());
-            robot.delay(1000);
-        }
-        if (!"".equals(errorString)) {
-
-            throw new RuntimeException("Error Log:\n" + errorString);
+        GraphicsEnvironment ge =
+                GraphicsEnvironment.getLocalGraphicsEnvironment();
+        UIManager.LookAndFeelInfo[] lookAndFeelArray =
+                UIManager.getInstalledLookAndFeels();
+        for (GraphicsDevice sd : ge.getScreenDevices()) {
+            for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
+                executeCase(lookAndFeelItem.getClassName(), sd);
+                robot.waitForIdle();
+            }
         }
     }
 
-    private static void executeCase(String lookAndFeelString) throws Exception {
+    private static void executeCase(String lookAndFeelString, GraphicsDevice sd)
+            throws Exception {
         if (tryLookAndFeel(lookAndFeelString)) {
-            SwingUtilities.invokeAndWait(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        setup(lookAndFeelString);
-                        test();
-                    } catch (Exception ex) {
-                        errorString += "\n";
-                        errorString += Arrays.toString(ex.getStackTrace());
-                    }
-                    finally {
-                        frame.dispose();
-                    }
+            SwingUtilities.invokeAndWait(() -> {
+                try {
+                    setup(lookAndFeelString, sd);
+                    test();
+                } catch (Exception ex) {
+                    throw new RuntimeException(ex);
+                } finally {
+                    frame.dispose();
                 }
             });
         }
-
     }
 
-    private static void setup(String lookAndFeelString)
+    private static void setup(String lookAndFeelString, GraphicsDevice sd)
             throws Exception {
+        GraphicsConfiguration gc = sd.getDefaultConfiguration();
+        Rectangle gcBounds = gc.getBounds();
+        frame = new JFrame("JComboBox Test " + lookAndFeelString, gc);
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setSize(400, 200);
+        frame.getContentPane().setLayout(new FlowLayout());
+        frame.setLocation(
+                gcBounds.x + gcBounds.width / 2 - frame.getWidth() / 2,
+                gcBounds.y + gcBounds.height / 2 - frame.getHeight() / 2);
 
-        frame = new JFrame("JComboBox Test " + lookAndFeelString);
-        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-        frame.setSize(320, 200);
-        frame.getContentPane().setLayout(new FlowLayout());
-        frame.setLocationRelativeTo(null);
         combobox = new JComboBox(new DefaultComboBoxModel() {
             @Override
             public Object getElementAt(int index) {
@@ -108,6 +109,7 @@
         });
 
         combobox.setMaximumRowCount(100);
+        combobox.putClientProperty("JComboBox.isPopDown", true);
         frame.getContentPane().add(combobox);
         frame.setVisible(true);
         combobox.addPopupMenuListener(new PopupMenuListener() {
@@ -120,30 +122,24 @@
                 int height = 0;
                 for (Window window : JFrame.getWindows()) {
                     if (Window.Type.POPUP == window.getType()) {
-                        height = window.getSize().height;
-                        break;
+                        if (window.getOwner().isVisible()) {
+                            height = window.getSize().height;
+                            break;
+                        }
                     }
                 }
-                GraphicsConfiguration gc
-                        = combobox.getGraphicsConfiguration();
-                Insets screenInsets = Toolkit.getDefaultToolkit()
-                        .getScreenInsets(gc);
+                GraphicsConfiguration gc = combobox.getGraphicsConfiguration();
+                Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
                 int gcHeight = gc.getBounds().height;
-                if (lookAndFeelString.contains("aqua")) {
-                    gcHeight = gcHeight - screenInsets.top;
-                    //For Aqua LAF
-                } else {
-                    gcHeight = gcHeight - screenInsets.top
-                            - screenInsets.bottom;
-                }
+                gcHeight = gcHeight - insets.top - insets.bottom;
                 if (height == gcHeight) {
                     return;
                 }
 
                 String exception = "Popup window height "
                         + "For LookAndFeel" + lookAndFeelString + " is wrong"
-                        + "\nShould be " + height + "Actually " + gcHeight;
-                errorString += exception;
+                        + "\nShould be " + gcHeight + ", Actually " + height;
+                throw new RuntimeException(exception);
             }
 
             @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/basic/BasicComboPopup/JComboBoxPopupLocation/JComboBoxPopupLocation.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,166 @@
+/*
+ * 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.awt.EventQueue;
+import java.awt.FlowLayout;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.UIManager;
+
+/**
+ * @test
+ * @bug 8176448
+ * @run main/timeout=600 JComboBoxPopupLocation
+ */
+public final class JComboBoxPopupLocation {
+
+    private static final int SIZE = 300;
+    public static final String PROPERTY_NAME = "JComboBox.isPopDown";
+    private static volatile Robot robot;
+    private static volatile JComboBox<String> comboBox;
+    private static volatile JFrame frame;
+
+    public static void main(final String[] args) throws Exception {
+        robot = new Robot();
+        robot.setAutoDelay(100);
+        robot.setAutoWaitForIdle(true);
+        GraphicsEnvironment ge =
+                GraphicsEnvironment.getLocalGraphicsEnvironment();
+        GraphicsDevice[] sds = ge.getScreenDevices();
+        UIManager.LookAndFeelInfo[] lookAndFeelArray =
+                UIManager.getInstalledLookAndFeels();
+        for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
+            System.setProperty(PROPERTY_NAME, "true");
+            step(sds, lookAndFeelItem);
+            if (lookAndFeelItem.getClassName().contains("Aqua")) {
+                System.setProperty(PROPERTY_NAME, "false");
+                step(sds, lookAndFeelItem);
+            }
+        }
+    }
+
+    private static void step(GraphicsDevice[] sds,
+                             UIManager.LookAndFeelInfo lookAndFeelItem)
+            throws Exception {
+        UIManager.setLookAndFeel(lookAndFeelItem.getClassName());
+        Point left = null;
+        for (final GraphicsDevice sd : sds) {
+            GraphicsConfiguration gc = sd.getDefaultConfiguration();
+            Rectangle bounds = gc.getBounds();
+            if (left == null || left.x > bounds.x) {
+                left = new Point(bounds.x, bounds.y + bounds.height / 2);
+            }
+            Point point = new Point(bounds.x, bounds.y);
+            Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
+            while (point.y < bounds.y + bounds.height - insets.bottom - SIZE ) {
+                while (point.x < bounds.x + bounds.width - insets.right - SIZE) {
+                    try {
+                        EventQueue.invokeAndWait(() -> {
+                            setup(point);
+                        });
+                        robot.waitForIdle();
+                        test(comboBox);
+                        robot.waitForIdle();
+                        validate(comboBox);
+                        robot.waitForIdle();
+                        point.translate(bounds.width / 5, 0);
+                    } finally {
+                        dispose();
+                    }
+                }
+                point.setLocation(bounds.x, point.y + bounds.height / 5);
+            }
+        }
+        if (left != null) {
+            final Point finalLeft = left;
+            finalLeft.translate(-50, 0);
+            try {
+                EventQueue.invokeAndWait(() -> {
+                    setup(finalLeft);
+                });
+                robot.waitForIdle();
+                test(comboBox);
+                robot.waitForIdle();
+                validate(comboBox);
+            } finally {
+                dispose();
+            }
+        }
+    }
+
+    private static void dispose() throws Exception {
+        EventQueue.invokeAndWait(() -> {
+            if (frame != null) {
+                frame.dispose();
+            }
+        });
+    }
+
+    private static void setup(final Point tmp) {
+        comboBox = new JComboBox<>();
+        for (int i = 1; i < 7; i++) {
+            comboBox.addItem("Long-long-long-long-long text in the item-" + i);
+        }
+        String property = System.getProperty(PROPERTY_NAME);
+        comboBox.putClientProperty(PROPERTY_NAME, Boolean.valueOf(property));
+        frame = new JFrame();
+        frame.setAlwaysOnTop(true);
+        frame.setLayout(new FlowLayout());
+        frame.add(comboBox);
+        frame.pack();
+        frame.setSize(frame.getWidth(), SIZE);
+        frame.setVisible(true);
+        frame.setLocation(tmp.x, tmp.y);
+    }
+
+    private static void test(final JComboBox comboBox) throws Exception {
+        Point pt = comboBox.getLocationOnScreen();
+        robot.mouseMove(pt.x + comboBox.getWidth() / 2,
+                        pt.y + comboBox.getHeight() / 2);
+        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+        int x = pt.x + comboBox.getWidth() / 2;
+        int y = pt.y + comboBox.getHeight() / 2 + 70;
+        robot.mouseMove(x, y);
+        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+    }
+
+    private static void validate(final JComboBox comboBox) throws Exception {
+        EventQueue.invokeAndWait(() -> {
+            if (comboBox.getSelectedIndex() == 0) {
+                throw new RuntimeException();
+            }
+        });
+    }
+}
--- a/jdk/test/javax/swing/plaf/metal/MetalIcons/MetalHiDPIIconsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/javax/swing/plaf/metal/MetalIcons/MetalHiDPIIconsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8160986
+ * @bug 8160986 8174845 8176883
  * @summary Bad rendering of Swing UI controls with Metal L&F on HiDPI display
  * @run main/manual MetalHiDPIIconsTest
  */
@@ -56,6 +56,8 @@
             + "  - JCheckBox\n"
             + "  - JComboBox\n"
             + "  - JScrollPane (vertical and horizontal scroll bars)\n"
+            + "  - JRadioButtonMenuItem\n"
+            + "  - JCheckBoxMenuItem\n"
             + "and others...\n\n"
             + "If so, press PASS, else press FAIL.\n";
 
--- a/jdk/test/jdk/internal/jrtfs/java.policy	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/jdk/internal/jrtfs/java.policy	Wed Jul 05 23:09:40 2017 +0200
@@ -1,3 +1,3 @@
 grant {
-    permission java.io.FilePermission "${java.home}/-", "read";
+    permission java.lang.RuntimePermission "accessSystemModules";
 };
--- a/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java	Wed Jul 05 23:09:40 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 8144355 8144062
+ * @bug 8144355 8144062 8176709
  * @summary Test aliasing additions to ZipFileSystem for multi-release jar files
  * @library /lib/testlibrary/java/util/jar
  * @build Compiler JarBuilder CreateMultiReleaseTestJars
@@ -42,6 +42,7 @@
 import java.nio.file.*;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.testng.Assert;
 import org.testng.annotations.*;
@@ -50,6 +51,7 @@
     final private int MAJOR_VERSION = Runtime.version().major();
 
     final private String userdir = System.getProperty("user.dir",".");
+    final private CreateMultiReleaseTestJars creator =  new CreateMultiReleaseTestJars();
     final private Map<String,String> stringEnv = new HashMap<>();
     final private Map<String,Integer> integerEnv = new HashMap<>();
     final private Map<String,Version> versionEnv = new HashMap<>();
@@ -63,7 +65,6 @@
 
     @BeforeClass
     public void initialize() throws Exception {
-        CreateMultiReleaseTestJars creator =  new CreateMultiReleaseTestJars();
         creator.compileEntries();
         creator.buildUnversionedJar();
         creator.buildMultiReleaseJar();
@@ -187,6 +188,45 @@
         }
     }
 
+    @Test
+    public void testIsMultiReleaseJar() throws Exception {
+        // Re-examine commented out tests as part of JDK-8176843
+        testCustomMultiReleaseValue("true", true);
+        testCustomMultiReleaseValue("true\r\nOther: value", true);
+        testCustomMultiReleaseValue("true\nOther: value", true);
+        //testCustomMultiReleaseValue("true\rOther: value", true);
+
+        testCustomMultiReleaseValue("false", false);
+        testCustomMultiReleaseValue(" true", false);
+        testCustomMultiReleaseValue("true ", false);
+        //testCustomMultiReleaseValue("true\n ", false);
+        //testCustomMultiReleaseValue("true\r ", false);
+        //testCustomMultiReleaseValue("true\n true", false);
+        //testCustomMultiReleaseValue("true\r\n true", false);
+    }
+
+    private static final AtomicInteger JAR_COUNT = new AtomicInteger(0);
+
+    private void testCustomMultiReleaseValue(String value, boolean expected)
+            throws Exception {
+        String fileName = "custom-mr" + JAR_COUNT.incrementAndGet() + ".jar";
+        creator.buildCustomMultiReleaseJar(fileName, value, Map.of(),
+                /*addEntries*/true);
+
+        Map<String,String> env = Map.of("multi-release", "runtime");
+        Path filePath = Paths.get(userdir, fileName);
+        String ssp = filePath.toUri().toString();
+        URI customJar = new URI("jar", ssp , null);
+        try (FileSystem fs = FileSystems.newFileSystem(customJar, env)) {
+            if (expected) {
+                Assert.assertTrue(readAndCompare(fs, MAJOR_VERSION));
+            } else {
+                Assert.assertTrue(readAndCompare(fs, 8));
+            }
+        }
+        Files.delete(filePath);
+    }
+
     private static class ByteArrayClassLoader extends ClassLoader {
         final private FileSystem fs;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/ModuleTargetHelper.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.lang.module.ModuleReader;
+import java.lang.module.ModuleReference;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import jdk.internal.module.ClassFileConstants;
+import jdk.internal.module.ClassFileAttributes;
+import jdk.internal.module.ClassFileAttributes.ModuleTargetAttribute;
+import jdk.internal.org.objectweb.asm.Attribute;
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+
+public class ModuleTargetHelper {
+    private ModuleTargetHelper() {}
+
+    public static final class ModuleTarget {
+        private String osName, osArch;
+
+        public ModuleTarget(String osName, String osArch) {
+            this.osName = osName;
+            this.osArch = osArch;
+        }
+
+        public String osName() {
+            return osName;
+        }
+
+        public String osArch() {
+            return osArch;
+        }
+    }
+
+    public static ModuleTarget getJavaBaseTarget() throws IOException {
+        Path p = Paths.get(URI.create("jrt:/modules/java.base/module-info.class"));
+        try (InputStream in = Files.newInputStream(p)) {
+            return read(in);
+        }
+    }
+
+    public static ModuleTarget read(InputStream in) throws IOException {
+        ModuleTargetAttribute[] modTargets = new ModuleTargetAttribute[1];
+        ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
+            @Override
+            public void visitAttribute(Attribute attr) {
+                if (attr instanceof ModuleTargetAttribute) {
+                    modTargets[0] = (ModuleTargetAttribute)attr;
+                }
+            }
+        };
+
+        // prototype of attributes that should be parsed
+        Attribute[] attrs = new Attribute[] {
+            new ModuleTargetAttribute()
+        };
+
+        // parse module-info.class
+        ClassReader cr = new ClassReader(in);
+        cr.accept(cv, attrs, 0);
+        if (modTargets[0] != null) {
+            return new ModuleTarget(modTargets[0].osName(), modTargets[0].osArch());
+        }
+
+        return null;
+    }
+
+    public static ModuleTarget read(ModuleReference modRef) throws IOException {
+        ModuleReader reader = modRef.open();
+        try (InputStream in = reader.open("module-info.class").get()) {
+            return read(in);
+        } finally {
+            reader.close();
+        }
+    }
+}
--- a/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java	Wed Jul 05 23:09:40 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
@@ -109,9 +109,17 @@
 
     public void buildCustomMultiReleaseJar(String filename, String multiReleaseValue,
             Map<String, String> extraAttributes) throws IOException {
+        buildCustomMultiReleaseJar(filename, multiReleaseValue, extraAttributes, false);
+    }
+
+    public void buildCustomMultiReleaseJar(String filename, String multiReleaseValue,
+            Map<String, String> extraAttributes, boolean addEntries) throws IOException {
         JarBuilder jb = new JarBuilder(filename);
         extraAttributes.entrySet()
                 .forEach(entry -> jb.addAttribute(entry.getKey(), entry.getValue()));
+        if (addEntries) {
+            addEntries(jb);
+        }
         jb.addAttribute("Multi-Release", multiReleaseValue);
         jb.build();
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/jvmstat/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.internal.jvmstat/sun.jvmstat.monitor
+
--- a/jdk/test/sun/jvmstat/monitor/HostIdentifier/HostIdentifierCreate.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/jvmstat/monitor/HostIdentifier/HostIdentifierCreate.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,8 +24,10 @@
 /*
  * @test
  * @bug 4990825
- * @modules jdk.internal.jvmstat/sun.jvmstat.monitor
  * @summary test that HostIdentifier objects get created as expected
+ *
+ * @modules java.xml
+ *          jdk.internal.jvmstat/sun.jvmstat.monitor
  */
 
 import java.io.*;
--- a/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java	Wed Jul 05 23:09:40 2017 +0200
@@ -40,9 +40,10 @@
  * @test
  * @bug 6672135
  * @summary setInterval() for local MonitoredHost and local MonitoredVm
- * @modules jdk.internal.jvmstat/sun.jvmstat.monitor
+ *
  * @library /lib/testlibrary
  * @library /test/lib
+ *
  * @build jdk.testlibrary.*
  * @build jdk.test.lib.apps.*
  * @run main TestPollingInterval
--- a/jdk/test/sun/jvmstat/monitor/VmIdentifier/VmIdentifierCreateResolve.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/jvmstat/monitor/VmIdentifier/VmIdentifierCreateResolve.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,8 +24,10 @@
 /*
  * @test
  * @bug 4990825
- * @modules jdk.internal.jvmstat/sun.jvmstat.monitor
  * @summary test that VmIdentifier objects get created as expected
+ *
+ * @modules java.xml
+ *          jdk.internal.jvmstat/sun.jvmstat.monitor
  */
 
 import java.io.*;
--- a/jdk/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,9 +24,9 @@
 /*
  * @test
  * @bug 4990825
- * @modules jdk.internal.jvmstat/sun.jvmstat.monitor
+ * @summary prolog size and overflow sanity checks
+ *
  * @run main/othervm -XX:+UsePerfData PrologSizeSanityCheck
- * @summary prolog size and overflow sanity checks
  */
 
 import sun.jvmstat.monitor.*;
--- a/jdk/test/sun/management/HotspotClassLoadingMBean/GetClassInitializationTime.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotClassLoadingMBean/GetClassInitializationTime.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug     4858522
  * @summary Basic unit test of HotspotClassLoadingMBean.getClassInitializationTime()
  * @author  Steve Bohne
- * @modules java.management/sun.management
+ *
  * @run main/othervm -XX:+UsePerfData GetClassInitializationTime
  */
 
--- a/jdk/test/sun/management/HotspotClassLoadingMBean/GetClassLoadingTime.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotClassLoadingMBean/GetClassLoadingTime.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug     4858522
  * @summary Basic unit test of HotspotClassLoadingMBean.getClassLoadingTime()
  * @author  Steve Bohne
- * @modules java.management/sun.management
+ *
  * @build ClassToLoad0
  * @run main/othervm -XX:+UsePerfData GetClassLoadingTime
  */
--- a/jdk/test/sun/management/HotspotClassLoadingMBean/GetInitializedClassCount.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotClassLoadingMBean/GetInitializedClassCount.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug     4858522
  * @summary Basic unit test of HotspotClassLoadingMBean.getInitializedClassCount()
  * @author  Steve Bohne
- * @modules java.management/sun.management
+ *
  * @run main/othervm -XX:+UsePerfData GetInitializedClassCount
  */
 
--- a/jdk/test/sun/management/HotspotClassLoadingMBean/GetLoadedClassSize.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotClassLoadingMBean/GetLoadedClassSize.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug     4858522
  * @summary Basic unit test of HotspotClassLoadingMBean.getLoadedClassSize()
  * @author  Steve Bohne
- * @modules java.management/sun.management
+ *
  * @run main/othervm -XX:+UsePerfData GetLoadedClassSize
  */
 
--- a/jdk/test/sun/management/HotspotClassLoadingMBean/GetMethodDataSize.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotClassLoadingMBean/GetMethodDataSize.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug     4858522
  * @summary Basic unit test of HotspotClassLoadingMBean.getMethodDataSize()
  * @author  Steve Bohne
- * @modules java.management/sun.management
+ *
  * @run main/othervm -XX:+UsePerfData GetMethodDataSize
  */
 
--- a/jdk/test/sun/management/HotspotClassLoadingMBean/GetUnloadedClassSize.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotClassLoadingMBean/GetUnloadedClassSize.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug     4858522
  * @summary Basic unit test of HotspotClassLoadingMBean.getUnloadedClassSize()
  * @author  Steve Bohne
- * @modules java.management/sun.management
+ *
  * @run main/othervm -XX:+UsePerfData GetUnloadedClassSize
  */
 
--- a/jdk/test/sun/management/HotspotRuntimeMBean/GetSafepointCount.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotRuntimeMBean/GetSafepointCount.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug     4858522
  * @summary Basic unit test of HotspotClassLoadingMBean.getSafepointCount()
  * @author  Steve Bohne
- * @modules java.management/sun.management
+ *
  * @run main/othervm -XX:+UsePerfData GetSafepointCount
  */
 
--- a/jdk/test/sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,7 +26,7 @@
  * @bug     4858522
  * @summary Basic unit test of HotspotRuntimeMBean.getSafepointSyncTime()
  * @author  Steve Bohne
- * @modules java.management/sun.management
+ *
  * @run main/othervm -XX:+UsePerfData GetSafepointSyncTime
  */
 
--- a/jdk/test/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,8 +24,8 @@
 /*
  * @test
  * @bug     4858522
- * @modules java.management/sun.management
  * @summary Basic unit test of HotspotRuntimeMBean.getTotalSafepointTime()
+ *
  * @run main/othervm -XX:+UsePerfData GetTotalSafepointTime
  */
 
--- a/jdk/test/sun/management/HotspotThreadMBean/GetInternalThreads.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/HotspotThreadMBean/GetInternalThreads.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Basic Test for HotspotThreadMBean.getInternalThreadCount()
  *          and getInternalThreadCpuTime()
  * @author  Mandy Chung
- * @modules java.management/sun.management
+ *
  * @run main/othervm -XX:+UsePerfData GetInternalThreads
  */
 
--- a/jdk/test/sun/management/LazyCompositeDataTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/LazyCompositeDataTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -36,7 +36,6 @@
  * @test
  * @bug 8139870
  * @summary sun.management.LazyCompositeData.isTypeMatched() fails for composite types with items of ArrayType
- * @modules java.management/sun.management
  * @author Jaroslav Bachorik
  */
 
@@ -160,4 +159,5 @@
         }
         System.out.println("=== PASSED");
     }
-}
\ No newline at end of file
+}
+
--- a/jdk/test/sun/management/LoggingTest/LoggingWithJULTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/LoggingTest/LoggingWithJULTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,11 +26,14 @@
 /**
  * @test
  * @bug 8172971
- * @modules java.management java.logging
  * @summary Smoke test to check that logging in java.management works as expected.
+ * @author danielfuchs
+ *
+ * @modules java.management
+ *          java.logging
+ *
  * @build LoggingTest LoggingWithJULTest
  * @run main/othervm LoggingWithJULTest
- * @author danielfuchs
  */
 public class LoggingWithJULTest {
 
--- a/jdk/test/sun/management/LoggingTest/LoggingWithLoggerFinderTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/LoggingTest/LoggingWithLoggerFinderTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -24,13 +24,13 @@
 /**
  * @test
  * @bug 8172971
- * @modules java.management
  * @summary Smoke test to check that logging in java.management is performed
  *          through System.Logger. This test installs a LoggerFinder service
  *          provider and verifies that it gets the traces.
+ * @author danielfuchs
+ *
  * @build test.loggerfinder/test.loggerfinder.TestLoggerFinder LoggingTest LoggingWithLoggerFinderTest
  * @run main/othervm --add-modules test.loggerfinder LoggingWithLoggerFinderTest
- * @author danielfuchs
  */
 public class LoggingWithLoggerFinderTest {
 
--- a/jdk/test/sun/management/StackTraceElementCompositeData/CompatibilityTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/StackTraceElementCompositeData/CompatibilityTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -15,9 +15,9 @@
  * @test
  * @bug     8139587
  * @summary Check backward compatibility of StackTraceElementCompositeData
- * @modules java.management/sun.management
+ * @author  Jaroslav Bachorik
+ *
  * @run testng CompatibilityTest
- * @author  Jaroslav Bachorik
  */
 
 public class CompatibilityTest {
@@ -69,4 +69,5 @@
         assertNull(ste.getModuleName());
         assertNull(ste.getModuleVersion());
     }
-}
\ No newline at end of file
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = java.management/sun.management
+
--- a/jdk/test/sun/management/jdp/JdpDefaultsTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jdp/JdpDefaultsTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,8 +30,9 @@
 /*
  * @test JdpDefaultsTest
  * @summary Assert that we can read JDP packets from a multicast socket connection, on default IP and port.
+ *
  * @library /lib/testlibrary
- * @modules jdk.management.agent/sun.management.jdp
+ *
  * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
  * @run main/othervm JdpDefaultsTest
  */
--- a/jdk/test/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,14 +22,15 @@
  */
 
 /**
- *  @test JdpJmxRemoteDynamicPortTest.java
- *  @bug 8167337
- *  @summary Verify a non-zero value is assigned to jmxremote.port
- *           when VM is started with jmxremote.port=0.
- *  @library /lib/testlibrary
- *  @modules jdk.management.agent/sun.management.jdp
- *  @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpJmxRemoteDynamicPortTestCase DynamicLauncher
- *  @run main/othervm JdpJmxRemoteDynamicPortTest
+ * @test JdpJmxRemoteDynamicPortTest.java
+ * @bug 8167337
+ * @summary Verify a non-zero value is assigned to jmxremote.port
+ *          when VM is started with jmxremote.port=0.
+ *
+ * @library /lib/testlibrary
+ *
+ * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpJmxRemoteDynamicPortTestCase DynamicLauncher
+ * @run main/othervm JdpJmxRemoteDynamicPortTest
  */
 
 import java.lang.management.ManagementFactory;
--- a/jdk/test/sun/management/jdp/JdpOffTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jdp/JdpOffTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -31,8 +31,9 @@
 /*
  * @test JdpOffTest.java
  * @summary Assert that no JDP packets are sent to the default address and port.
+ *
  * @library /lib/testlibrary
- * @modules jdk.management.agent/sun.management.jdp
+ *
  * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOffTestCase DynamicLauncher
  * @run main/othervm JdpOffTest
  */
--- a/jdk/test/sun/management/jdp/JdpSpecificAddressTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jdp/JdpSpecificAddressTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -30,8 +30,9 @@
 /*
  * @test JdpSpecificAddressTest
  * @summary Assert that we can read JDP packets from a multicast socket connection, on specific IP and port.
+ *
  * @library /lib/testlibrary
- * @modules jdk.management.agent/sun.management.jdp
+ *
  * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
  * @run main/othervm JdpSpecificAddressTest
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jdp/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,3 @@
+modules = jdk.management.agent/sun.management.jdp \
+          java.logging
+
--- a/jdk/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,15 +22,14 @@
  */
 
 /**
- *  @test LocalRMIServerSocketFactoryTest.java
- *  @bug 6774170
- *  @summary Connect to a server socket returned by the LocalRMIServerSocketFactory.
+ * @test LocalRMIServerSocketFactoryTest.java
+ * @bug 6774170
+ * @summary Connect to a server socket returned by the LocalRMIServerSocketFactory.
  *
- *  @author Daniel Fuchs
+ * @author Daniel Fuchs
  *
- *  @modules jdk.management.agent/sun.management.jmxremote
- *  @run compile -XDignore.symbol.file=true -g LocalRMIServerSocketFactoryTest.java
- *  @run main LocalRMIServerSocketFactoryTest
+ * @run compile -XDignore.symbol.file=true -g LocalRMIServerSocketFactoryTest.java
+ * @run main LocalRMIServerSocketFactoryTest
  */
 
 import sun.management.jmxremote.LocalRMIServerSocketFactory;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/jmxremote/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,3 @@
+modules = jdk.management.agent/jdk.internal.agent \
+          jdk.management.agent/sun.management.jmxremote
+
--- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -40,12 +40,16 @@
 /**
  * @test
  * @bug 6434402 8004926
+ * @author Jaroslav Bachorik
+ *
  * @library /lib/testlibrary
- * @modules jdk.management.agent/jdk.internal.agent
+ * @modules java.management
+ *          jdk.attach
+ *          jdk.management.agent/jdk.internal.agent
+ *
  * @build jdk.testlibrary.*
  * @build TestManager TestApplication CustomLauncherTest
  * @run main/othervm CustomLauncherTest
- * @author Jaroslav Bachorik
  */
 public class CustomLauncherTest {
     private static final  String TEST_CLASSPATH = System.getProperty("test.class.path");
--- a/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -48,9 +48,9 @@
  * @summary Test JMX agent host address binding. Same ports but different
  *          interfaces to bind to (using plain sockets and SSL sockets).
  *
- * @modules jdk.management.agent/jdk.internal.agent
- *          jdk.management.agent/sun.management.jmxremote
  * @library /lib/testlibrary
+ * @modules java.management.rmi
+ *
  * @build jdk.testlibrary.* JMXAgentInterfaceBinding
  * @run main/timeout=5 JMXInterfaceBindingTest
  */
--- a/jdk/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -27,7 +27,11 @@
  * @summary Tests that the jvmstat counters published by the out-of-the-box
  *          management agent for the JMX connection details are correct.
  * @author Luis-Miguel Alventosa
- * @modules jdk.management.agent/jdk.internal.agent
+ *
+ * @modules java.management
+ *          jdk.attach
+ *          jdk.management.agent/jdk.internal.agent
+ *
  * @run clean JvmstatCountersTest
  * @run build JvmstatCountersTest
  * @run main/othervm/timeout=600 -XX:+UsePerfData JvmstatCountersTest 1
--- a/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -32,13 +32,17 @@
 
 /**
  * @test
- * @library /lib/testlibrary
  * @bug 5016507 6173612 6319776 6342019 6484550 8004926
  * @summary Start a managed VM and test that a management tool can connect
  *          without connection or username/password details.
  *          TestManager will attempt a connection to the address obtained from
  *          both agent properties and jvmstat buffer.
- * @modules jdk.management.agent/jdk.internal.agent
+ *
+ * @library /lib/testlibrary
+ * @modules java.management
+ *          jdk.attach
+ *          jdk.management.agent/jdk.internal.agent
+ *
  * @build jdk.testlibrary.* TestManager TestApplication
  * @run main/othervm/timeout=300 LocalManagementTest
  */
--- a/jdk/test/sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,14 +25,14 @@
 
 /**
  * @test
- * @library /lib/testlibrary
  * @bug 6557093
  * @summary Check SSL config file permission for out-of-the-box management
- * @modules jdk.management.agent
+ * @author Taras Ledkov
+ *
+ * @library /lib/testlibrary
+ *
  * @build jdk.testlibrary.* AbstractFilePermissionTest Dummy
  * @run main/timeout=300 PasswordFilePermissionTest
- *
- * @author Taras Ledkov
  */
 public class PasswordFilePermissionTest extends AbstractFilePermissionTest {
 
--- a/jdk/test/sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -24,12 +24,11 @@
 #
 # @test
 # @bug     6528083
+# @key intermittent
 # @summary Test RMI Bootstrap
 #
-# @key intermittent
 # @library /lib/testlibrary
-# @modules jdk.management.agent/jdk.internal.agent
-#          jdk.management.agent/sun.management.jmxremote
+#
 # @build jdk.testlibrary.* TestLogger Utils RmiBootstrapTest
 # @run shell/timeout=300  RmiBootstrapTest.sh
 
@@ -44,7 +43,7 @@
 
 rm -rf ${TESTCLASSES}/ssl
 mkdir -p ${TESTCLASSES}/ssl
-cp -rf ${TESTSRC}/ssl/*store ${TESTCLASSES}/ssl 
+cp -rf ${TESTSRC}/ssl/*store ${TESTCLASSES}/ssl
 chmod -R 777 ${TESTCLASSES}/ssl
 
 DEBUGOPTIONS=""
@@ -56,7 +55,7 @@
 
 # Call the common generic test
 #
-# No need to since bug 4267864 is now fixed. 
+# No need to since bug 4267864 is now fixed.
 #
 echo -------------------------------------------------------------
 echo Launching test for `basename $0 .sh`
--- a/jdk/test/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -39,13 +39,14 @@
 
 /**
  * @test
- * @library /lib/testlibrary
  * @bug 6228231
  * @summary Test that RMI registry uses SSL.
- * @modules jdk.management.agent
+ * @author Luis-Miguel Alventosa, Taras Ledkov
+ *
+ * @library /lib/testlibrary
+ *
  * @build jdk.testlibrary.* RmiRegistrySslTestApp
  * @run main/timeout=300 RmiRegistrySslTest
- * @author Luis-Miguel Alventosa, Taras Ledkov
  */
 public class RmiRegistrySslTest {
     private final String TEST_CLASS_PATH = System.getProperty("test.class.path");
--- a/jdk/test/sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -27,8 +27,7 @@
 # @summary Test RMI Bootstrap with SSL
 #
 # @library /lib/testlibrary
-# @modules jdk.management.agent/jdk.internal.agent
-#          jdk.management.agent/sun.management.jmxremote
+#
 # @build jdk.testlibrary.* TestLogger Utils RmiBootstrapTest
 # @run shell/timeout=300  RmiSslBootstrapTest.sh
 
@@ -43,7 +42,7 @@
 
 rm -rf ${TESTCLASSES}/ssl
 mkdir -p ${TESTCLASSES}/ssl
-cp -rf ${TESTSRC}/ssl/*store ${TESTCLASSES}/ssl 
+cp -rf ${TESTSRC}/ssl/*store ${TESTCLASSES}/ssl
 chmod -R 777 ${TESTCLASSES}/ssl
 
 DEBUGOPTIONS=""
--- a/jdk/test/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh	Wed Jul 05 23:09:40 2017 +0200
@@ -24,10 +24,8 @@
 #
 # @test
 # @summary Test RMI Bootstrap with SSL and no keystore.
+# @bug 4932854
 #
-# @bug 4932854
-# @modules jdk.management.agent/jdk.internal.agent
-#          jdk.management.agent/sun.management.jmxremote
 # @build TestLogger RmiSslNoKeyStoreTest
 # @run shell/timeout=300  RmiSslNoKeyStoreTest.sh
 
@@ -42,7 +40,7 @@
 
 rm -rf ${TESTCLASSES}/ssl
 mkdir -p ${TESTCLASSES}/ssl
-cp -rf ${TESTSRC}/ssl/*store ${TESTCLASSES}/ssl 
+cp -rf ${TESTSRC}/ssl/*store ${TESTCLASSES}/ssl
 chmod -R 777 ${TESTCLASSES}/ssl
 
 DEBUGOPTIONS=""
--- a/jdk/test/sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,14 +25,14 @@
 
 /**
  * @test
+ * @bug 6557093
+ * @summary Check SSL config file permission for out-of-the-box management
+ * @author Taras Ledkov
+ *
  * @library /lib/testlibrary
- * @bug 6557093
- * @modules jdk.management.agent
+ *
  * @build jdk.testlibrary.* Dummy AbstractFilePermissionTest
- * @summary Check SSL config file permission for out-of-the-box management
  * @run main/timeout=300 SSLConfigFilePermissionTest
- *
- * @author Taras Ledkov
  */
 public class SSLConfigFilePermissionTest extends AbstractFilePermissionTest {
 
--- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -53,13 +53,17 @@
 /**
  * @test
  * @bug 7110104
+ * @key randomness intermittent
+ * @summary Makes sure that enabling/disabling the management agent through JCMD
+ *          achieves the desired results
+ *
  * @library /lib/testlibrary
- * @modules jdk.management.agent/jdk.internal.agent
+ * @modules java.management
+ *          java.rmi
+ *          jdk.management.agent/jdk.internal.agent
+ *
  * @build jdk.testlibrary.* JMXStartStopTest PortAllocator TestApp ManagementAgentJcmd
  * @run main/othervm/timeout=600 -XX:+UsePerfData JMXStartStopTest
- * @summary Makes sure that enabling/disabling the management agent through JCMD
- *          achieves the desired results
- * @key randomness intermittent
  */
 public class JMXStartStopTest {
     private static final String TEST_APP_NAME = "TestApp";
--- a/jdk/test/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -38,11 +38,12 @@
 /**
  * @test
  * @bug 8075926
+ * @key intermittent
  * @summary Makes sure that the current management agent status is reflected
  *          in the related performance counters.
- * @key intermittent
+ *
  * @library /lib/testlibrary
- * @modules jdk.management.agent/jdk.internal.agent
+ *
  * @build jdk.testlibrary.* PortAllocator TestApp ManagementAgentJcmd
  * @run testng/othervm -XX:+UsePerfData JMXStatusPerfCountersTest
  */
--- a/jdk/test/sun/management/jmxremote/startstop/JMXStatusTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStatusTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -37,8 +37,9 @@
  * @summary Performs a sanity test for the ManagementAgent.status diagnostic command.
  *          Management agent may be disabled, started (only local connections) and started.
  *          The test asserts that the expected text is being printed.
+ *
  * @library /lib/testlibrary
- * @modules jdk.management.agent/jdk.internal.agent
+ *
  * @build jdk.testlibrary.* PortAllocator TestApp ManagementAgentJcmd
  *        JMXStatusTest JMXStatus1Test JMXStatus2Test
  * @run testng/othervm -XX:+UsePerfData JMXStatus1Test
--- a/jdk/test/sun/net/www/http/HttpClient/B8025710.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/net/www/http/HttpClient/B8025710.java	Wed Jul 05 23:09:40 2017 +0200
@@ -37,6 +37,7 @@
  * @test
  * @bug 8025710
  * @summary Proxied https connection reuse by HttpClient can send CONNECT to the server
+ * @run main/othervm B8025710
  */
 public class B8025710 {
 
--- a/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java	Wed Jul 05 23:09:40 2017 +0200
@@ -26,8 +26,7 @@
  * @bug 8132734 8144062 8159785
  * @summary Test that URL connections to multi-release jars can be runtime versioned
  * @library /lib/testlibrary/java/util/jar
- * @modules java.compiler
- *          jdk.compiler
+ * @modules jdk.compiler
  *          jdk.httpserver
  *          jdk.jartool
  * @build Compiler JarBuilder CreateMultiReleaseTestJars SimpleHttpServer
--- a/jdk/test/sun/net/www/protocol/jrt/java.policy	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/net/www/protocol/jrt/java.policy	Wed Jul 05 23:09:40 2017 +0200
@@ -1,3 +1,3 @@
 grant {
-    permission java.io.FilePermission "${java.home}/-", "read";
+    permission java.lang.RuntimePermission "accessSystemModules";
 };
--- a/jdk/test/sun/security/krb5/auto/Basic.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/security/krb5/auto/Basic.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 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,19 +25,48 @@
  * @test
  * @bug 7152176 8164437
  * @summary More krb5 tests
+ * @library /test/lib
  * @compile -XDignore.symbol.file Basic.java
- * @run main/othervm
- *      Basic jdk.security.jgss
- * @run main/othervm --limit-modules java.security.jgss,jdk.security.auth
- *      Basic java.security.jgss
+ * @run main/othervm Basic
  */
 
+import jdk.test.lib.process.ProcessTools;
 import sun.security.jgss.GSSUtil;
 
-// The basic krb5 test skeleton you can copy from
+import java.util.List;
+import java.util.stream.Stream;
+
 public class Basic {
 
-    public static void main(String[] args) throws Exception {
+    public static void main(String[] args) throws Throwable {
+
+        if (args.length == 0) { // jtreg launched here
+
+            // With all modules
+            test("jdk.security.jgss");
+
+            // With limited modules
+            List<String> cmd = ProcessTools.createJavaProcessBuilder().command();
+            Stream.of(jdk.internal.misc.VM.getRuntimeArguments())
+                    .filter(arg -> arg.startsWith("--add-exports=") ||
+                            arg.startsWith("--add-opens="))
+                    .forEach(cmd::add);
+            cmd.addAll(List.of(
+                    "-Dtest.src=" + System.getProperty("test.src"),
+                    "--add-modules",
+                        "java.base,java.security.jgss,jdk.security.auth",
+                    "--limit-modules",
+                        "java.security.jgss,jdk.security.auth",
+                    "Basic",
+                    "launched-limited"));
+            ProcessTools.executeCommand(cmd.toArray(new String[cmd.size()]))
+                    .shouldHaveExitValue(0);
+        } else { // Launched by ProcessTools above, with limited modules.
+            test("java.security.jgss");
+        }
+    }
+
+    static void test(String expected) throws Exception {
 
         new OneKDC(null).writeJAASConf();
 
@@ -66,8 +95,8 @@
 
         // Bonus test for 8164437.
         String moduleName = c.x().getClass().getModule().getName();
-        if (!moduleName.equals(args[0])) {
-            throw new Exception("Expected: " + args[0]
+        if (!moduleName.equals(expected)) {
+            throw new Exception("Expected: " + expected
                     + ". Actual: " + moduleName);
         }
     }
--- a/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -28,6 +28,7 @@
  *          java.security.jgss/sun.security.krb5.internal:+open
  *          java.security.jgss/sun.security.jgss
  *          java.security.jgss/sun.security.krb5:+open
+ *          java.security.jgss/sun.security.krb5.internal.ccache
  *          java.security.jgss/sun.security.krb5.internal.crypto
  *          java.security.jgss/sun.security.krb5.internal.ktab
  *          jdk.security.auth
--- a/jdk/test/sun/security/krb5/config/Include.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/security/krb5/config/Include.java	Wed Jul 05 23:09:40 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);
--- a/jdk/test/sun/security/pkcs/pkcs8/PKCS8Test.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/security/pkcs/pkcs8/PKCS8Test.java	Wed Jul 05 23:09:40 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
@@ -195,12 +195,12 @@
     public static void main(String[] args)
             throws IOException, InvalidKeyException {
 
-        BigInteger p = BigInteger.valueOf(1);
-        BigInteger q = BigInteger.valueOf(2);
-        BigInteger g = BigInteger.valueOf(3);
-        BigInteger x = BigInteger.valueOf(4);
+        BigInteger x = BigInteger.valueOf(1);
+        BigInteger p = BigInteger.valueOf(2);
+        BigInteger q = BigInteger.valueOf(3);
+        BigInteger g = BigInteger.valueOf(4);
 
-        DSAPrivateKey priv = new DSAPrivateKey(p, q, g, x);
+        DSAPrivateKey priv = new DSAPrivateKey(x, p, q, g);
 
         byte[] encodedKey = priv.getEncoded();
         byte[] expectedBytes = new byte[EXPECTED.length];
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs/pkcs8/TestLeadingZeros.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,82 @@
+/*
+ * 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 8175251
+ * @summary ensure that PKCS8-encoded private key with leading 0s
+ * can be loaded.
+ * @run main TestLeadingZeros
+ */
+
+import java.io.*;
+import java.security.*;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.interfaces.*;
+import java.util.*;
+
+public class TestLeadingZeros {
+
+    // The following test vectors are various BER encoded PKCS8 bytes
+    static final String[] PKCS8_ENCODINGS  = {
+        // first is the original one from PKCS8Test
+        "301e020100301206052b0e03020c30090201020201030201040403020101A000",
+        // changed original to version w/ 1 leading 0
+        "301f02020000301206052b0e03020c30090201020201030201040403020101A000",
+        // changed original to P w/ 1 leading 0
+        "301f020100301306052b0e03020c300a020200020201030201040403020101A000",
+        // changed original to X w/ 2 leading 0s
+        "3020020100301206052b0e03020c300902010202010302010404050203000001A000"
+    };
+
+    public static void main(String[] argv) throws Exception {
+        KeyFactory factory = KeyFactory.getInstance("DSA", "SUN");
+
+        for (String encodings : PKCS8_ENCODINGS) {
+            byte[] encodingBytes = hexToBytes(encodings);
+            PKCS8EncodedKeySpec encodedKeySpec =
+                new PKCS8EncodedKeySpec(encodingBytes);
+            DSAPrivateKey privKey2 = (DSAPrivateKey)
+                factory.generatePrivate(encodedKeySpec);
+            System.out.println("key: " + privKey2);
+        }
+        System.out.println("Test Passed");
+    }
+
+    private static byte[] hexToBytes(String hex) {
+        if (hex.length() % 2 != 0) {
+            throw new RuntimeException("Input should be even length");
+        }
+        int size = hex.length() / 2;
+        byte[] result = new byte[size];
+        for (int i = 0; i < size; i++) {
+            int hi = Character.digit(hex.charAt(2 * i), 16);
+            int lo = Character.digit(hex.charAt(2 * i + 1), 16);
+            if ((hi == -1) || (lo == -1)) {
+                throw new RuntimeException("Input should be hexadecimal");
+            }
+            result[i] = (byte) (16 * hi + lo);
+        }
+        return result;
+    }
+}
--- a/jdk/test/sun/security/tools/keytool/WeakAlg.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/security/tools/keytool/WeakAlg.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8171319
+ * @bug 8171319 8177569
  * @summary keytool should print out warnings when reading or generating
   *         cert/cert req using weak algorithms
  * @library /test/lib
@@ -78,7 +78,8 @@
                 .shouldMatch("<b>.*512-bit RSA key.*risk")
                 .shouldContain("512-bit RSA key (weak)");
 
-        // Multiple warnings for multiple cert in -printcert or -list or -exportcert
+        // Multiple warnings for multiple cert in -printcert
+        // or -list or -exportcert
 
         // -certreq, -printcertreq, -gencert
         checkCertReq("a", "", null);
@@ -184,7 +185,7 @@
                 .shouldMatch("The input.*MD5withRSA.*risk")
                 .shouldNotContain("[no]");
 
-        // cert is self-signed cacerts
+        // JDK-8177569: no warning for sigalg of trusted cert
         String weakSigAlgCA = null;
         KeyStore ks = KeyStoreUtil.getCacertsKeyStore();
         if (ks != null) {
@@ -208,12 +209,40 @@
             }
         }
         if (weakSigAlgCA != null) {
+            // The following 2 commands still have a warning on why not using
+            // the -cacerts option directly.
+            kt("-list -keystore " + KeyStoreUtil.getCacerts())
+                    .shouldNotContain("risk");
+            kt("-list -v -keystore " + KeyStoreUtil.getCacerts())
+                    .shouldNotContain("risk");
+
+            // -printcert will always show warnings
+            kt("-printcert -file ca.cert")
+                    .shouldContain("name: " + weakSigAlgCA + " (weak)")
+                    .shouldContain("Warning")
+                    .shouldMatch("The certificate.*" + weakSigAlgCA + ".*risk");
+            kt("-printcert -file ca.cert -trustcacerts") // -trustcacerts useless
+                    .shouldContain("name: " + weakSigAlgCA + " (weak)")
+                    .shouldContain("Warning")
+                    .shouldMatch("The certificate.*" + weakSigAlgCA + ".*risk");
+
+            // Importing with -trustcacerts ignore CA cert's sig alg
             kt("-delete -alias d");
             kt("-importcert -alias d -trustcacerts -file ca.cert", "no")
                     .shouldContain("Certificate already exists in system-wide CA")
+                    .shouldNotContain("risk")
+                    .shouldContain("Do you still want to add it to your own keystore?");
+            kt("-importcert -alias d -trustcacerts -file ca.cert -noprompt")
+                    .shouldNotContain("risk")
+                    .shouldNotContain("[no]");
+
+            // but not without -trustcacerts
+            kt("-delete -alias d");
+            kt("-importcert -alias d -file ca.cert", "no")
+                    .shouldContain("name: " + weakSigAlgCA + " (weak)")
                     .shouldContain("Warning")
                     .shouldMatch("The input.*" + weakSigAlgCA + ".*risk")
-                    .shouldContain("Do you still want to add it to your own keystore?");
+                    .shouldContain("Trust this certificate?");
             kt("-importcert -alias d -file ca.cert -noprompt")
                     .shouldContain("Warning")
                     .shouldMatch("The input.*" + weakSigAlgCA + ".*risk")
@@ -266,6 +295,26 @@
         // install reply
 
         reStore();
+        certreq("c", "");
+        gencert("a-c", "");
+        kt("-importcert -alias c -file a-c.cert")
+                .shouldContain("Warning")
+                .shouldMatch("Issuer <a>.*MD5withRSA.*risk");
+
+        // JDK-8177569: no warning for sigalg of trusted cert
+        reStore();
+        // Change a into a TrustedCertEntry
+        kt("-exportcert -alias a -file a.cert");
+        kt("-delete -alias a");
+        kt("-importcert -alias a -file a.cert -noprompt");
+        kt("-list -alias a -v")
+                .shouldNotContain("weak")
+                .shouldNotContain("Warning");
+        // This time a is trusted and no warning on its weak sig alg
+        kt("-importcert -alias c -file a-c.cert")
+                .shouldNotContain("Warning");
+
+        reStore();
 
         gencert("a-b", "");
         gencert("b-c", "");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jcmd/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.jcmd
+
--- a/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java	Wed Jul 05 23:09:40 2017 +0200
@@ -34,15 +34,14 @@
 import jdk.testlibrary.OutputAnalyzer;
 import jdk.testlibrary.Utils;
 
-/**
- * Unit test for jcmd utility. Tests jcmd options which do not send
- * requests to a specific JVM process.
- */
 /*
  * @test
  * @bug 7104647
+ * @summary Unit test for jcmd utility. Tests jcmd options which do not send
+ * requests to a specific JVM process.
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @build jdk.testlibrary.*
  * @run main TestJcmdDefaults
  */
--- a/jdk/test/sun/tools/jcmd/TestJcmdSanity.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java	Wed Jul 05 23:09:40 2017 +0200
@@ -35,15 +35,14 @@
 import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.Utils;
 
-/**
- * Unit test for jcmd utility. The test will send different diagnostic command
- * requests to the current java process.
- */
 /*
  * @test
  * @bug 7104647 7154822
+ * @summary Unit test for jcmd utility. The test will send different diagnostic
+ * command requests to the current java process.
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @build jdk.testlibrary.*
  * @run main/othervm -XX:+UsePerfData TestJcmdSanity
  */
--- a/jdk/test/sun/tools/jconsole/ResourceCheckTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jconsole/ResourceCheckTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -22,13 +22,14 @@
  */
 
 /**
+ * @test
+ * @bug 5008856 5023573 5024917 5062569 7172176
+ * @summary 'missing resource key' error for key = "Operating system"
  *
- *  @test
- *  @bug 5008856 5023573 5024917 5062569 7172176
- *  @summary 'missing resource key' error for key = "Operating system"
- *  @modules jdk.jconsole/sun.tools.jconsole
- *           jdk.jconsole/sun.tools.jconsole.resources:open
- *  @run main ResourceCheckTest
+ * @modules jdk.jconsole/sun.tools.jconsole
+ *          jdk.jconsole/sun.tools.jconsole.resources:open
+ *
+ * @run main ResourceCheckTest
  */
 
 import java.lang.reflect.Field;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jhsdb/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,3 @@
+modules = jdk.hotspot.agent \
+          java.management
+
--- a/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -36,11 +36,12 @@
  * @test
  * @bug 8042397
  * @summary Unit test for jmap utility test heap configuration reader
- * @modules jdk.hotspot.agent/sun.jvm.hotspot
+ *
  * @library /test/lib
  * @library /lib/testlibrary
- * @build jdk.testlibrary.*
- * @build jdk.test.lib.apps.*
+ * @modules java.management
+ *          jdk.hotspot.agent/sun.jvm.hotspot
+ *
  * @build JMapHeapConfigTest TmtoolTestScenario
  * @run main JMapHeapConfigTest
  */
--- a/jdk/test/sun/tools/jinfo/JInfoTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jinfo/JInfoTest.java	Wed Jul 05 23:09:40 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
@@ -36,11 +36,12 @@
 /*
  * @test
  * @summary Unit test for jinfo utility
- * @modules java.base/jdk.internal.misc
+ *
  * @library /test/lib
- * @build jdk.test.lib.*
- * @build jdk.test.lib.apps.*
- * @build jdk.test.lib.process.*
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ *          jdk.jcmd
+ *
  * @run main JInfoTest
  */
 public class JInfoTest {
@@ -88,8 +89,8 @@
             LingeredApp.startApp(params, app2);
             OutputAnalyzer output = jinfo("JInfoTestLingeredApp");
             output.shouldHaveExitValue(0);
-            // "HotSpot(TM)" written once per proc
-            documentMatch(output.getStdout(), ".*HotSpot\\(TM\\).*HotSpot\\(TM\\).*");
+            // "Runtime Environment" written once per proc
+            documentMatch(output.getStdout(), ".*Runtime Environment.*Runtime Environment.*");
         } finally {
             JInfoTestLingeredApp.stopApp(app1);
             JInfoTestLingeredApp.stopApp(app2);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jinfo/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.jcmd
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jmap/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.jcmd
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jstack/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.jcmd
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jstat/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.jcmd
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jstatd/TEST.properties	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,5 @@
+modules = java.management \
+          java.rmi
+          jdk.jcmd \
+          jdk.jstatd
+
--- a/jdk/test/sun/tools/jstatd/TestJstatdDefaults.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jstatd/TestJstatdDefaults.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,8 +25,9 @@
  * @test
  * @bug 4990825
  * @key intermittent
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
  * @run main/timeout=60 TestJstatdDefaults
  */
--- a/jdk/test/sun/tools/jstatd/TestJstatdExternalRegistry.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jstatd/TestJstatdExternalRegistry.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,8 +25,9 @@
  * @test
  * @bug 4990825 7092186
  * @key intermittent
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
  * @run main/timeout=60 TestJstatdExternalRegistry
  */
--- a/jdk/test/sun/tools/jstatd/TestJstatdPort.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jstatd/TestJstatdPort.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,8 +25,9 @@
  * @test
  * @bug 4990825
  * @key intermittent
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
  * @run main/timeout=60 TestJstatdPort
  */
--- a/jdk/test/sun/tools/jstatd/TestJstatdPortAndServer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jstatd/TestJstatdPortAndServer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,8 +25,9 @@
  * @test
  * @bug 4990825
  * @key intermittent
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
  * @run main/timeout=60 TestJstatdPortAndServer
  */
--- a/jdk/test/sun/tools/jstatd/TestJstatdServer.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/sun/tools/jstatd/TestJstatdServer.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,8 +25,9 @@
  * @test
  * @bug 4990825
  * @key intermittent
+ *
  * @library /lib/testlibrary
- * @modules java.management
+ *
  * @build jdk.testlibrary.* JstatdTest JstatGCUtilParser
  * @run main/timeout=60 TestJstatdServer
  */
--- a/jdk/test/tools/jar/modularJar/Basic.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/jar/modularJar/Basic.java	Wed Jul 05 23:09:40 2017 +0200
@@ -39,6 +39,7 @@
 import jdk.testlibrary.FileUtils;
 import jdk.testlibrary.JDKToolFinder;
 import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 import static java.lang.String.format;
@@ -46,7 +47,7 @@
 
 /*
  * @test
- * @bug 8167328 8171830 8165640 8174248
+ * @bug 8167328 8171830 8165640 8174248 8176772
  * @library /lib/testlibrary
  * @modules jdk.compiler
  *          jdk.jartool
@@ -754,7 +755,7 @@
             .assertSuccess();
 
 
-        for (String option : new String[]  {"--print-module-descriptor", "-d" }) {
+        for (String option : new String[]  {"--describe-module", "-d" }) {
 
             jar(option,
                 "--file=" + modularJar.toString())
@@ -801,8 +802,8 @@
     }
 
     @Test
-    public void printModuleDescriptorFoo() throws IOException {
-        Path mp = Paths.get("printModuleDescriptorFoo");
+    public void describeModuleFoo() throws IOException {
+        Path mp = Paths.get("describeModuleFoo");
         createTestDir(mp);
         Path modClasses = MODULE_CLASSES.resolve(FOO.moduleName);
         Path modularJar = mp.resolve(FOO.moduleName + ".jar");
@@ -815,7 +816,7 @@
             "-C", modClasses.toString(), ".")
             .assertSuccess();
 
-        for (String option : new String[]  {"--print-module-descriptor", "-d" }) {
+        for (String option : new String[]  {"--describe-module", "-d" }) {
             jar(option,
                 "--file=" + modularJar.toString())
                 .assertSuccess()
@@ -836,8 +837,8 @@
     }
 
     @Test
-    public void printModuleDescriptorFooFromStdin() throws IOException {
-        Path mp = Paths.get("printModuleDescriptorFooFromStdin");
+    public void describeModuleFooFromStdin() throws IOException {
+        Path mp = Paths.get("describeModuleFooFromStdin");
         createTestDir(mp);
         Path modClasses = MODULE_CLASSES.resolve(FOO.moduleName);
         Path modularJar = mp.resolve(FOO.moduleName + ".jar");
@@ -850,7 +851,7 @@
             "-C", modClasses.toString(), ".")
             .assertSuccess();
 
-        for (String option : new String[]  {"--print-module-descriptor", "-d" }) {
+        for (String option : new String[]  {"--describe-module", "-d" }) {
             jarWithStdin(modularJar.toFile(),
                          option)
                          .assertSuccess()
@@ -862,6 +863,50 @@
         }
     }
 
+
+    @DataProvider(name = "autoNames")
+    public Object[][] autoNames() {
+        return new Object[][] {
+            // JAR file name                module-name[@version]
+            { "foo.jar",                    "foo" },
+            { "foo4j.jar",                  "foo4j", },
+            { "foo1.2.3.jar",               "foo" },
+            { "foo-1.2.3.4.jar",            "foo@1.2.3.4" },
+            { "foo-bar.jar",                "foo.bar" },
+            { "foo-1.2-SNAPSHOT.jar",       "foo@1.2-SNAPSHOT" },
+        };
+    }
+
+    @Test(dataProvider = "autoNames")
+    public void describeAutomaticModule(String jarName, String mid)
+        throws IOException
+    {
+        Path mp = Paths.get("describeAutomaticModule");
+        createTestDir(mp);
+        Path regularJar = mp.resolve(jarName);
+        Path t = Paths.get("t");
+        if (Files.notExists(t))
+            Files.createFile(t);
+
+        jar("--create",
+            "--file=" + regularJar.toString(),
+            t.toString())
+            .assertSuccess();
+
+        for (String option : new String[]  {"--describe-module", "-d" }) {
+            jar(option,
+                "--file=" + regularJar.toString())
+                .assertSuccess()
+                .resultChecker(r -> {
+                    assertTrue(r.output.contains("No module descriptor found"));
+                    assertTrue(r.output.contains("Derived automatic module"));
+                    assertTrue(r.output.contains("module " + mid),
+                               "Expected [", "module " + mid,"] in [", r.output, "]");
+                    }
+                );
+        }
+    }
+
     // -- Infrastructure
 
     static Result jarWithStdin(File stdinSource, String... args) {
--- a/jdk/test/tools/jlink/IntegrationTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/jlink/IntegrationTest.java	Wed Jul 05 23:09:40 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,6 +25,7 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.UncheckedIOException;
+import java.nio.ByteOrder;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -135,11 +136,6 @@
         }
         System.out.println(jl);
 
-        JlinkConfiguration config
-                = new JlinkConfiguration(null, null, null, null);
-
-        System.out.println(config);
-
         Plugin p = Jlink.newPlugin("toto", Collections.emptyMap(), null);
         if (p != null) {
             throw new Exception("Plugin should be null");
@@ -163,7 +159,7 @@
         Set<String> limits = new HashSet<>();
         limits.add("java.management");
         JlinkConfiguration config = new Jlink.JlinkConfiguration(output,
-                modulePaths, mods, limits, null);
+                modulePaths, mods, limits, ByteOrder.nativeOrder());
 
         List<Plugin> lst = new ArrayList<>();
 
@@ -214,7 +210,8 @@
         checkReleaseProperty(props, "JAVA_FULL_VERSION");
         checkReleaseProperty(props, "OS_NAME");
         checkReleaseProperty(props, "OS_ARCH");
-        checkReleaseProperty(props, "OS_VERSION");
+        // OS_VERSION is added from makefile. We're testing API-way to create image here!
+        // checkReleaseProperty(props, "OS_VERSION");
 
         if (!Files.exists(output.resolve("toto.txt"))) {
             throw new AssertionError("Post processing not called");
--- a/jdk/test/tools/jlink/JLinkNegativeTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/jlink/JLinkNegativeTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -193,7 +193,7 @@
                     .output(imageFile)
                     .addMods("not_zip")
                     .modulePath(helper.defaultModulePath())
-                    .call().assertFailure("Error: java.io.IOException: Invalid jmod file");
+                    .call().assertFailure("Error: java.io.IOException: Invalid JMOD file");
         } finally {
             deleteDirectory(jmod);
         }
--- a/jdk/test/tools/jlink/JLinkTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/jlink/JLinkTest.java	Wed Jul 05 23:09:40 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
@@ -274,7 +274,7 @@
             String[] userOptions = {"--compress", "2", "foo" };
             String moduleName = "orphanarg1";
             helper.generateDefaultJModule(moduleName, "composite2");
-            helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: orphan argument: foo");
+            helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: foo");
         }
 
         // orphan argument - JDK-8166810
@@ -282,7 +282,7 @@
             String[] userOptions = {"--output", "foo", "bar" };
             String moduleName = "orphanarg2";
             helper.generateDefaultJModule(moduleName, "composite2");
-            helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: orphan argument: bar");
+            helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: bar");
         }
 
         // basic check for --help - JDK-8173717
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/BindServices.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+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.spi.ToolProvider;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static jdk.testlibrary.Asserts.assertTrue;
+import static jdk.testlibrary.ProcessTools.*;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * @test
+ * @bug 8174826
+ * @library /lib/testlibrary
+ * @modules jdk.compiler jdk.jlink
+ * @build BindServices CompilerUtils jdk.testlibrary.ProcessTools
+ * @run testng BindServices
+ */
+
+public class BindServices {
+    private static final String JAVA_HOME = System.getProperty("java.home");
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+
+    private static final String MODULE_PATH =
+        Paths.get(JAVA_HOME, "jmods").toString() +
+            File.pathSeparator + MODS_DIR.toString();
+
+    // the names of the modules in this test
+    private static String[] modules = new String[] {"m1", "m2", "m3"};
+
+
+    private static boolean hasJmods() {
+        if (!Files.exists(Paths.get(JAVA_HOME, "jmods"))) {
+            System.err.println("Test skipped. NO jmods directory");
+            return false;
+        }
+        return true;
+    }
+
+    /*
+     * Compiles all modules used by the test
+     */
+    @BeforeTest
+    public void compileAll() throws Throwable {
+        if (!hasJmods()) return;
+
+        for (String mn : modules) {
+            Path msrc = SRC_DIR.resolve(mn);
+            assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
+                "--module-source-path", SRC_DIR.toString()));
+        }
+    }
+
+    @Test
+    public void noServiceBinding() throws Throwable {
+        if (!hasJmods()) return;
+
+        Path dir = Paths.get("noServiceBinding");
+
+        // no service binding and does not link m2,m3 providers.
+        JLink.run("--output", dir.toString(),
+                  "--module-path", MODULE_PATH,
+                  "--add-modules", "m1").output();
+
+        testImage(dir, "m1");
+    }
+
+    @Test
+    public void fullServiceBinding() throws Throwable {
+        if (!hasJmods()) return;
+
+        Path dir = Paths.get("fullServiceBinding");
+
+        // full service binding
+        // m2 is a provider used by m1.  During service binding, when m2 is
+        // resolved, m2 uses p2.T that causes m3 to be linked as it is a
+        // provider to p2.T
+        JLink.run("--output", dir.toString(),
+                  "--module-path", MODULE_PATH,
+                  "--add-modules", "m1",
+                  "--bind-services",
+                  "--limit-modules", "m1,m2,m3,java.base");
+
+        testImage(dir, "m1", "m2", "m3");
+    }
+
+    @Test
+    public void testVerbose() throws Throwable {
+        if (!hasJmods()) return;
+
+        Path dir = Paths.get("verbose");
+
+        List<String> output =
+            JLink.run("--output", dir.toString(),
+                      "--module-path", MODULE_PATH,
+                      "--add-modules", "m1",
+                      "--bind-services",
+                      "--verbose",
+                      "--limit-modules", "m1,m2,m3,java.base").output();
+
+        List<String> expected = List.of(
+            "module m1 (" + MODS_DIR.resolve("m1").toUri().toString() + ")",
+            "module m2 (" + MODS_DIR.resolve("m2").toUri().toString() + ")",
+            "module m3 (" + MODS_DIR.resolve("m3").toUri().toString() + ")",
+            "module m1 provides p1.S, used by m1",
+            "module m2 provides p1.S, used by m1",
+            "module m2 provides p2.T, used by m2",
+            "module m3 provides p2.T, used by m2"
+        );
+
+        assertTrue(output.containsAll(expected));
+
+        testImage(dir, "m1", "m2", "m3");
+    }
+
+    /*
+     * Tests the given ${java.home} to only contain the specified modules
+     */
+    private void testImage(Path javaHome, String... modules) throws Throwable {
+        Path java = javaHome.resolve("bin").resolve("java");
+        String[] cmd = Stream.concat(
+            Stream.of(java.toString(), "-m", "m1/p1.Main"),
+            Stream.of(modules)).toArray(String[]::new);
+
+        assertTrue(executeProcess(cmd).outputTo(System.out)
+                                      .errorTo(System.out)
+                                      .getExitValue() == 0);
+    }
+
+    static class JLink {
+        static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
+            .orElseThrow(() ->
+                new RuntimeException("jlink tool not found")
+            );
+
+        static JLink run(String... options) {
+            JLink jlink = new JLink();
+            assertTrue(jlink.execute(options) == 0);
+            return jlink;
+        }
+
+        final List<String> output = new ArrayList<>();
+        private int execute(String... options) {
+            System.out.println("jlink " +
+                Stream.of(options).collect(Collectors.joining(" ")));
+
+            StringWriter writer = new StringWriter();
+            PrintWriter pw = new PrintWriter(writer);
+            int rc = JLINK_TOOL.run(pw, pw, options);
+            System.out.println(writer.toString());
+            Stream.of(writer.toString().split("\\v"))
+                  .map(String::trim)
+                  .forEach(output::add);
+            return rc;
+        }
+
+        boolean contains(String s) {
+            return output.contains(s);
+        }
+
+        List<String> output() {
+            return output;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/SuggestProviders.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+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.spi.ToolProvider;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static jdk.testlibrary.Asserts.assertTrue;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * @test
+ * @bug 8174826
+ * @library /lib/testlibrary
+ * @modules jdk.charsets jdk.compiler jdk.jlink
+ * @build SuggestProviders CompilerUtils
+ * @run testng SuggestProviders
+ */
+
+public class SuggestProviders {
+    private static final String JAVA_HOME = System.getProperty("java.home");
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+
+    private static final String MODULE_PATH =
+        Paths.get(JAVA_HOME, "jmods").toString() +
+        File.pathSeparator + MODS_DIR.toString();
+
+    // the names of the modules in this test
+    private static String[] modules = new String[] {"m1", "m2", "m3"};
+
+
+    private static boolean hasJmods() {
+        if (!Files.exists(Paths.get(JAVA_HOME, "jmods"))) {
+            System.err.println("Test skipped. NO jmods directory");
+            return false;
+        }
+        return true;
+    }
+
+    /*
+     * Compiles all modules used by the test
+     */
+    @BeforeTest
+    public void compileAll() throws Throwable {
+        if (!hasJmods()) return;
+
+        for (String mn : modules) {
+            Path msrc = SRC_DIR.resolve(mn);
+            assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
+                "--module-source-path", SRC_DIR.toString()));
+        }
+    }
+
+    @Test
+    public void suggestProviders() throws Throwable {
+        if (!hasJmods()) return;
+
+        List<String> output = JLink.run("--module-path", MODULE_PATH,
+                                        "--add-modules", "m1",
+                                        "--suggest-providers").output();
+        // check a subset of services used by java.base
+        List<String> expected = List.of(
+            "uses java.lang.System$LoggerFinder",
+            "uses java.net.ContentHandlerFactory",
+            "uses java.net.spi.URLStreamHandlerProvider",
+            "uses java.nio.channels.spi.AsynchronousChannelProvider",
+            "uses java.nio.channels.spi.SelectorProvider",
+            "uses java.nio.charset.spi.CharsetProvider",
+            "uses java.nio.file.spi.FileSystemProvider",
+            "uses java.nio.file.spi.FileTypeDetector",
+            "uses java.security.Provider",
+            "uses java.util.spi.ToolProvider",
+            "uses p1.S",
+            "module jdk.charsets provides java.nio.charset.spi.CharsetProvider, used by java.base",
+            "module jdk.compiler provides java.util.spi.ToolProvider, used by java.base",
+            "module jdk.jlink provides java.util.spi.ToolProvider, used by java.base",
+            "module m1 provides p1.S, used by m1",
+            "module m2 provides p1.S, used by m1"
+        );
+
+        assertTrue(output.containsAll(expected));
+    }
+
+    @Test
+    public void providersForServices() throws Throwable {
+        if (!hasJmods()) return;
+
+        List<String> output =
+            JLink.run("--module-path", MODULE_PATH,
+                      "--add-modules", "m1",
+                      "--suggest-providers",
+                      "java.nio.charset.spi.CharsetProvider,p1.S,p2.T").output();
+
+        System.out.println(output);
+        List<String> expected = List.of(
+            "module jdk.charsets provides java.nio.charset.spi.CharsetProvider, used by java.base",
+            "module m1 provides p1.S, used by m1",
+            "module m2 provides p1.S, used by m1",
+            "module m2 provides p2.T, used by m2",
+            "module m3 provides p2.T, used by m2"
+        );
+
+        assertTrue(output.containsAll(expected));
+    }
+
+    @Test
+    public void unusedService() throws Throwable {
+        if (!hasJmods()) return;
+
+        List<String> output =
+            JLink.run("--module-path", MODULE_PATH,
+                "--add-modules", "m1",
+                "--suggest-providers",
+                "nonExistentType").output();
+
+        System.out.println(output);
+        List<String> expected = List.of(
+            "Services specified in --suggest-providers not used: nonExistentType"
+        );
+
+        assertTrue(output.containsAll(expected));
+    }
+
+    @Test
+    public void noSuggestProviders() throws Throwable {
+        if (!hasJmods()) return;
+
+        List<String> output =
+            JLink.run("--module-path", MODULE_PATH,
+                      "--add-modules", "m1",
+                      "--bind-services",
+                      "--limit-modules", "m1,m2,m3,java.base",
+                      "--suggest-providers").output();
+
+        String expected = "--bind-services option is specified. No additional providers suggested.";
+        assertTrue(output.contains(expected));
+
+    }
+
+    static class JLink {
+        static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
+            .orElseThrow(() ->
+                new RuntimeException("jlink tool not found")
+            );
+
+        static JLink run(String... options) {
+            JLink jlink = new JLink();
+            assertTrue(jlink.execute(options) == 0);
+            return jlink;
+        }
+
+        final List<String> output = new ArrayList<>();
+        private int execute(String... options) {
+            System.out.println("jlink " +
+                Stream.of(options).collect(Collectors.joining(" ")));
+
+            StringWriter writer = new StringWriter();
+            PrintWriter pw = new PrintWriter(writer);
+            int rc = JLINK_TOOL.run(pw, pw, options);
+            System.out.println(writer.toString());
+            Stream.of(writer.toString().split("\\v"))
+                  .map(String::trim)
+                  .forEach(output::add);
+            return rc;
+        }
+
+        boolean contains(String s) {
+            return output.contains(s);
+        }
+
+        List<String> output() {
+            return output;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m1/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m1 {
+    exports p1;
+    uses p1.S;
+    provides p1.S with p1.Impl;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m1/p1/Impl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public class Impl implements S {
+    public String name() {
+        return this.getClass().getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m1/p1/Main.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,53 @@
+/*
+ * 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 p1;
+
+import java.lang.module.ModuleFinder;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * This tests if JAVA_HOME is linked only with the specified modules.
+ */
+public class Main {
+    public static void main(String... args) {
+        Set<String> modules = ModuleFinder.ofSystem().findAll().stream()
+            .map(mref -> mref.descriptor().name())
+            .filter(mn -> !mn.equals("java.base"))
+            .collect(Collectors.toSet());
+
+        Set<String> notLinked = Stream.of(args).filter(mn -> !modules.contains(mn))
+                                      .collect(Collectors.toSet());
+        if (!notLinked.isEmpty()) {
+            throw new RuntimeException("Expected modules not linked in the image: "
+                + notLinked);
+        }
+        Stream.of(args).forEach(modules::remove);
+
+        if (!modules.isEmpty()) {
+            throw new RuntimeException("Unexpected modules linked in the image: "
+                + modules);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m1/p1/S.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public interface S {
+    String name();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m2/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m2 {
+    requires m1;
+    exports p2;
+    uses p2.T;
+    provides p1.S with p2.Impl;
+    provides p2.T with p2.Impl;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m2/p2/Impl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p2;
+
+public class Impl implements p1.S, T {
+    public String name() {
+        return this.getClass().getName();
+    }
+
+    public void run() {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m2/p2/T.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p2;
+
+public interface T {
+    void run();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m3/module-info.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m3 {
+    requires m2;
+    provides p2.T with p3.Impl;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/bindservices/src/m3/p3/Impl.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p3;
+
+public class Impl implements p2.T {
+    public void run() {
+    }
+}
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -81,9 +81,13 @@
             Path msrc = SRC_DIR.resolve(mn);
             if (version.equals("0")) {
                 assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
+                    "--add-exports", "java.base/jdk.internal.module=m1",
+                    "--add-exports", "java.base/jdk.internal.org.objectweb.asm=m1",
                     "--module-source-path", SRC_DIR.toString()));
             } else {
                 assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
+                    "--add-exports", "java.base/jdk.internal.module=m1",
+                    "--add-exports", "java.base/jdk.internal.org.objectweb.asm=m1",
                     "--module-source-path", SRC_DIR.toString(),
                     "--module-version", version));
             }
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -25,6 +25,8 @@
 import java.lang.module.ModuleDescriptor.*;
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
+import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -40,7 +42,11 @@
 /**
  * @test
  * @bug 8142968 8173381
+ * @library /lib/testlibrary
  * @modules java.base/jdk.internal.misc
+ * @modules java.base/jdk.internal.module
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * @build ModuleTargetHelper
  * @run testng SystemModulesTest
  * @summary Verify the properties of ModuleDescriptor created
  *          by SystemModules
@@ -62,7 +68,6 @@
             return;
 
         ModuleFinder.ofSystem().findAll().stream()
-                    .map(ModuleReference::descriptor)
                     .forEach(this::checkAttributes);
     }
 
@@ -72,9 +77,7 @@
         if (name.equals(OS_NAME))
             return true;
 
-        if (OS_NAME.equals("Mac OS X")) {
-            return name.equals("Darwin");
-        } else if (OS_NAME.startsWith("Windows")) {
+        if (OS_NAME.startsWith("Windows")) {
             return name.startsWith("Windows");
         } else {
             System.err.println("ERROR: " + name + " but expected: " + OS_NAME);
@@ -89,28 +92,28 @@
         switch (OS_ARCH) {
             case "i386":
             case "x86":
-                return name.equals("i586");
+                return name.equals("x86");
+            case "amd64":
+                return name.equals("x86_64");
             default:
                 System.err.println("ERROR: " + name + " but expected: " + OS_ARCH);
                 return false;
         }
     }
 
-    private void checkAttributes(ModuleDescriptor md) {
-        System.out.format("%s %s %s %s%n", md.name(),
-                          md.osName(), md.osArch(), md.osVersion());
-
-        if (md.name().equals("java.base")) {
-            assertTrue(checkOSName(md.osName().get()));
-            assertTrue(checkOSArch(md.osArch().get()));
-            assertTrue(md.osVersion().isPresent());
-        } else {
-            // target platform attribute is dropped by jlink plugin
-            assertFalse(md.osName().isPresent());
-            assertFalse(md.osArch().isPresent());
-            assertFalse(md.osVersion().isPresent());
-            assertTrue(md.packages().size() > 0
-                || EMPTY_MODULES.contains(md.name()), md.name());
+    private void checkAttributes(ModuleReference modRef) {
+        try {
+            if (modRef.descriptor().name().equals("java.base")) {
+                ModuleTargetHelper.ModuleTarget mt = ModuleTargetHelper.read(modRef);
+                assertTrue(checkOSName(mt.osName()));
+                assertTrue(checkOSArch(mt.osArch()));
+            } else {
+                // target platform attribute is dropped by jlink plugin for other modules
+                ModuleTargetHelper.ModuleTarget mt = ModuleTargetHelper.read(modRef);
+                assertTrue(mt == null || (mt.osName() == null && mt.osArch() == null));
+            }
+        } catch (IOException exp) {
+            throw new UncheckedIOException(exp);
         }
     }
 
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Wed Jul 05 23:09:40 2017 +0200
@@ -38,7 +38,6 @@
 
 import static jdk.testlibrary.ProcessTools.*;
 
-
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
@@ -48,7 +47,9 @@
  * @bug 8142968 8173381 8174740
  * @library /lib/testlibrary
  * @modules jdk.compiler jdk.jlink
- * @build UserModuleTest CompilerUtils jdk.testlibrary.FileUtils jdk.testlibrary.ProcessTools
+ * @modules java.base/jdk.internal.module
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * @build ModuleTargetHelper UserModuleTest CompilerUtils jdk.testlibrary.FileUtils jdk.testlibrary.ProcessTools
  * @run testng UserModuleTest
  */
 
@@ -85,7 +86,9 @@
         for (String mn : modules) {
             Path msrc = SRC_DIR.resolve(mn);
             assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
-                "--module-source-path", SRC_DIR.toString()));
+                "--module-source-path", SRC_DIR.toString(),
+                "--add-exports", "java.base/jdk.internal.module=" + mn,
+                "--add-exports", "java.base/jdk.internal.org.objectweb.asm=" + mn));
         }
 
         if (Files.exists(IMAGE)) {
@@ -106,7 +109,10 @@
         if (!hasJmods()) return;
 
         Path java = IMAGE.resolve("bin").resolve("java");
-        assertTrue(executeProcess(java.toString(), "-m", MAIN_MID)
+        assertTrue(executeProcess(java.toString(),
+                        "--add-exports", "java.base/jdk.internal.module=m1,m4",
+                        "--add-exports", "java.base/jdk.internal.org.objectweb.asm=m1,m4",
+                        "-m", MAIN_MID)
                         .outputTo(System.out)
                         .errorTo(System.out)
                         .getExitValue() == 0);
@@ -136,6 +142,8 @@
 
         Path java = IMAGE.resolve("bin").resolve("java");
         assertTrue(executeProcess(java.toString(),
+                                  "--add-exports", "java.base/jdk.internal.module=m1,m4",
+                                  "--add-exports", "java.base/jdk.internal.org.objectweb.asm=m1,m4",
                                   "-Djdk.system.module.finder.disabledFastPath",
                                   "-m", MAIN_MID)
                         .outputTo(System.out)
@@ -154,7 +162,10 @@
         Path dir = Paths.get("dedupSetTest");
         createImage(dir, "m1", "m2", "m3", "m4");
         Path java = dir.resolve("bin").resolve("java");
-        assertTrue(executeProcess(java.toString(), "-m", MAIN_MID)
+        assertTrue(executeProcess(java.toString(),
+                         "--add-exports", "java.base/jdk.internal.module=m1,m4",
+                         "--add-exports", "java.base/jdk.internal.org.objectweb.asm=m1,m4",
+                         "-m", MAIN_MID)
                         .outputTo(System.out)
                         .errorTo(System.out)
                         .getExitValue() == 0);
@@ -205,11 +216,13 @@
     }
 
     private void createJmods(String... modules) throws IOException {
-        // use the same target platform as in java.base
-        ModuleDescriptor md = Layer.boot().findModule("java.base").get()
-                                   .getDescriptor();
-        String osName = md.osName().get();
-        String osArch = md.osArch().get();
+        ModuleTargetHelper.ModuleTarget mt = ModuleTargetHelper.getJavaBaseTarget();
+        if (mt == null) {
+            throw new RuntimeException("ModuleTarget is missing for java.base");
+        }
+
+        String osName = mt.osName();
+        String osArch = mt.osArch();
 
         // create JMOD files
         Files.createDirectories(JMODS_DIR);
@@ -246,6 +259,8 @@
         // verify ModuleDescriptor
         Path java = dir.resolve("bin").resolve("java");
         assertTrue(executeProcess(java.toString(),
+                        "--add-exports", "java.base/jdk.internal.module=m1,m4",
+                        "--add-exports", "java.base/jdk.internal.org.objectweb.asm=m1,m4",
                         "--add-modules=m1", "-m", "m4")
             .outputTo(System.out)
             .errorTo(System.out)
@@ -275,6 +290,8 @@
         // verify ModuleDescriptor
         Path java = dir.resolve("bin").resolve("java");
         assertTrue(executeProcess(java.toString(),
+                        "--add-exports", "java.base/jdk.internal.module=m1,m4",
+                        "--add-exports", "java.base/jdk.internal.org.objectweb.asm=m1,m4",
                         "--add-modules=m1", "-m", "m4", "retainModuleTarget")
             .outputTo(System.out)
             .errorTo(System.out)
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m1/p1/Main.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m1/p1/Main.java	Wed Jul 05 23:09:40 2017 +0200
@@ -23,6 +23,7 @@
 
 package p1;
 
+import java.io.InputStream;
 import java.io.IOException;
 import java.lang.module.ModuleDescriptor;
 import java.lang.reflect.Layer;
@@ -35,7 +36,38 @@
 import java.util.Collections;
 import java.util.Set;
 
+import jdk.internal.module.ClassFileAttributes;
+import jdk.internal.module.ClassFileAttributes.ModuleTargetAttribute;
+import jdk.internal.module.ClassFileConstants;
+import jdk.internal.org.objectweb.asm.Attribute;
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+
 public class Main {
+    private static boolean hasModuleTarget(InputStream in) throws IOException {
+        ModuleTargetAttribute[] modTargets = new ModuleTargetAttribute[1];
+        ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
+            @Override
+            public void visitAttribute(Attribute attr) {
+                if (attr instanceof ModuleTargetAttribute) {
+                    modTargets[0] = (ModuleTargetAttribute)attr;
+                }
+            }
+        };
+
+        // prototype of attributes that should be parsed
+        Attribute[] attrs = new Attribute[] {
+            new ModuleTargetAttribute()
+        };
+
+        // parse module-info.class
+        ClassReader cr = new ClassReader(in);
+        cr.accept(cv, attrs, 0);
+        return modTargets[0] != null &&
+            (modTargets[0].osName() != null || modTargets[0].osArch() != null);
+    }
+
     public static void main(String... args) throws Exception {
         // load another package
         p2.T.test();
@@ -44,12 +76,13 @@
         validate(Main.class.getModule());
 
         // validate the Moduletarget attribute for java.base
-        ModuleDescriptor md = Layer.boot().findModule("java.base").get()
-                                   .getDescriptor();
-        if (!md.osName().isPresent() || !md.osArch().isPresent() ||
-                !md.osVersion().isPresent()) {
-            throw new RuntimeException("java.base: " + md.osName() + " " +
-                    md.osArch() + " " + md.osVersion());
+        FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"),
+                                                  Collections.emptyMap());
+        Path path = fs.getPath("/", "modules", "java.base", "module-info.class");
+        try (InputStream in = Files.newInputStream(path)) {
+            if (! hasModuleTarget(in)) {
+                throw new RuntimeException("Missing ModuleTarget for java.base");
+            }
         }
     }
 
@@ -67,9 +100,9 @@
         checkPackages(md.packages(), "p1", "p2");
         checkPackages(md1.packages(), "p1", "p2");
 
-        // check ModuleTarget attribute
-        checkModuleTargetAttribute(md);
-        checkModuleTargetAttribute(md1);
+        try (InputStream in = Files.newInputStream(path)) {
+            checkModuleTargetAttribute(in, "p1");
+        }
     }
 
     static void checkPackages(Set<String> pkgs, String... expected) {
@@ -78,10 +111,9 @@
         }
     }
 
-    static void checkModuleTargetAttribute(ModuleDescriptor md) {
-        if (md.osName().isPresent() || md.osArch().isPresent() ||
-                md.osVersion().isPresent()) {
-            throw new RuntimeException(md.osName() + " " + md.osArch() + " " + md.osVersion());
+    static void checkModuleTargetAttribute(InputStream in, String modName) throws IOException {
+        if (hasModuleTarget(in)) {
+            throw new RuntimeException("ModuleTarget present for " + modName);
         }
     }
 }
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m4/p4/Main.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m4/p4/Main.java	Wed Jul 05 23:09:40 2017 +0200
@@ -36,7 +36,47 @@
 import java.util.Collections;
 import java.util.Set;
 
+import jdk.internal.module.ClassFileAttributes;
+import jdk.internal.module.ClassFileAttributes.ModuleTargetAttribute;
+import jdk.internal.module.ClassFileConstants;
+import jdk.internal.org.objectweb.asm.Attribute;
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+
 public class Main {
+    private static boolean hasModuleTarget(InputStream in) throws IOException {
+        ModuleTargetAttribute[] modTargets = new ModuleTargetAttribute[1];
+        ClassVisitor cv = new ClassVisitor(Opcodes.ASM5) {
+            @Override
+            public void visitAttribute(Attribute attr) {
+                if (attr instanceof ModuleTargetAttribute) {
+                    modTargets[0] = (ModuleTargetAttribute)attr;
+                }
+            }
+        };
+
+        // prototype of attributes that should be parsed
+        Attribute[] attrs = new Attribute[] {
+            new ModuleTargetAttribute()
+        };
+
+        // parse module-info.class
+        ClassReader cr = new ClassReader(in);
+        cr.accept(cv, attrs, 0);
+        return modTargets[0] != null &&
+            (modTargets[0].osName() != null || modTargets[0].osArch() != null);
+    }
+
+    private static boolean hasModuleTarget(String modName) throws IOException {
+        FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"),
+                                                  Collections.emptyMap());
+        Path path = fs.getPath("/", "modules", modName, "module-info.class");
+        try (InputStream in = Files.newInputStream(path)) {
+            return hasModuleTarget(in);
+        }
+    }
+
     // the system module plugin by default drops ModuleTarget attribute
     private static boolean expectModuleTarget = false;
     public static void main(String... args) throws IOException {
@@ -49,13 +89,8 @@
         }
 
         // java.base is packaged with osName/osArch/osVersion
-        ModuleDescriptor md = Layer.boot().findModule("java.base").get()
-                                   .getDescriptor();
-        if (!md.osName().isPresent() ||
-                !md.osArch().isPresent() ||
-                !md.osVersion().isPresent()) {
-            throw new RuntimeException("osName/osArch/osVersion is missing: " +
-                md.osName() + " " + md.osArch() + " " + md.osVersion());
+        if (! hasModuleTarget("java.base")) {
+            throw new RuntimeException("ModuleTarget absent for java.base");
         }
 
         // verify module-info.class for m1 and m4
@@ -82,7 +117,7 @@
         checkModuleDescriptor(ModuleDescriptor.read(Files.newInputStream(path)), packages);
     }
 
-    static void checkModuleDescriptor(ModuleDescriptor md, String... packages) {
+    static void checkModuleDescriptor(ModuleDescriptor md, String... packages) throws IOException {
         String mainClass = md.name().replace('m', 'p') + ".Main";
         if (!md.mainClass().get().equals(mainClass)) {
             throw new RuntimeException(md.mainClass().toString());
@@ -90,22 +125,16 @@
 
         if (expectModuleTarget) {
             // ModuleTarget attribute is retained
-            if (!md.osName().isPresent() || !md.osArch().isPresent()) {
-                throw new RuntimeException("osName or osArch is missing: " +
-                    md.osName() + " " + md.osArch());
+            if (! hasModuleTarget(md.name())) {
+                throw new RuntimeException("ModuleTarget missing for " + md.name());
             }
         } else {
             // by default ModuleTarget attribute is dropped
-            if (md.osName().isPresent() || md.osArch().isPresent()) {
-                throw new RuntimeException("osName and osArch should not be set: " +
-                    md.osName() + " " + md.osArch());
+            if (hasModuleTarget(md.name())) {
+                throw new RuntimeException("ModuleTarget present for " + md.name());
             }
         }
 
-        if (md.osVersion().isPresent()) {
-            throw new RuntimeException("Expected no osVersion set: " + md.osVersion());
-        }
-
         Set<String> pkgs = md.packages();
         if (!pkgs.equals(Set.of(packages))) {
             throw new RuntimeException(pkgs + " expected: " + Set.of(packages));
--- a/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java	Wed Jul 05 23:09:40 2017 +0200
@@ -134,16 +134,16 @@
         return new Object[][]{
 
             // source not found
-            {"DoesNotExist/p=m1",  "WARNING: Unknown module: DoesNotExist specified in --add-exports"},
+            {"DoesNotExist/p=m1",  "WARNING: Unknown module: DoesNotExist specified to --add-exports"},
             {"m1/DoesNotExist=m2", "WARNING: package DoesNotExist not in m1"},
 
             // target not found
-            {"m1/p1=DoesNotExist", "WARNING: Unknown module: DoesNotExist specified in --add-exports"},
+            {"m1/p1=DoesNotExist", "WARNING: Unknown module: DoesNotExist specified to --add-exports"},
 
             // bad names
-            {"m*/p1=m2",           "WARNING: Unknown module: m* specified in --add-exports"},
+            {"m*/p1=m2",           "WARNING: Unknown module: m* specified to --add-exports"},
             {"m1/p!=m2",           "WARNING: package p! not in m1"},
-            {"m1/p1=m!",           "WARNING: Unknown module: m! specified in --add-exports"},
+            {"m1/p1=m!",           "WARNING: Unknown module: m! specified to --add-exports"},
 
         };
     }
--- a/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java	Wed Jul 05 23:09:40 2017 +0200
@@ -168,14 +168,14 @@
         return new Object[][]{
 
             // source not found
-            {"DoesNotExist=m2",    "WARNING: Unknown module: DoesNotExist specified in --add-reads"},
+            {"DoesNotExist=m2",    "WARNING: Unknown module: DoesNotExist specified to --add-reads"},
 
             // target not found
-            {"m2=DoesNotExist",    "WARNING: Unknown module: DoesNotExist specified in --add-reads"},
+            {"m2=DoesNotExist",    "WARNING: Unknown module: DoesNotExist specified to --add-reads"},
 
             // bad names
-            {"m*=m2",              "WARNING: Unknown module: m* specified in --add-reads"},
-            {"m2=m!",              "WARNING: Unknown module: m! specified in --add-reads"},
+            {"m*=m2",              "WARNING: Unknown module: m* specified to --add-reads"},
+            {"m2=m!",              "WARNING: Unknown module: m! specified to --add-reads"},
 
         };
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/basic/InitErrors.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @library /lib/testlibrary
+ * @build InitErrors jdk.testlibrary.*
+ * @run testng InitErrors
+ * @summary Basic test to ensure that module system initialization errors
+ *          go the right stream and with the right level of verbosity
+ */
+
+
+import java.util.Arrays;
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.OutputAnalyzer;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+public class InitErrors {
+
+    // the option to cause module initialization to fail
+    private static final String ADD_UNKNOWN_MODULE = "--add-modules=XXX";
+
+    // the expected error message
+    private static final String UNKNOWN_MODULE_NOT_FOUND= "Module XXX not found";
+
+    // output expected in the stack trace when using -Xlog:init=debug
+    private static final String STACK_FRAME = "java.base/java.lang.System.initPhase2";
+
+
+    /**
+     * Default behavior, send error message to stdout
+     */
+    @Test
+    public void testDefaultOutput() throws Exception {
+        expectFail(showVersion(ADD_UNKNOWN_MODULE)
+                .stdoutShouldContain(UNKNOWN_MODULE_NOT_FOUND)
+                .stdoutShouldNotContain(STACK_FRAME)
+                .stderrShouldNotContain(UNKNOWN_MODULE_NOT_FOUND)
+                .stderrShouldNotContain(STACK_FRAME));
+    }
+
+    /**
+     * -XX:+DisplayVMOutputToStderr should send error message to stderr
+     */
+    @Test
+    public void testOutputToStderr() throws Exception {
+        expectFail(showVersion(ADD_UNKNOWN_MODULE, "-XX:+DisplayVMOutputToStderr")
+                .stdoutShouldNotContain(UNKNOWN_MODULE_NOT_FOUND)
+                .stdoutShouldNotContain(STACK_FRAME)
+                .stderrShouldContain(UNKNOWN_MODULE_NOT_FOUND)
+                .stderrShouldNotContain(STACK_FRAME));
+    }
+
+    /**
+     * -Xlog:init=debug should print stack trace to stdout
+     */
+    @Test
+    public void testStackTrace() throws Exception {
+        expectFail(showVersion(ADD_UNKNOWN_MODULE, "-Xlog:init=debug")
+                .stdoutShouldContain(UNKNOWN_MODULE_NOT_FOUND)
+                .stdoutShouldContain(STACK_FRAME)
+                .stderrShouldNotContain(UNKNOWN_MODULE_NOT_FOUND)
+                .stderrShouldNotContain(STACK_FRAME));
+    }
+
+    /**
+     * -Xlog:init=debug -XX:+DisplayVMOutputToStderr should print stack trace
+     * to stderr
+     */
+    @Test
+    public void testStackTraceToStderr() throws Exception {
+        expectFail(showVersion(ADD_UNKNOWN_MODULE,
+                               "-Xlog:init=debug",
+                               "-XX:+DisplayVMOutputToStderr")
+                .stdoutShouldNotContain(UNKNOWN_MODULE_NOT_FOUND)
+                .stdoutShouldNotContain(STACK_FRAME)
+                .stderrShouldContain(UNKNOWN_MODULE_NOT_FOUND)
+                .stderrShouldContain(STACK_FRAME));
+    }
+
+    private OutputAnalyzer showVersion(String... args) throws Exception {
+        int len = args.length;
+        args = Arrays.copyOf(args, len+1);
+        args[len] = "-version";
+        return ProcessTools.executeTestJava(args)
+                .outputTo(System.out)
+                .errorTo(System.out);
+    }
+
+    private void expectFail(OutputAnalyzer output) {
+        assertFalse(output.getExitValue() == 0);
+    }
+
+}
--- a/jdk/test/tools/launcher/modules/patch/basic/PatchTestWarningError.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/launcher/modules/patch/basic/PatchTestWarningError.java	Wed Jul 05 23:09:40 2017 +0200
@@ -179,7 +179,7 @@
                             "-m", "test/jdk.test.Main", arg)
                 .outputTo(System.out)
                 .errorTo(System.out)
-                .shouldContain("WARNING: Unknown module: DoesNotExist specified in --patch-module")
+                .shouldContain("WARNING: Unknown module: DoesNotExist specified to --patch-module")
                 .getExitValue();
 
         assertTrue(exitValue == 0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/permit/AttemptAccess.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * Launched by PermitIllegalAccess to attempt illegal access.
+ */
+
+public class AttemptAccess {
+
+    public static void main(String[] args) throws Exception {
+        String action = args[0];
+        int count = Integer.parseInt(args[1]);
+
+        for (int i=0; i<count; i++) {
+            switch (action) {
+                case "access":
+                    tryAccess();
+                    break;
+                case "setAccessible":
+                    trySetAccessible();
+                    break;
+                case "trySetAccessible":
+                    tryTrySetAccessible();
+                    break;
+            }
+        }
+    }
+
+    static void tryAccess() throws Exception {
+        Class<?> clazz = Class.forName("sun.security.x509.X500Name");
+        Constructor<?> ctor = clazz.getConstructor(String.class);
+        Object name = ctor.newInstance("CN=user");
+    }
+
+    static void trySetAccessible() throws Exception {
+        Method find = ClassLoader.class.getDeclaredMethod("findClass", String.class);
+        find.setAccessible(true);
+    }
+
+    static void tryTrySetAccessible() throws Exception {
+        Method find = ClassLoader.class.getDeclaredMethod("findClass", String.class);
+        find.trySetAccessible();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/permit/PermitIllegalAccess.java	Wed Jul 05 23:09:40 2017 +0200
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @library /lib/testlibrary
+ * @build PermitIllegalAccess AttemptAccess jdk.testlibrary.*
+ * @run testng PermitIllegalAccess
+ * @summary Basic test for java --permit-illegal-access
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Stream;
+
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.OutputAnalyzer;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * Basic test of --permit-illegal-access to ensure that it permits access
+ * via core reflection and setAccessible/trySetAccessible.
+ */
+
+@Test
+public class PermitIllegalAccess {
+
+    static final String TEST_CLASSES = System.getProperty("test.classes");
+    static final String TEST_MAIN = "AttemptAccess";
+
+    static final String WARNING = "WARNING";
+    static final String STARTUP_WARNING =
+        "WARNING: --permit-illegal-access will be removed in the next major release";
+    static final String ILLEGAL_ACCESS_WARNING =
+        "WARNING: Illegal access by " + TEST_MAIN;
+
+    /**
+     * Launches AttemptAccess to execute an action, returning the OutputAnalyzer
+     * to analyze the output/exitCode.
+     */
+    private OutputAnalyzer tryAction(String action, int count, String... args)
+        throws Exception
+    {
+        Stream<String> s1 = Stream.of(args);
+        Stream<String> s2 = Stream.of("-cp", TEST_CLASSES, TEST_MAIN, action, "" + count);
+        String[] opts = Stream.concat(s1, s2).toArray(String[]::new);
+        return ProcessTools.executeTestJava(opts)
+                .outputTo(System.out)
+                .errorTo(System.out);
+    }
+
+    /**
+     * Launches AttemptAccess with --permit-illegal-access to execute an action,
+     * returning the OutputAnalyzer to analyze the output/exitCode.
+     */
+    private OutputAnalyzer tryActionPermittingIllegalAccess(String action, int count)
+        throws Exception
+    {
+        return tryAction(action, count, "--permit-illegal-access");
+    }
+
+    /**
+     * Sanity check to ensure that IllegalAccessException is thrown.
+     */
+    public void testAccessFail() throws Exception {
+        int exitValue = tryAction("access", 1)
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("IllegalAccessException")
+                .stderrShouldNotContain(WARNING)
+                .stderrShouldContain("IllegalAccessException")
+                .getExitValue();
+        assertTrue(exitValue != 0);
+    }
+
+    /**
+     * Sanity check to ensure that InaccessibleObjectException is thrown.
+     */
+    public void testSetAccessibleFail() throws Exception {
+        int exitValue = tryAction("setAccessible", 1)
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("InaccessibleObjectException")
+                .stderrShouldNotContain(WARNING)
+                .stderrShouldContain("InaccessibleObjectException")
+                .getExitValue();
+        assertTrue(exitValue != 0);
+    }
+
+    /**
+     * Permit illegal access to succeed
+     */
+    public void testAccessPermitted() throws Exception {
+        tryActionPermittingIllegalAccess("access", 1)
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("IllegalAccessException")
+                .stderrShouldContain(STARTUP_WARNING)
+                .stderrShouldNotContain("IllegalAccessException")
+                .stderrShouldContain(ILLEGAL_ACCESS_WARNING)
+                .shouldHaveExitValue(0);
+    }
+
+    /**
+     * Permit repeated illegal access to succeed
+     */
+    public void testRepeatedAccessPermitted() throws Exception {
+        OutputAnalyzer outputAnalyzer = tryActionPermittingIllegalAccess("access", 10)
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("IllegalAccessException")
+                .stderrShouldContain(STARTUP_WARNING)
+                .stderrShouldNotContain("IllegalAccessException")
+                .stderrShouldContain(ILLEGAL_ACCESS_WARNING)
+                .shouldHaveExitValue(0);;
+
+        // should only have one illegal access warning
+        assertTrue(containsCount(outputAnalyzer.asLines(), ILLEGAL_ACCESS_WARNING) == 1);
+    }
+
+    /**
+     * Permit setAccessible to succeed
+     */
+    public void testSetAccessiblePermitted() throws Exception {
+        tryActionPermittingIllegalAccess("setAccessible", 1)
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("InaccessibleObjectException")
+                .stderrShouldContain(STARTUP_WARNING)
+                .stderrShouldNotContain("InaccessibleObjectException")
+                .stderrShouldContain(ILLEGAL_ACCESS_WARNING)
+                .shouldHaveExitValue(0);
+    }
+
+    /**
+     * Permit repeated calls to setAccessible to succeed
+     */
+    public void testRepeatedSetAccessiblePermitted() throws Exception {
+        OutputAnalyzer outputAnalyzer = tryActionPermittingIllegalAccess("setAccessible", 10)
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("InaccessibleObjectException")
+                .stderrShouldContain(STARTUP_WARNING)
+                .stderrShouldNotContain("InaccessibleObjectException")
+                .stderrShouldContain(ILLEGAL_ACCESS_WARNING)
+                .shouldHaveExitValue(0);
+
+        // should only have one illegal access warning
+        assertTrue(containsCount(outputAnalyzer.asLines(), ILLEGAL_ACCESS_WARNING) == 1);
+    }
+
+    /**
+     * Permit trySetAccessible to succeed
+     */
+    public void testTrySetAccessiblePermitted() throws Exception {
+        tryActionPermittingIllegalAccess("trySetAccessible", 1)
+                .stdoutShouldNotContain(WARNING)
+                .stderrShouldContain(STARTUP_WARNING)
+                .stderrShouldContain(ILLEGAL_ACCESS_WARNING)
+                .shouldHaveExitValue(0);
+    }
+
+    /**
+     * Permit repeated calls to trySetAccessible to succeed
+     */
+    public void testRepeatedTrySetAccessiblePermitted() throws Exception {
+        OutputAnalyzer outputAnalyzer = tryActionPermittingIllegalAccess("trySetAccessible", 10)
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("InaccessibleObjectException")
+                .stderrShouldContain(STARTUP_WARNING)
+                .stderrShouldNotContain("InaccessibleObjectException")
+                .stderrShouldContain(ILLEGAL_ACCESS_WARNING)
+                .shouldHaveExitValue(0);
+
+        // should only have one illegal access warning
+        assertTrue(containsCount(outputAnalyzer.asLines(), ILLEGAL_ACCESS_WARNING) == 1);
+
+    }
+
+    /**
+     * Permit access to succeed with --add-exports. No warning should be printed.
+     */
+    public void testAccessWithAddExports() throws Exception {
+        tryAction("access", 1, "--add-exports", "java.base/sun.security.x509=ALL-UNNAMED")
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("IllegalAccessException")
+                .stderrShouldNotContain(WARNING)
+                .stderrShouldNotContain("IllegalAccessException")
+                .shouldHaveExitValue(0);
+    }
+
+    /**
+     * Permit access to succeed with --add-exports and --permit-illegal-access.
+     * The only warning emitted should be the startup warning.
+     */
+    public void testAccessWithePermittedAddExports() throws Exception {
+        tryAction("access", 1, "--permit-illegal-access",
+                    "--add-exports", "java.base/sun.security.x509=ALL-UNNAMED")
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("IllegalAccessException")
+                .stderrShouldContain(STARTUP_WARNING)
+                .stderrShouldNotContain("IllegalAccessException")
+                .stderrShouldNotContain(ILLEGAL_ACCESS_WARNING)
+                .shouldHaveExitValue(0);
+    }
+
+    /**
+     * Permit setAccessible to succeed with --add-opens. No warning should be printed.
+     */
+    public void testSetAccessibleWithAddOpens() throws Exception {
+        tryAction("setAccessible", 1, "--add-opens", "java.base/java.lang=ALL-UNNAMED")
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("InaccessibleObjectException")
+                .stderrShouldNotContain(WARNING)
+                .stderrShouldNotContain("InaccessibleObjectException")
+                .shouldHaveExitValue(0);
+    }
+
+    /**
+     * Permit setAccessible to succeed with both --add-opens and --permit-illegal-access.
+     * The only warning emitted should be the startup warning.
+     */
+    public void testSetAccessiblePermittedWithAddOpens() throws Exception {
+        tryAction("setAccessible", 1, "--permit-illegal-access",
+                    "--add-opens", "java.base/java.lang=ALL-UNNAMED")
+                .stdoutShouldNotContain(WARNING)
+                .stdoutShouldNotContain("InaccessibleObjectException")
+                .stderrShouldContain(STARTUP_WARNING)
+                .stderrShouldNotContain("InaccessibleObjectException")
+                .stderrShouldNotContain(ILLEGAL_ACCESS_WARNING)
+                .shouldHaveExitValue(0);
+    }
+
+
+    /**
+     * Returns the number of lines in the given input that contain the
+     * given char sequence.
+     */
+    private int containsCount(List<String> lines, CharSequence cs) {
+        int count = 0;
+        for (String line : lines) {
+            if (line.contains(cs)) count++;
+        }
+        return count;
+    }
+}
--- a/jdk/test/tools/pack200/pack200-verifier/src/xmlkit/ClassReader.java	Sat Apr 08 03:25:14 2017 +0000
+++ b/jdk/test/tools/pack200/pack200-verifier/src/xmlkit/ClassReader.java	Wed Jul 05 23:09:40 2017 +0200
@@ -1544,7 +1544,6 @@
         Element e = new Element(x.getCpString(attr.attribute_name_index));
         e.add(x.getCpString(attr.os_name_index));
         e.add(x.getCpString(attr.os_arch_index));
-        e.add(x.getCpString(attr.os_version_index));
         e.trimToSize();
         p.add(e);
         return null;
--- a/make/CreateJmods.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/make/CreateJmods.gmk	Wed Jul 05 23:09:40 2017 +0200
@@ -135,9 +135,8 @@
 	$(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
 	$(JMOD) create \
             --module-version $(VERSION_SHORT) \
-            --os-name $(REQUIRED_OS_NAME) \
-            --os-arch $(OPENJDK_TARGET_CPU_LEGACY) \
-            --os-version $(REQUIRED_OS_VERSION) \
+            --os-name '$(REQUIRED_OS_NAME)' \
+            --os-arch '$(REQUIRED_OS_ARCH)' \
             --module-path $(JMODS_DIR) \
 	    --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
 	    $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@)
--- a/make/Images.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/make/Images.gmk	Wed Jul 05 23:09:40 2017 +0200
@@ -119,6 +119,7 @@
     --module-path $(IMAGES_OUTPUTDIR)/jmods \
     --endian $(OPENJDK_BUILD_CPU_ENDIAN) \
     --release-info $(BASE_RELEASE_FILE) \
+    --release-info add:OS_VERSION=\"$(REQUIRED_OS_VERSION)\" \
     --order-resources=$(call CommaList, $(JLINK_ORDER_RESOURCES)) \
     --dedup-legal-notices=error-if-not-same-content \
     $(JLINK_JLI_CLASSES) \
--- a/make/Init.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/make/Init.gmk	Wed Jul 05 23:09:40 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	Sat Apr 08 03:25:14 2017 +0000
+++ b/make/InitSupport.gmk	Wed Jul 05 23:09:40 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/Javadoc.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/make/Javadoc.gmk	Wed Jul 05 23:09:40 2017 +0200
@@ -27,6 +27,7 @@
 include $(SPEC)
 include MakeBase.gmk
 include $(JDK_TOPDIR)/make/Tools.gmk
+include $(JDK_TOPDIR)/make/ModuleTools.gmk
 
 ################################################################################
 
@@ -174,6 +175,7 @@
     -tag param \
     -tag return \
     -tag throws \
+    -taglet build.tools.taglet.ModuleGraph \
     -tag since \
     -tag version \
     -tag serialData \
@@ -188,6 +190,13 @@
 DEFAULT_JAVADOC_OPTIONS := -XDignore.symbol.file=true -use -keywords -notimestamp \
     -serialwarn -encoding ISO-8859-1 -breakiterator --system none
 
+#
+# TODO: this should be set by the configure option.
+#
+ifndef ENABLE_MODULE_GRAPH
+   ENABLE_MODULE_GRAPH=false
+endif
+
 ################################################################################
 # Setup make rules for running javadoc.
 #
@@ -321,7 +330,8 @@
 	  $$(eval $$(call ListPathsSafely, $1_PACKAGES, $$($1_PACKAGES_FILE)))
         endif
 	$$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/docs/$1.javadoc, \
-	    $$($1_JAVA) -Djava.awt.headless=true $(NEW_JAVADOC) -d $$(@D) \
+	    $$($1_JAVA) -Djava.awt.headless=true -DenableModuleGraph=$(ENABLE_MODULE_GRAPH) \
+		$(NEW_JAVADOC) -d $$(@D) \
 	        $$(DEFAULT_JAVADOC_TAGS) $$(DEFAULT_JAVADOC_OPTIONS) \
 	        --module-source-path $$(call PathList, $$(JAVADOC_SOURCE_DIRS)) \
 	        $$($1_OPTIONS) $$($1_PACKAGES_ARG))
@@ -735,18 +745,34 @@
 ZIP_TARGETS += $(JAVADOC_ARCHIVE)
 
 ################################################################################
+# generate .dot files for module graphs
+
+JAVADOC_MODULE_GRAPHS_DIR := $(SUPPORT_OUTPUTDIR)/docs/module-graphs
+JAVADOC_MODULE_GRAPHS := $(JAVADOC_MODULE_GRAPHS_DIR)/java.se.dot
+JAVADOC_MODULE_GRAPHS_PROPS := $(JDK_TOPDIR)/make/src/classes/build/tools/jigsaw/javadoc-graphs.properties
+
+$(JAVADOC_MODULE_GRAPHS): $(BUILD_JIGSAW_TOOLS) $(JAVADOC_MODULE_GRAPHS_PROPS)
+	$(MKDIR) -p $(@D)
+	$(TOOL_GENGRAPHS) --spec --output $(JAVADOC_MODULE_GRAPHS_DIR) \
+	    --dot-attributes $(JAVADOC_MODULE_GRAPHS_PROPS)
+
+MODULE_GRAPH_TARGETS += $(JAVADOC_MODULE_GRAPHS)
+
+################################################################################
 
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, , Javadoc.gmk))
 
 ################################################################################
 
+docs-module-graphs: $(MODULE_GRAPH_TARGETS) 
+
 docs-javadoc: $(TARGETS)
 
 docs-copy: $(COPY_TARGETS)
 
 docs-zip: $(ZIP_TARGETS)
 
-all: docs-javadoc docs-copy docs-zip
+all: docs-module-graphs docs-javadoc docs-copy docs-zip
 
-.PHONY: default all docs-javadoc docs-copy docs-zip
+.PHONY: default all docs-module-graphs docs-javadoc docs-copy docs-zip
--- a/make/Main.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/make/Main.gmk	Wed Jul 05 23:09:40 2017 +0200
@@ -363,6 +363,9 @@
 ################################################################################
 # Docs targets
 
+docs-module-graphs:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-module-graphs)
+
 docs-javadoc:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-javadoc)
 
@@ -375,7 +378,7 @@
 update-build-docs:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f UpdateBuildDocs.gmk)
 
-ALL_TARGETS += docs-javadoc docs-copy docs-zip update-build-docs
+ALL_TARGETS += docs-module-graphs docs-javadoc docs-copy docs-zip update-build-docs
 
 ################################################################################
 # Cross compilation support
@@ -772,6 +775,8 @@
 
   bootcycle-images: jdk-image
 
+  docs-module-graphs: exploded-image buildtools-modules 
+
   docs-javadoc: $(GENSRC_TARGETS) rmic
 
   # The gensrc step for jdk.jdi creates an html file that is used by docs-copy.
@@ -929,7 +934,7 @@
 endif
 
 # This target builds the documentation image
-docs-image: docs-javadoc docs-copy
+docs-image: docs-module-graphs docs-javadoc docs-copy
 
 # This target builds the test image
 test-image: prepare-test-image test-image-hotspot-jtreg-native \
--- a/make/common/MakeBase.gmk	Sat Apr 08 03:25:14 2017 +0000
+++ b/make/common/MakeBase.gmk	Wed Jul 05 23:09:40 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/nashorn/.hgtags	Sat Apr 08 03:25:14 2017 +0000
+++ b/nashorn/.hgtags	Wed Jul 05 23:09:40 2017 +0200
@@ -396,3 +396,6 @@
 d75af059cff651c1b5cccfeb4c9ea8d054b28cfd jdk-9+159
 9d4dbb8cbe7ce321c6e9e34dc9e0974760710907 jdk-9+160
 d6ef419af865dccf1e5be8047b0aba09286ffa93 jdk-9+161
+2cd29b339692524de64d049b329873facaff9727 jdk-9+162
+5e5e436543daea0c174d878d5e3ff8dd791e538a jdk-9+163
+b473fab09baab51a06ffba02eb06c7f5ee8578f7 jdk-9+164