Merge
authorduke
Wed, 05 Jul 2017 22:30:23 +0200
changeset 42252 a74bc7057efc
parent 42251 cddf48cf96e9 (current diff)
parent 42243 efa5b6fbe372 (diff)
child 42256 c33f23eb67a6
Merge
jdk/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCalls.c
jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_de_GR.properties
jdk/test/java/util/Locale/LocaleTestFmwk.java
jdk/test/javax/net/ssl/templates/SSLSocketSample.java
jdk/test/javax/net/ssl/templates/SSLTest.java
make/common/CORE_PKGS.gmk
make/common/NON_CORE_PKGS.gmk
--- a/.hgtags-top-repo	Fri Nov 25 11:16:51 2016 +0800
+++ b/.hgtags-top-repo	Wed Jul 05 22:30:23 2017 +0200
@@ -388,3 +388,4 @@
 1fc62b1c629fb80fdaa639d3b59452a184f0d705 jdk-9+143
 8d337fd6333e28c48aa87880144b840aad82baaf jdk-9+144
 ff98aa9ec9fae991e426ce5926fc9036d25f5562 jdk-9+145
+a22e2671d88f6b22a4aa82e3966986542ed2a381 jdk-9+146
--- a/common/autoconf/basics.m4	Fri Nov 25 11:16:51 2016 +0800
+++ b/common/autoconf/basics.m4	Wed Jul 05 22:30:23 2017 +0200
@@ -1048,7 +1048,9 @@
   # These tools might not be installed by default,
   # need hint on how to install them.
   BASIC_REQUIRE_PROGS(UNZIP, unzip)
-  BASIC_REQUIRE_PROGS(ZIP, zip)
+  # Since zip uses "ZIP" as a environment variable for passing options, we need
+  # to name our variable differently, hence ZIPEXE.
+  BASIC_REQUIRE_PROGS(ZIPEXE, zip)
 
   # Non-required basic tools
 
--- a/common/autoconf/flags.m4	Fri Nov 25 11:16:51 2016 +0800
+++ b/common/autoconf/flags.m4	Wed Jul 05 22:30:23 2017 +0200
@@ -311,7 +311,11 @@
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
     fi
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    PICFLAG="-KPIC"
+    if test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
+      PICFLAG="-xcode=pic32"
+    else
+      PICFLAG="-KPIC"
+    fi
     C_FLAG_REORDER='-xF'
     CXX_FLAG_REORDER='-xF'
     SHARED_LIBRARY_FLAGS="-G"
@@ -838,7 +842,6 @@
     fastdebug | slowdebug )
       $2CFLAGS_JDK="[$]$2CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
       $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
-      JAVAC_FLAGS="$JAVAC_FLAGS -g"
       ;;
     release )
       ;;
@@ -894,12 +897,12 @@
   # Set some additional per-OS defines.
   if test "x$OPENJDK_$1_OS" = xlinux; then
     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DLINUX"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
+    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -pipe $PICFLAG -fno-rtti -fno-exceptions \
         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
   elif test "x$OPENJDK_$1_OS" = xsolaris; then
     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSOLARIS"
     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -template=no%extdef -features=no%split_init \
-        -D_Crun_inline_placement -library=%none -KPIC -mt -features=no%except"
+        -D_Crun_inline_placement -library=%none $PICFLAG -mt -features=no%except"
   elif test "x$OPENJDK_$1_OS" = xmacosx; then
     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
     $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_ALLBSD_SOURCE"
@@ -1310,7 +1313,7 @@
   AC_MSG_CHECKING([if both compilers support "ARG_ARGUMENT"])
   supports=no
   if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
-  
+
   AC_MSG_RESULT([$supports])
   if test "x$supports" = "xyes" ; then
     :
--- a/common/autoconf/generated-configure.sh	Fri Nov 25 11:16:51 2016 +0800
+++ b/common/autoconf/generated-configure.sh	Wed Jul 05 22:30:23 2017 +0200
@@ -945,7 +945,7 @@
 READELF
 OTOOL
 LDD
-ZIP
+ZIPEXE
 UNZIP
 TAR_SUPPORTS_TRANSFORM
 TAR_INCLUDE_PARAM
@@ -1292,7 +1292,7 @@
 NICE
 MAKE
 UNZIP
-ZIP
+ZIPEXE
 LDD
 OTOOL
 READELF
@@ -2236,7 +2236,7 @@
   NICE        Override default value for NICE
   MAKE        Override default value for MAKE
   UNZIP       Override default value for UNZIP
-  ZIP         Override default value for ZIP
+  ZIPEXE      Override default value for ZIPEXE
   LDD         Override default value for LDD
   OTOOL       Override default value for OTOOL
   READELF     Override default value for READELF
@@ -5093,7 +5093,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1479120453
+DATE_WHEN_GENERATED=1479997904
 
 ###############################################################################
 #
@@ -21373,13 +21373,15 @@
   fi
 
 
-
-
-
-  # Publish this variable in the help.
-
-
-  if [ -z "${ZIP+x}" ]; then
+  # Since zip uses "ZIP" as a environment variable for passing options, we need
+  # to name our variable differently, hence ZIPEXE.
+
+
+
+  # Publish this variable in the help.
+
+
+  if [ -z "${ZIPEXE+x}" ]; then
     # The variable is not set by user, try to locate tool using the code snippet
     for ac_prog in zip
 do
@@ -21387,56 +21389,56 @@
 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_ZIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ZIP in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ZIP="$ZIP" # 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_ZIP="$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
-ZIP=$ac_cv_path_ZIP
-if test -n "$ZIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
-$as_echo "$ZIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$ZIP" && break
-done
-
-  else
-    # The variable is set, but is it from the command line or the environment?
-
-    # Try to remove the string !ZIP! from our list.
-    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!ZIP!/}
-    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 "xZIP" != xBASH; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of ZIP from the environment. Use command line variables instead." >&5
-$as_echo "$as_me: WARNING: Ignoring value of ZIP from the environment. Use command line variables instead." >&2;}
+if ${ac_cv_path_ZIPEXE+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ZIPEXE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ZIPEXE="$ZIPEXE" # 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_ZIPEXE="$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
+ZIPEXE=$ac_cv_path_ZIPEXE
+if test -n "$ZIPEXE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIPEXE" >&5
+$as_echo "$ZIPEXE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ZIPEXE" && break
+done
+
+  else
+    # The variable is set, but is it from the command line or the environment?
+
+    # Try to remove the string !ZIPEXE! from our list.
+    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!ZIPEXE!/}
+    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 "xZIPEXE" != xBASH; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of ZIPEXE from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of ZIPEXE from the environment. Use command line variables instead." >&2;}
       fi
       # Try to locate tool using the code snippet
       for ac_prog in zip
@@ -21445,135 +21447,135 @@
 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_ZIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ZIP in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ZIP="$ZIP" # 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_ZIP="$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
-ZIP=$ac_cv_path_ZIP
-if test -n "$ZIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
-$as_echo "$ZIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$ZIP" && 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$ZIP" = x; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool ZIP= (no value)" >&5
-$as_echo "$as_me: Setting user supplied tool ZIP= (no value)" >&6;}
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZIP" >&5
-$as_echo_n "checking for ZIP... " >&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="$ZIP"
-        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 ZIP=$tool_basename" >&5
-$as_echo "$as_me: Will search for user supplied tool ZIP=$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_ZIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ZIP in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ZIP="$ZIP" # 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_ZIP="$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
-ZIP=$ac_cv_path_ZIP
-if test -n "$ZIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
-$as_echo "$ZIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-          if test "x$ZIP" = 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 ZIP=$tool_specified" >&5
-$as_echo "$as_me: Will use user supplied tool ZIP=$tool_specified" >&6;}
-          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZIP" >&5
-$as_echo_n "checking for ZIP... " >&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 ZIP=$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
-
-
-
-  if test "x$ZIP" = x; then
-    as_fn_error $? "Could not find required tool for ZIP" "$LINENO" 5
+if ${ac_cv_path_ZIPEXE+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ZIPEXE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ZIPEXE="$ZIPEXE" # 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_ZIPEXE="$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
+ZIPEXE=$ac_cv_path_ZIPEXE
+if test -n "$ZIPEXE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIPEXE" >&5
+$as_echo "$ZIPEXE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ZIPEXE" && 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$ZIPEXE" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool ZIPEXE= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool ZIPEXE= (no value)" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZIPEXE" >&5
+$as_echo_n "checking for ZIPEXE... " >&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="$ZIPEXE"
+        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 ZIPEXE=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool ZIPEXE=$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_ZIPEXE+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ZIPEXE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ZIPEXE="$ZIPEXE" # 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_ZIPEXE="$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
+ZIPEXE=$ac_cv_path_ZIPEXE
+if test -n "$ZIPEXE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIPEXE" >&5
+$as_echo "$ZIPEXE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+          if test "x$ZIPEXE" = 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 ZIPEXE=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool ZIPEXE=$tool_specified" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZIPEXE" >&5
+$as_echo_n "checking for ZIPEXE... " >&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 ZIPEXE=$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
+
+
+
+  if test "x$ZIPEXE" = x; then
+    as_fn_error $? "Could not find required tool for ZIPEXE" "$LINENO" 5
   fi
 
 
@@ -49101,7 +49103,11 @@
       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1'
     fi
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    PICFLAG="-KPIC"
+    if test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
+      PICFLAG="-xcode=pic32"
+    else
+      PICFLAG="-KPIC"
+    fi
     C_FLAG_REORDER='-xF'
     CXX_FLAG_REORDER='-xF'
     SHARED_LIBRARY_FLAGS="-G"
@@ -50020,7 +50026,6 @@
     fastdebug | slowdebug )
       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
-      JAVAC_FLAGS="$JAVAC_FLAGS -g"
       ;;
     release )
       ;;
@@ -50076,12 +50081,12 @@
   # Set some additional per-OS defines.
   if test "x$OPENJDK_TARGET_OS" = xlinux; then
     JVM_CFLAGS="$JVM_CFLAGS -DLINUX"
-    JVM_CFLAGS="$JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
+    JVM_CFLAGS="$JVM_CFLAGS -pipe $PICFLAG -fno-rtti -fno-exceptions \
         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
     JVM_CFLAGS="$JVM_CFLAGS -DSOLARIS"
     JVM_CFLAGS="$JVM_CFLAGS -template=no%extdef -features=no%split_init \
-        -D_Crun_inline_placement -library=%none -KPIC -mt -features=no%except"
+        -D_Crun_inline_placement -library=%none $PICFLAG -mt -features=no%except"
   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
     JVM_CFLAGS="$JVM_CFLAGS -D_ALLBSD_SOURCE"
@@ -50844,7 +50849,6 @@
     fastdebug | slowdebug )
       OPENJDK_BUILD_CFLAGS_JDK="$OPENJDK_BUILD_CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
       OPENJDK_BUILD_CXXFLAGS_JDK="$OPENJDK_BUILD_CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
-      JAVAC_FLAGS="$JAVAC_FLAGS -g"
       ;;
     release )
       ;;
@@ -50900,12 +50904,12 @@
   # Set some additional per-OS defines.
   if test "x$OPENJDK_BUILD_OS" = xlinux; then
     OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DLINUX"
-    OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
+    OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -pipe $PICFLAG -fno-rtti -fno-exceptions \
         -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
   elif test "x$OPENJDK_BUILD_OS" = xsolaris; then
     OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DSOLARIS"
     OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -template=no%extdef -features=no%split_init \
-        -D_Crun_inline_placement -library=%none -KPIC -mt -features=no%except"
+        -D_Crun_inline_placement -library=%none $PICFLAG -mt -features=no%except"
   elif test "x$OPENJDK_BUILD_OS" = xmacosx; then
     OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
     OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -D_ALLBSD_SOURCE"
--- a/common/autoconf/spec.gmk.in	Fri Nov 25 11:16:51 2016 +0800
+++ b/common/autoconf/spec.gmk.in	Wed Jul 05 22:30:23 2017 +0200
@@ -657,8 +657,7 @@
 UNIQ:=@UNIQ@
 WC:=@WC@
 XARGS:=@XARGS@
-ZIPEXE:=@ZIP@
-ZIP:=@ZIP@
+ZIPEXE:=@ZIPEXE@
 UNZIP:=@UNZIP@
 MT:=@FIXPATH@ @MT@
 RC:=@FIXPATH@ @RC@
--- a/corba/.hgtags	Fri Nov 25 11:16:51 2016 +0800
+++ b/corba/.hgtags	Wed Jul 05 22:30:23 2017 +0200
@@ -388,3 +388,4 @@
 6211236ef15ec796806357608b1dd1b70c258ece jdk-9+143
 d4f1dae174098e799c48948e866054c52e11a186 jdk-9+144
 a44b156ae7f06bf41b9bece30df7775e482395dd jdk-9+145
+ecd74b41ab65bf228837b5bdf99690638d55425c jdk-9+146
--- a/hotspot/.hgtags	Fri Nov 25 11:16:51 2016 +0800
+++ b/hotspot/.hgtags	Wed Jul 05 22:30:23 2017 +0200
@@ -548,3 +548,4 @@
 d87d5d430c42342f0320ca7f5cbe0cbd1f9d62ba jdk-9+143
 6187b582d02aee38341dc8ce4011906e9b364e9f jdk-9+144
 61e7ea56312351657e69198c503a6f7bf865af83 jdk-9+145
+a82cb5350cad96a0b4de496afebe3ded89f27efa jdk-9+146
--- a/hotspot/make/gensrc/GensrcJvmti.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/hotspot/make/gensrc/GensrcJvmti.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -130,8 +130,6 @@
 TARGETS += $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp
 
 ################################################################################
-# Disable copy of jvmti.h from hotspot until this has been cleared up. The file
-# is currently being copied from the jdk repository. See JDK-8167078.
 # Copy jvmti.h to include dir
 
 # The file is the same regardless of jvm variant. Only let one do the copy.
--- a/hotspot/make/lib/CompileLibjsig.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/hotspot/make/lib/CompileLibjsig.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -129,7 +129,7 @@
         ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
           $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz: \
               $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)
-			$(CD) $$(@D) && $(ZIP) -q -y $$@ $$(basename $$(@F))$(DEBUG_INFO_SUFFIX)
+			$(CD) $$(@D) && $(ZIPEXE) -q -y $$@ $$(basename $$(@F))$(DEBUG_INFO_SUFFIX)
 
           TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz
         endif
--- a/hotspot/test/Makefile	Fri Nov 25 11:16:51 2016 +0800
+++ b/hotspot/test/Makefile	Wed Jul 05 22:30:23 2017 +0200
@@ -50,7 +50,7 @@
 UNAME     = uname
 UNIQ      = uniq
 WC        = wc
-ZIP       = zip
+ZIPEXE    = zip
 
 define NEWLINE
 
@@ -213,7 +213,7 @@
 ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`     \
 	           && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
 	           && $(CHMOD) -R a+r . \
-	           && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
+	           && $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . )
 
 # important results files
 SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
@@ -327,7 +327,7 @@
   else ifeq ($(shell expr $(CONCURRENCY) \> 12), 1)
     CONCURRENCY := 12
   endif
-else 
+else
   CONCURRENCY := 1
 endif
 JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
--- a/jdk/.hgtags	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/.hgtags	Wed Jul 05 22:30:23 2017 +0200
@@ -388,3 +388,4 @@
 8dbc8594f9d5149bf1c22221272284609408227a jdk-9+143
 efa71dc820eb8bd5a6c9f2f66f39c383ac3ee99d jdk-9+144
 99b7853cfbd8227c4441de4b6119c10742556840 jdk-9+145
+6e4ff59afb5d0adf21a72c4ff534326594a99e5d jdk-9+146
--- a/jdk/make/copy/Copy-java.base.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/make/copy/Copy-java.base.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -181,6 +181,7 @@
 DEF_POLICY_DST := $(LIB_DST_DIR)/security/default.policy
 
 DEF_POLICY_SRC_LIST := $(DEF_POLICY_SRC)
+DEF_POLICY_SRC_LIST += $(CUSTOM_POLICY_SRC_LIST)
 
 ifneq ($(filter $(OPENJDK_TARGET_OS), windows solaris), )
   DEF_POLICY_SRC_LIST += $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/lib/security/default.policy
--- a/jdk/make/copy/Copy-jdk.accessibility.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/make/copy/Copy-jdk.accessibility.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2104, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2104, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -30,8 +30,7 @@
 ifeq ($(OPENJDK_TARGET_OS), windows)
   TARGETS += $(INCLUDE_DST_OS_DIR)/bridge/AccessBridgeCallbacks.h \
       $(INCLUDE_DST_OS_DIR)/bridge/AccessBridgeCalls.h \
-      $(INCLUDE_DST_OS_DIR)/bridge/AccessBridgePackages.h \
-      $(INCLUDE_DST_OS_DIR)/bridge/AccessBridgeCalls.c
+      $(INCLUDE_DST_OS_DIR)/bridge/AccessBridgePackages.h
 
   $(INCLUDE_DST_OS_DIR)/bridge/%: \
       $(JDK_TOPDIR)/src/jdk.accessibility/windows/native/include/bridge/%
--- a/jdk/make/launcher/Launcher-jdk.accessibility.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/make/launcher/Launcher-jdk.accessibility.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -71,7 +71,7 @@
 
     $$(eval $$(call SetupNativeCompilation, BUILD_JACCESSINSPECTOR$1, \
       SRC := $(TOPDIR)/jaccessinspector $(TOPDIR)/common \
-          $(TOPDIR)/toolscommon $(TOPDIR)/include/bridge, \
+          $(TOPDIR)/toolscommon $(TOPDIR)/bridge, \
       CFLAGS := $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 -EHsc, \
       LDFLAGS := $$(LDFLAGS_JDKEXE) -stack:655360, \
       LIBS := advapi32.lib user32.lib, \
@@ -98,7 +98,7 @@
 
     $$(eval $$(call SetupNativeCompilation,BUILD_JACCESSWALKER$1, \
       SRC := $(TOPDIR)/jaccesswalker $(TOPDIR)/common \
-          $(TOPDIR)/toolscommon $(TOPDIR)/include/bridge, \
+          $(TOPDIR)/toolscommon $(TOPDIR)/bridge, \
       CFLAGS := $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 -EHsc, \
       LDFLAGS := $$(LDFLAGS_JDKEXE) -stack:655360, \
       LIBS := advapi32.lib comctl32.lib gdi32.lib user32.lib, \
--- a/jdk/make/lib/Awt2dLibraries.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/make/lib/Awt2dLibraries.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -356,7 +356,7 @@
             $(X_CFLAGS), \
         WARNINGS_AS_ERRORS_xlc := false, \
         DISABLED_WARNINGS_gcc := type-limits pointer-to-int-cast \
-            deprecated-declarations unused-result maybe-uninitialized format \
+            unused-result maybe-uninitialized format \
             format-security int-to-pointer-cast parentheses, \
         DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE \
             E_ASSIGNMENT_TYPE_MISMATCH E_NON_CONST_INIT, \
--- a/jdk/make/lib/Lib-jdk.accessibility.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/make/lib/Lib-jdk.accessibility.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,7 @@
         OPTIMIZATION := LOW, \
         CFLAGS := $(CFLAGS_JDKLIB) $(ACCESSBRIDGE_CFLAGS) \
             $(addprefix -I,$(JAVA_AB_SRCDIR)) \
-            -I$(JDK_TOPDIR)/src/jdk.accessibility/windows/native/include/bridge \
+            -I$(ROOT_SRCDIR)/include/bridge \
             -DACCESSBRIDGE_ARCH_$2, \
         LDFLAGS := $(LDFLAGS_JDKLIB) -subsystem:windows, \
         LIBS := kernel32.lib user32.lib gdi32.lib \
@@ -78,7 +78,7 @@
         OPTIMIZATION := LOW, \
         CFLAGS := $(filter-out -MD, $(CFLAGS_JDKLIB)) -MT $(ACCESSBRIDGE_CFLAGS) \
             $(addprefix -I,$(WIN_AB_SRCDIR)) \
-            -I$(JDK_TOPDIR)/src/jdk.accessibility/windows/native/include/bridge \
+            -I$(ROOT_SRCDIR)/include/bridge \
             -DACCESSBRIDGE_ARCH_$2, \
         LDFLAGS := $(LDFLAGS_JDKLIB) -subsystem:windows \
             -def:$(ROOT_SRCDIR)/libwindowsaccessbridge/WinAccessBridge.DEF, \
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java	Wed Jul 05 22:30:23 2017 +0200
@@ -194,11 +194,17 @@
      * When setting the filter, it should be stateless and idempotent,
      * reporting the same result when passed the same arguments.
      * <p>
-     * The filter is configured using the {@link java.security.Security}
-     * property {@code jdk.serialFilter} and can be overridden by
-     * the System property {@code jdk.serialFilter}.
-     *
-     * The syntax is the same as for the {@link #createFilter(String) createFilter} method.
+     * The filter is configured during the initialization of the {@code ObjectInputFilter.Config}
+     * class. For example, by calling {@link #getSerialFilter() Config.getSerialFilter}.
+     * If the system property {@code jdk.serialFilter} is defined, it is used
+     * to configure the filter.
+     * If the system property is not defined, and the {@link java.security.Security}
+     * property {@code jdk.serialFilter} is defined then it is used to configure the filter.
+     * Otherwise, the filter is not configured during initialization.
+     * The syntax for each property is the same as for the
+     * {@link #createFilter(String) createFilter} method.
+     * If a filter is not configured, it can be set with
+     * {@link #setSerialFilter(ObjectInputFilter) Config.setSerialFilter}.
      *
      * @since 9
      */
--- a/jdk/src/java.base/share/classes/java/lang/CharSequence.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/lang/CharSequence.java	Wed Jul 05 22:30:23 2017 +0200
@@ -121,8 +121,11 @@
      * href="{@docRoot}/java/lang/Character.html#unicode">surrogate code
      * point</a> is passed through uninterpreted.
      *
-     * <p>If the sequence is mutated while the stream is being read, the
-     * result is undefined.
+     * <p>The stream binds to this sequence when the terminal stream operation
+     * commences (specifically, for mutable sequences the spliterator for the
+     * stream is <a href="../Spliterator.html#binding"><em>late-binding</em></a>).
+     * If the sequence is modified during that operation then the result is
+     * undefined.
      *
      * @return an IntStream of char values from this sequence
      * @since 1.8
@@ -168,8 +171,11 @@
      * unpaired surrogates, and undefined code units, are zero-extended to
      * {@code int} values which are then passed to the stream.
      *
-     * <p>If the sequence is mutated while the stream is being read, the result
-     * is undefined.
+     * <p>The stream binds to this sequence when the terminal stream operation
+     * commences (specifically, for mutable sequences the spliterator for the
+     * stream is <a href="../Spliterator.html#binding"><em>late-binding</em></a>).
+     * If the sequence is modified during that operation then the result is
+     * undefined.
      *
      * @return an IntStream of Unicode code points from this sequence
      * @since 1.8
--- a/jdk/src/java.base/share/classes/java/lang/Class.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java	Wed Jul 05 22:30:23 2017 +0200
@@ -2704,9 +2704,6 @@
      * Reflection support.
      */
 
-    // Caches for certain reflective results
-    private static boolean useCaches = true;
-
     // reflection data that might get invalidated when JVM TI RedefineClasses() is called
     private static class ReflectionData<T> {
         volatile Field[] declaredFields;
@@ -2739,8 +2736,7 @@
         SoftReference<ReflectionData<T>> reflectionData = this.reflectionData;
         int classRedefinedCount = this.classRedefinedCount;
         ReflectionData<T> rd;
-        if (useCaches &&
-            reflectionData != null &&
+        if (reflectionData != null &&
             (rd = reflectionData.get()) != null &&
             rd.redefinedCount == classRedefinedCount) {
             return rd;
@@ -2752,8 +2748,6 @@
 
     private ReflectionData<T> newReflectionData(SoftReference<ReflectionData<T>> oldReflectionData,
                                                 int classRedefinedCount) {
-        if (!useCaches) return null;
-
         while (true) {
             ReflectionData<T> rd = new ReflectionData<>(classRedefinedCount);
             // try to CAS it...
@@ -2819,7 +2813,6 @@
     // be propagated to the outside world, but must instead be copied
     // via ReflectionFactory.copyField.
     private Field[] privateGetDeclaredFields(boolean publicOnly) {
-        checkInitted();
         Field[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -2842,7 +2835,6 @@
     // be propagated to the outside world, but must instead be copied
     // via ReflectionFactory.copyField.
     private Field[] privateGetPublicFields(Set<Class<?>> traversedInterfaces) {
-        checkInitted();
         Field[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -2902,7 +2894,6 @@
     // objects must NOT be propagated to the outside world, but must
     // instead be copied via ReflectionFactory.copyConstructor.
     private Constructor<T>[] privateGetDeclaredConstructors(boolean publicOnly) {
-        checkInitted();
         Constructor<T>[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -2937,7 +2928,6 @@
     // be propagated to the outside world, but must instead be copied
     // via ReflectionFactory.copyMethod.
     private Method[] privateGetDeclaredMethods(boolean publicOnly) {
-        checkInitted();
         Method[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -3134,7 +3124,6 @@
     // be propagated to the outside world, but must instead be copied
     // via ReflectionFactory.copyMethod.
     private Method[] privateGetPublicMethods() {
-        checkInitted();
         Method[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -3445,7 +3434,7 @@
      * @since  1.4
      */
     public boolean desiredAssertionStatus() {
-        ClassLoader loader = getClassLoader();
+        ClassLoader loader = getClassLoader0();
         // If the loader is null this is a system class, so ask the VM
         if (loader == null)
             return desiredAssertionStatus0(this);
@@ -3490,39 +3479,6 @@
     }
     private static ReflectionFactory reflectionFactory;
 
-    // To be able to query system properties as soon as they're available
-    private static boolean initted = false;
-    private static void checkInitted() {
-        if (initted) return;
-        AccessController.doPrivileged(new PrivilegedAction<>() {
-                public Void run() {
-                    // 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
-                        return null;
-                    }
-
-                    // Doesn't use Boolean.getBoolean to avoid class init.
-                    String val =
-                        System.getProperty("sun.reflect.noCaches");
-                    if (val != null && val.equals("true")) {
-                        useCaches = false;
-                    }
-
-                    initted = true;
-                    return null;
-                }
-            });
-    }
-
     /**
      * Returns the elements of this enum class or null if this
      * Class object does not represent an enum type.
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Wed Jul 05 22:30:23 2017 +0200
@@ -104,9 +104,9 @@
  * class or resource itself.
  *
  * <p> Class loaders that support concurrent loading of classes are known as
- * <em>{@linkplain #isParallelCapable() parallel capable}</em> class loaders and
- * are required to register themselves at their class initialization time by
- * invoking the {@link
+ * <em>{@linkplain #isRegisteredAsParallelCapable() parallel capable}</em> class
+ * loaders and are required to register themselves at their class initialization
+ * time by invoking the {@link
  * #registerAsParallelCapable <tt>ClassLoader.registerAsParallelCapable</tt>}
  * method. Note that the <tt>ClassLoader</tt> class is registered as parallel
  * capable by default. However, its subclasses still need to register themselves
@@ -1335,10 +1335,12 @@
      * @return  A <tt>URL</tt> object for reading the resource, or
      *          <tt>null</tt> if the resource could not be found or the invoker
      *          doesn't have adequate  privileges to get the resource.
+     * @throws  NullPointerException If {@code name} is {@code null}
      *
      * @since  1.1
      */
     public URL getResource(String name) {
+        Objects.requireNonNull(name);
         URL url;
         if (parent != null) {
             url = parent.getResource(name);
@@ -1382,12 +1384,14 @@
      *
      * @throws  IOException
      *          If I/O errors occur
+     * @throws  NullPointerException If {@code name} is {@code null}
      *
      * @see  #findResources(String)
      *
      * @since  1.2
      */
     public Enumeration<URL> getResources(String name) throws IOException {
+        Objects.requireNonNull(name);
         @SuppressWarnings("unchecked")
         Enumeration<URL>[] tmp = (Enumeration<URL>[]) new Enumeration<?>[2];
         if (parent != null) {
@@ -1434,11 +1438,14 @@
      *          that the class loader doesn't have access to will not be in the
      *          stream.
      *
+     * @throws  NullPointerException If {@code name} is {@code null}
+     *
      * @see  #findResources(String)
      *
      * @since  9
      */
     public Stream<URL> resources(String name) {
+        Objects.requireNonNull(name);
         int characteristics = Spliterator.NONNULL | Spliterator.IMMUTABLE;
         Supplier<Spliterator<URL>> si = () -> {
             try {
@@ -1495,7 +1502,8 @@
     }
 
     /**
-     * Registers the caller as {@linkplain #isParallelCapable() parallel capable}.
+     * Registers the caller as
+     * {@linkplain #isRegisteredAsParallelCapable() parallel capable}.
      * The registration succeeds if and only if all of the following
      * conditions are met:
      * <ol>
@@ -1509,7 +1517,7 @@
      * @return  {@code true} if the caller is successfully registered as
      *          parallel capable and {@code false} if otherwise.
      *
-     * @see #isParallelCapable()
+     * @see #isRegisteredAsParallelCapable()
      *
      * @since   1.7
      */
@@ -1521,7 +1529,7 @@
     }
 
     /**
-     * Returns {@code true} if this class loader is
+     * Returns {@code true} if this class loader is registered as
      * {@linkplain #registerAsParallelCapable parallel capable}, otherwise
      * {@code false}.
      *
@@ -1532,7 +1540,7 @@
      *
      * @since   9
      */
-    public final boolean isParallelCapable() {
+    public final boolean isRegisteredAsParallelCapable() {
         return ParallelLoaders.isRegistered(this.getClass());
     }
 
@@ -1599,10 +1607,12 @@
      *
      * @return  An input stream for reading the resource, or <tt>null</tt>
      *          if the resource could not be found
+     * @throws  NullPointerException If {@code name} is {@code null}
      *
      * @since  1.1
      */
     public InputStream getResourceAsStream(String name) {
+        Objects.requireNonNull(name);
         URL url = getResource(name);
         try {
             return url != null ? url.openStream() : null;
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java	Wed Jul 05 22:30:23 2017 +0200
@@ -200,7 +200,8 @@
     }
 
     /**
-     * {@inheritDoc}
+     * Returns the {@code Class} object representing the class that
+     * declares the constructor represented by this object.
      */
     @Override
     public Class<T> getDeclaringClass() {
@@ -321,6 +322,11 @@
      *    public java.util.Hashtable(int,float)
      * }</pre>
      *
+     * <p>If the constructor is declared to throw exceptions, the
+     * parameter list is followed by a space, followed by the word
+     * "{@code throws}" followed by a comma-separated list of the
+     * thrown exception types.
+     *
      * <p>The only possible modifiers for constructors are the access
      * modifiers {@code public}, {@code protected} or
      * {@code private}.  Only one of these may appear, or none if the
@@ -357,13 +363,13 @@
      * "<code><i>Type</i>...</code>".
      *
      * A space is used to separate access modifiers from one another
-     * and from the type parameters or return type.  If there are no
+     * and from the type parameters or class name.  If there are no
      * type parameters, the type parameter list is elided; if the type
      * parameter list is present, a space separates the list from the
      * class name.  If the constructor is declared to throw
      * exceptions, the parameter list is followed by a space, followed
      * by the word "{@code throws}" followed by a
-     * comma-separated list of the thrown exception types.
+     * comma-separated list of the generic thrown exception types.
      *
      * <p>The only possible modifiers for constructors are the access
      * modifiers {@code public}, {@code protected} or
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Method.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Method.java	Wed Jul 05 22:30:23 2017 +0200
@@ -211,7 +211,8 @@
     }
 
     /**
-     * {@inheritDoc}
+     * Returns the {@code Class} object representing the class or interface
+     * that declares the method represented by this object.
      */
     @Override
     public Class<?> getDeclaringClass() {
@@ -372,7 +373,7 @@
      * the method name, followed by a parenthesized, comma-separated
      * list of the method's formal parameter types. If the method
      * throws checked exceptions, the parameter list is followed by a
-     * space, followed by the word throws followed by a
+     * space, followed by the word "{@code throws}" followed by a
      * comma-separated list of the thrown exception types.
      * For example:
      * <pre>
@@ -428,8 +429,8 @@
      * parameter list is present, a space separates the list from the
      * class name.  If the method is declared to throw exceptions, the
      * parameter list is followed by a space, followed by the word
-     * throws followed by a comma-separated list of the generic thrown
-     * exception types.
+     * "{@code throws}" followed by a comma-separated list of the generic
+     * thrown exception types.
      *
      * <p>The access modifiers are placed in canonical order as
      * specified by "The Java Language Specification".  This is
--- a/jdk/src/java.base/share/classes/java/net/Authenticator.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/net/Authenticator.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -131,6 +131,35 @@
     }
 
     /**
+     * Gets the default authenticator.
+     * First, if there is a security manager, its {@code checkPermission}
+     * method is called with a
+     * {@code NetPermission("requestPasswordAuthentication")} permission.
+     * This may result in a java.lang.SecurityException.
+     * Then the default authenticator, if set, is returned.
+     * Otherwise, {@code null} is returned.
+     *
+     * @return The default authenticator, if set, {@code null} otherwise.
+     *
+     * @throws SecurityException
+     *        if a security manager exists and its
+     *        {@code checkPermission} method doesn't allow
+     *        requesting password authentication.
+     * @since 9
+     * @see SecurityManager#checkPermission
+     * @see java.net.NetPermission
+     */
+    public static Authenticator getDefault() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            NetPermission requestPermission
+                = new NetPermission("requestPasswordAuthentication");
+            sm.checkPermission(requestPermission);
+        }
+        return theAuthenticator;
+    }
+
+    /**
      * Ask the authenticator that has been registered with the system
      * for a password.
      * <p>
--- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Wed Jul 05 22:30:23 2017 +0200
@@ -42,6 +42,7 @@
 import java.util.Enumeration;
 import java.util.List;
 import java.util.NoSuchElementException;
+import java.util.Objects;
 import java.util.Set;
 import java.util.WeakHashMap;
 import java.util.jar.Attributes;
@@ -301,9 +302,12 @@
      * @return  An input stream for reading the resource, or {@code null}
      *          if the resource could not be found
      *
+     * @throws  NullPointerException If {@code name} is {@code null}
+     *
      * @since  1.7
      */
     public InputStream getResourceAsStream(String name) {
+        Objects.requireNonNull(name);
         URL url = getResource(name);
         try {
             if (url == null) {
--- a/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java	Wed Jul 05 22:30:23 2017 +0200
@@ -32,6 +32,7 @@
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import jdk.internal.misc.JavaSecurityAccess;
 import jdk.internal.misc.JavaSecurityProtectionDomainAccess;
@@ -524,7 +525,7 @@
                             // have some side effects so this manual
                             // comparison is sufficient.
                             if (pdpName.equals(pp.getName()) &&
-                                pdpActions.equals(pp.getActions())) {
+                                Objects.equals(pdpActions, pp.getActions())) {
                                 plVector.remove(i);
                                 break;
                             }
--- a/jdk/src/java.base/share/classes/java/security/SecureRandom.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/security/SecureRandom.java	Wed Jul 05 22:30:23 2017 +0200
@@ -120,6 +120,24 @@
  * gathered, for example, if the entropy source is /dev/random on various
  * Unix-like operating systems.
  *
+ * <h2> Thread safety </h2>
+ * {@code SecureRandom} objects are safe for use by multiple concurrent threads.
+ *
+ * @implSpec
+ * A {@code SecureRandom} service provider can advertise that it is thread-safe
+ * by setting the <a href=
+ * "{@docRoot}/../technotes/guides/security/StandardNames.html#Service">service
+ * provider attribute</a> "ThreadSafe" to "true" when registering the provider.
+ * Otherwise, this class will instead synchronize access to the following
+ * methods of the {@code SecureRandomSpi} implementation:
+ * <ul>
+ * <li>{@link SecureRandomSpi#engineSetSeed(byte[])}
+ * <li>{@link SecureRandomSpi#engineNextBytes(byte[])}
+ * <li>{@link SecureRandomSpi#engineNextBytes(byte[], SecureRandomParameters)}
+ * <li>{@link SecureRandomSpi#engineGenerateSeed(int)}
+ * <li>{@link SecureRandomSpi#engineReseed(SecureRandomParameters)}
+ * </ul>
+ *
  * @see java.security.SecureRandomSpi
  * @see java.util.Random
  *
@@ -150,6 +168,14 @@
      */
     private SecureRandomSpi secureRandomSpi = null;
 
+    /**
+     * Thread safety.
+     *
+     * @serial
+     * @since 9
+     */
+    private final boolean threadSafe;
+
     /*
      * The algorithm name of null if unknown.
      *
@@ -189,6 +215,16 @@
          */
         super(0);
         getDefaultPRNG(false, null);
+        this.threadSafe = getThreadSafe();
+    }
+
+    private boolean getThreadSafe() {
+        if (provider == null || algorithm == null) {
+            return false;
+        } else {
+            return Boolean.parseBoolean(provider.getProperty(
+                    "SecureRandom." + algorithm + " ThreadSafe", "false"));
+        }
     }
 
     /**
@@ -217,6 +253,7 @@
     public SecureRandom(byte[] seed) {
         super(0);
         getDefaultPRNG(true, seed);
+        this.threadSafe = getThreadSafe();
     }
 
     private void getDefaultPRNG(boolean setSeed, byte[] seed) {
@@ -269,6 +306,7 @@
         this.secureRandomSpi = secureRandomSpi;
         this.provider = provider;
         this.algorithm = algorithm;
+        this.threadSafe = getThreadSafe();
 
         if (!skipDebug && pdebug != null) {
             pdebug.println("SecureRandom." + algorithm +
@@ -653,8 +691,14 @@
      *
      * @see #getSeed
      */
-    public synchronized void setSeed(byte[] seed) {
-        secureRandomSpi.engineSetSeed(seed);
+    public void setSeed(byte[] seed) {
+        if (threadSafe) {
+            secureRandomSpi.engineSetSeed(seed);
+        } else {
+            synchronized (this) {
+                secureRandomSpi.engineSetSeed(seed);
+            }
+        }
     }
 
     /**
@@ -679,7 +723,7 @@
          * yet been initialized at that point.
          */
         if (seed != 0) {
-            this.secureRandomSpi.engineSetSeed(longToByteArray(seed));
+            setSeed(longToByteArray(seed));
         }
     }
 
@@ -690,7 +734,13 @@
      */
     @Override
     public void nextBytes(byte[] bytes) {
-        secureRandomSpi.engineNextBytes(bytes);
+        if (threadSafe) {
+            secureRandomSpi.engineNextBytes(bytes);
+        } else {
+            synchronized (this) {
+                secureRandomSpi.engineNextBytes(bytes);
+            }
+        }
     }
 
     /**
@@ -707,12 +757,19 @@
      *
      * @since 9
      */
-    public synchronized void nextBytes(
-            byte[] bytes, SecureRandomParameters params) {
+    public void nextBytes(byte[] bytes, SecureRandomParameters params) {
         if (params == null) {
             throw new IllegalArgumentException("params cannot be null");
         }
-        secureRandomSpi.engineNextBytes(Objects.requireNonNull(bytes), params);
+        if (threadSafe) {
+            secureRandomSpi.engineNextBytes(
+                    Objects.requireNonNull(bytes), params);
+        } else {
+            synchronized (this) {
+                secureRandomSpi.engineNextBytes(
+                        Objects.requireNonNull(bytes), params);
+            }
+        }
     }
 
     /**
@@ -756,6 +813,7 @@
      *
      * @param numBytes the number of seed bytes to generate.
      *
+     * @throws IllegalArgumentException if {@code numBytes} is negative
      * @return the seed bytes.
      *
      * @see #setSeed
@@ -782,7 +840,13 @@
         if (numBytes < 0) {
             throw new IllegalArgumentException("numBytes cannot be negative");
         }
-        return secureRandomSpi.engineGenerateSeed(numBytes);
+        if (threadSafe) {
+            return secureRandomSpi.engineGenerateSeed(numBytes);
+        } else {
+            synchronized (this) {
+                return secureRandomSpi.engineGenerateSeed(numBytes);
+            }
+        }
     }
 
     /**
@@ -917,8 +981,14 @@
      *
      * @since 9
      */
-    public synchronized void reseed() {
-        secureRandomSpi.engineReseed(null);
+    public void reseed() {
+        if (threadSafe) {
+            secureRandomSpi.engineReseed(null);
+        } else {
+            synchronized (this) {
+                secureRandomSpi.engineReseed(null);
+            }
+        }
     }
 
     /**
@@ -937,11 +1007,17 @@
      *
      * @since 9
      */
-    public synchronized void reseed(SecureRandomParameters params) {
+    public void reseed(SecureRandomParameters params) {
         if (params == null) {
             throw new IllegalArgumentException("params cannot be null");
         }
-        secureRandomSpi.engineReseed(params);
+        if (threadSafe) {
+            secureRandomSpi.engineReseed(params);
+        } else {
+            synchronized (this) {
+                secureRandomSpi.engineReseed(params);
+            }
+        }
     }
 
     // Declare serialVersionUID to be compatible with JDK1.1
--- a/jdk/src/java.base/share/classes/java/security/SecureRandomSpi.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/security/SecureRandomSpi.java	Wed Jul 05 22:30:23 2017 +0200
@@ -58,6 +58,26 @@
  * a {@code SecureRandomParameters} argument will never
  * return an instance of this implementation. The
  * {@link #engineGetParameters()} method must return {@code null}.
+ * <p>
+ * See {@link SecureRandom} for additional details on thread safety. By
+ * default, a {@code SecureRandomSpi} implementation is considered to be
+ * not safe for use by multiple concurrent threads and {@code SecureRandom}
+ * will synchronize access to each of the applicable engine methods
+ * (see {@link SecureRandom} for the list of methods). However, if a
+ * {@code SecureRandomSpi} implementation is thread-safe, the <a href=
+ * "{@docRoot}/../technotes/guides/security/StandardNames.html#Service">
+ * service provider attribute</a> "ThreadSafe" should be set to "true" during
+ * its registration, as follows:
+ * <blockquote><pre>
+ * put("SecureRandom.AlgName ThreadSafe", "true");</pre>
+ * </blockquote>
+ * or
+ * <blockquote><pre>
+ * putService(new Service(this, "SecureRandom", "AlgName", className,
+ *          null, Map.of("ThreadSafe", "true")));</pre>
+ * </blockquote>
+ * {@code SecureRandom} will call the applicable engine methods
+ * without any synchronization.
  *
  * @since 1.2
  */
--- a/jdk/src/java.base/share/classes/java/time/ZoneId.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/time/ZoneId.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -76,6 +76,7 @@
 import java.time.zone.ZoneRules;
 import java.time.zone.ZoneRulesException;
 import java.time.zone.ZoneRulesProvider;
+import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Objects;
@@ -284,7 +285,7 @@
      * @return a modifiable copy of the set of zone IDs, not null
      */
     public static Set<String> getAvailableZoneIds() {
-        return ZoneRulesProvider.getAvailableZoneIds();
+        return new HashSet<String>(ZoneRulesProvider.getAvailableZoneIds());
     }
 
     //-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimePrintContext.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimePrintContext.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -302,14 +302,10 @@
      * @throws DateTimeException if the field is not available and the section is not optional
      */
     Long getValue(TemporalField field) {
-        try {
-            return temporal.getLong(field);
-        } catch (DateTimeException ex) {
-            if (optional > 0) {
-                return null;
-            }
-            throw ex;
+        if (optional > 0 && !temporal.isSupported(field)) {
+            return null;
         }
+        return temporal.getLong(field);
     }
 
     //-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/zone/ZoneRulesProvider.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/time/zone/ZoneRulesProvider.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,6 +77,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.Collections;
 
 /**
  * Provider of time-zone rules to the system.
@@ -137,6 +138,11 @@
      */
     private static final ConcurrentMap<String, ZoneRulesProvider> ZONES = new ConcurrentHashMap<>(512, 0.75f, 2);
 
+    /**
+     * The zone ID data
+     */
+    private static volatile Set<String> ZONE_IDS;
+
     static {
         // if the property java.time.zone.DefaultZoneRulesProvider is
         // set then its value is the class name of the default provider
@@ -194,10 +200,10 @@
      * <p>
      * These IDs are the string form of a {@link ZoneId}.
      *
-     * @return a modifiable copy of the set of zone IDs, not null
+     * @return the unmodifiable set of zone IDs, not null
      */
     public static Set<String> getAvailableZoneIds() {
-        return new HashSet<>(ZONES.keySet());
+        return ZONE_IDS;
     }
 
     /**
@@ -303,7 +309,7 @@
      * @param provider  the provider to register, not null
      * @throws ZoneRulesException if unable to complete the registration
      */
-    private static void registerProvider0(ZoneRulesProvider provider) {
+    private static synchronized void registerProvider0(ZoneRulesProvider provider) {
         for (String zoneId : provider.provideZoneIds()) {
             Objects.requireNonNull(zoneId, "zoneId");
             ZoneRulesProvider old = ZONES.putIfAbsent(zoneId, provider);
@@ -313,6 +319,8 @@
                     ", currently loading from provider: " + provider);
             }
         }
+        Set<String> combinedSet = new HashSet<String>(ZONES.keySet());
+        ZONE_IDS = Collections.unmodifiableSet(combinedSet);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/util/BitSet.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/util/BitSet.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.LongBuffer;
+import java.util.function.IntConsumer;
 import java.util.stream.IntStream;
 import java.util.stream.StreamSupport;
 
@@ -1209,40 +1210,165 @@
      * is the number of bits in the set state, equal to the value
      * returned by the {@link #cardinality()} method.
      *
-     * <p>The bit set must remain constant during the execution of the
-     * terminal stream operation.  Otherwise, the result of the terminal
-     * stream operation is undefined.
+     * <p>The stream binds to this bit set when the terminal stream operation
+     * commences (specifically, the spliterator for the stream is
+     * <a href="../Spliterator.html#binding"><em>late-binding</em></a>).  If the
+     * bit set is modified during that operation then the result is undefined.
      *
      * @return a stream of integers representing set indices
      * @since 1.8
      */
     public IntStream stream() {
-        class BitSetIterator implements PrimitiveIterator.OfInt {
-            int next = nextSetBit(0);
+        class BitSetSpliterator implements Spliterator.OfInt {
+            private int index; // current bit index for a set bit
+            private int fence; // -1 until used; then one past last bit index
+            private int est;   // size estimate
+            private boolean root; // true if root and not split
+            // root == true then size estimate is accurate
+            // index == -1 or index >= fence if fully traversed
+            // Special case when the max bit set is Integer.MAX_VALUE
+
+            BitSetSpliterator(int origin, int fence, int est, boolean root) {
+                this.index = origin;
+                this.fence = fence;
+                this.est = est;
+                this.root = root;
+            }
+
+            private int getFence() {
+                int hi;
+                if ((hi = fence) < 0) {
+                    // Round up fence to maximum cardinality for allocated words
+                    // This is sufficient and cheap for sequential access
+                    // When splitting this value is lowered
+                    hi = fence = (wordsInUse >= wordIndex(Integer.MAX_VALUE))
+                                 ? Integer.MAX_VALUE
+                                 : wordsInUse << ADDRESS_BITS_PER_WORD;
+                    est = cardinality();
+                    index = nextSetBit(0);
+                }
+                return hi;
+            }
 
             @Override
-            public boolean hasNext() {
-                return next != -1;
+            public boolean tryAdvance(IntConsumer action) {
+                Objects.requireNonNull(action);
+
+                int hi = getFence();
+                int i = index;
+                if (i < 0 || i >= hi) {
+                    // Check if there is a final bit set for Integer.MAX_VALUE
+                    if (i == Integer.MAX_VALUE && hi == Integer.MAX_VALUE) {
+                        index = -1;
+                        action.accept(Integer.MAX_VALUE);
+                        return true;
+                    }
+                    return false;
+                }
+
+                index = nextSetBit(i + 1, wordIndex(hi - 1));
+                action.accept(i);
+                return true;
+            }
+
+            @Override
+            public void forEachRemaining(IntConsumer action) {
+                Objects.requireNonNull(action);
+
+                int hi = getFence();
+                int i = index;
+                int v = wordIndex(hi - 1);
+                index = -1;
+                while (i >= 0 && i < hi) {
+                    action.accept(i);
+                    i = nextSetBit(i + 1, v);
+                }
+                // Check if there is a final bit set for Integer.MAX_VALUE
+                if (i == Integer.MAX_VALUE && hi == Integer.MAX_VALUE) {
+                    action.accept(Integer.MAX_VALUE);
+                }
             }
 
             @Override
-            public int nextInt() {
-                if (next != -1) {
-                    int ret = next;
-                    next = (next == Integer.MAX_VALUE) ? -1 : nextSetBit(next+1);
-                    return ret;
-                } else {
-                    throw new NoSuchElementException();
+            public OfInt trySplit() {
+                int hi = getFence();
+                int lo = index;
+                if (lo < 0) {
+                    return null;
+                }
+
+                // Lower the fence to be the upper bound of last bit set
+                // The index is the first bit set, thus this spliterator
+                // covers one bit and cannot be split, or two or more
+                // bits
+                hi = fence = (hi < Integer.MAX_VALUE || !get(Integer.MAX_VALUE))
+                        ? previousSetBit(hi - 1) + 1
+                        : Integer.MAX_VALUE;
+
+                // Find the mid point
+                int mid = (lo + hi) >>> 1;
+                if (lo >= mid) {
+                    return null;
                 }
+
+                // Raise the index of this spliterator to be the next set bit
+                // from the mid point
+                index = nextSetBit(mid, wordIndex(hi - 1));
+                root = false;
+
+                // Don't lower the fence (mid point) of the returned spliterator,
+                // traversal or further splitting will do that work
+                return new BitSetSpliterator(lo, mid, est >>>= 1, false);
+            }
+
+            @Override
+            public long estimateSize() {
+                getFence(); // force init
+                return est;
+            }
+
+            @Override
+            public int characteristics() {
+                // Only sized when root and not split
+                return (root ? Spliterator.SIZED : 0) |
+                    Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED;
+            }
+
+            @Override
+            public Comparator<? super Integer> getComparator() {
+                return null;
             }
         }
+        return StreamSupport.intStream(new BitSetSpliterator(0, -1, 0, true), false);
+    }
 
-        return StreamSupport.intStream(
-                () -> Spliterators.spliterator(
-                        new BitSetIterator(), cardinality(),
-                        Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED),
-                Spliterator.SIZED | Spliterator.SUBSIZED |
-                        Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED,
-                false);
+    /**
+     * Returns the index of the first bit that is set to {@code true}
+     * that occurs on or after the specified starting index and up to and
+     * including the specified word index
+     * If no such bit exists then {@code -1} is returned.
+     *
+     * @param  fromIndex the index to start checking from (inclusive)
+     * @param  toWordIndex the last word index to check (inclusive)
+     * @return the index of the next set bit, or {@code -1} if there
+     *         is no such bit
+     */
+    private int nextSetBit(int fromIndex, int toWordIndex) {
+        int u = wordIndex(fromIndex);
+        // Check if out of bounds
+        if (u > toWordIndex)
+            return -1;
+
+        long word = words[u] & (WORD_MASK << fromIndex);
+
+        while (true) {
+            if (word != 0)
+                return (u * BITS_PER_WORD) + Long.numberOfTrailingZeros(word);
+            // Check if out of bounds
+            if (++u > toWordIndex)
+                return -1;
+            word = words[u];
+        }
     }
+
 }
--- a/jdk/src/java.base/share/classes/java/util/PriorityQueue.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/util/PriorityQueue.java	Wed Jul 05 22:30:23 2017 +0200
@@ -54,7 +54,8 @@
  * <p>This class and its iterator implement all of the
  * <em>optional</em> methods of the {@link Collection} and {@link
  * Iterator} interfaces.  The Iterator provided in method {@link
- * #iterator()} is <em>not</em> guaranteed to traverse the elements of
+ * #iterator()} and the Spliterator provided in method {@link #spliterator()}
+ * are <em>not</em> guaranteed to traverse the elements of
  * the priority queue in any particular order. If you need ordered
  * traversal, consider using {@code Arrays.sort(pq.toArray())}.
  *
@@ -799,7 +800,8 @@
     /**
      * Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
      * and <em>fail-fast</em> {@link Spliterator} over the elements in this
-     * queue.
+     * queue. The spliterator does not traverse elements in any particular order
+     * (the {@link Spliterator#ORDERED ORDERED} characteristic is not reported).
      *
      * <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
      * {@link Spliterator#SUBSIZED}, and {@link Spliterator#NONNULL}.
--- a/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Wed Jul 05 22:30:23 2017 +0200
@@ -65,7 +65,8 @@
  * <p>This class and its iterator implement all of the
  * <em>optional</em> methods of the {@link Collection} and {@link
  * Iterator} interfaces.  The Iterator provided in method {@link
- * #iterator()} is <em>not</em> guaranteed to traverse the elements of
+ * #iterator()} and the Spliterator provided in method {@link #spliterator()}
+ * are <em>not</em> guaranteed to traverse the elements of
  * the PriorityBlockingQueue in any particular order. If you need
  * ordered traversal, consider using
  * {@code Arrays.sort(pq.toArray())}.  Also, method {@code drainTo}
@@ -994,6 +995,8 @@
 
     /**
      * Returns a {@link Spliterator} over the elements in this queue.
+     * The spliterator does not traverse elements in any particular order
+     * (the {@link Spliterator#ORDERED ORDERED} characteristic is not reported).
      *
      * <p>The returned spliterator is
      * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
--- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1327,7 +1327,7 @@
      * @param s the {@code Supplier} of generated elements
      * @return a new infinite sequential unordered {@code Stream}
      */
-    public static<T> Stream<T> generate(Supplier<T> s) {
+    public static<T> Stream<T> generate(Supplier<? extends T> s) {
         Objects.requireNonNull(s);
         return StreamSupport.stream(
                 new StreamSpliterators.InfiniteSupplyingSpliterator.OfRef<>(Long.MAX_VALUE, s), false);
--- a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1346,9 +1346,9 @@
         }
 
         static final class OfRef<T> extends InfiniteSupplyingSpliterator<T> {
-            final Supplier<T> s;
+            final Supplier<? extends T> s;
 
-            OfRef(long size, Supplier<T> s) {
+            OfRef(long size, Supplier<? extends T> s) {
                 super(size);
                 this.s = s;
             }
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Wed Jul 05 22:30:23 2017 +0200
@@ -72,13 +72,13 @@
         // If neither is specified then default to -cp <working directory>
         // If -cp is not specified and -m is specified, the value of
         // java.class.path is an empty string, then no class path.
-        URLClassPath ucp = null;
+        URLClassPath ucp = new URLClassPath(new URL[0]);
         String mainMid = System.getProperty("jdk.module.main");
         String cp = System.getProperty("java.class.path");
         if (cp == null)
             cp = "";
         if (mainMid == null || cp.length() > 0)
-            ucp = toURLClassPath(cp);
+            addClassPathToUCP(cp, ucp);
 
         // create the class loaders
         BOOT_LOADER = new BootClassLoader(bcp);
--- a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Wed Jul 05 22:30:23 2017 +0200
@@ -462,6 +462,8 @@
      * This method:
      * 1. Loads the main class from the module or class path
      * 2. Checks the public static void main method.
+     * 3. If the main class extends FX Application then call on FXHelper to
+     * perform the launch.
      *
      * @param printToStderr if set, all output will be routed to stderr
      * @param mode LaunchMode as determined by the arguments passed on the
@@ -479,11 +481,23 @@
         Class<?> mainClass = (mode == LM_MODULE) ? loadModuleMainClass(what)
                                                  : loadMainClass(mode, what);
 
-        validateMainClass(mainClass);
+        // record the real main class for UI purposes
+        // neither method above can return null, they will abort()
+        appClass = mainClass;
 
-        // record main class if not already set
-        if (appClass == null)
-            appClass = mainClass;
+        /*
+         * Check if FXHelper can launch it using the FX launcher. In an FX app,
+         * the main class may or may not have a main method, so do this before
+         * validating the main class.
+         */
+        if (JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) ||
+            doesExtendFXApplication(mainClass)) {
+            // Will abort() if there are problems with FX runtime
+            FXHelper.setFXLaunchParameters(what, mode);
+            mainClass = FXHelper.class;
+        }
+
+        validateMainClass(mainClass);
 
         return mainClass;
     }
@@ -530,7 +544,6 @@
 
             String cn = Normalizer.normalize(mainClass, Normalizer.Form.NFC);
             c = Class.forName(m, cn);
-
         }
         if (c == null) {
             abort(null, "java.launcher.module.error2", mainClass, mainModule);
@@ -542,8 +555,6 @@
 
     /**
      * Loads the main class from the class path (LM_CLASS or LM_JAR).
-     * If the main class extends FX Application then call on FXHelper to
-     * determine the main class to launch.
      */
     private static Class<?> loadMainClass(int mode, String what) {
         // get the class name
@@ -570,7 +581,7 @@
             if (System.getProperty("os.name", "").contains("OS X")
                     && Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
                 try {
-                    // On Mac OS X since all names with diacretic symbols are
+                    // On Mac OS X since all names with diacritical marks are
                     // given as decomposed it is possible that main class name
                     // comes incorrectly from the command line and we have
                     // to re-compose it
@@ -583,21 +594,6 @@
                 abort(cnfe, "java.launcher.cls.error1", cn);
             }
         }
-
-        // record the main class
-        appClass = mainClass;
-
-        /*
-         * Check if FXHelper can launch it using the FX launcher. In an FX app,
-         * the main class may or may not have a main method, so do this before
-         * validating the main class.
-         */
-        if (JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) ||
-            doesExtendFXApplication(mainClass)) {
-            // Will abort() if there are problems with FX runtime
-            FXHelper.setFXLaunchParameters(what, mode);
-            return FXHelper.class;
-        }
         return mainClass;
     }
 
@@ -773,9 +769,15 @@
          * java -cp somedir FXClass     N/A               LM_CLASS     "LM_CLASS"
          * java -jar fxapp.jar          Present           LM_JAR       "LM_JAR"
          * java -jar fxapp.jar          Not Present       LM_JAR       "LM_JAR"
+         * java -m module/class [1]     N/A               LM_MODULE    "LM_MODULE"
+         * java -m module               N/A               LM_MODULE    "LM_MODULE"
+         *
+         * [1] - JavaFX-Application-Class is ignored when modular args are used, even
+         * if present in a modular jar
          */
         private static final String JAVAFX_LAUNCH_MODE_CLASS = "LM_CLASS";
         private static final String JAVAFX_LAUNCH_MODE_JAR = "LM_JAR";
+        private static final String JAVAFX_LAUNCH_MODE_MODULE = "LM_MODULE";
 
         /*
          * FX application launcher and launch method, so we can launch
@@ -835,6 +837,9 @@
                 case LM_JAR:
                     fxLaunchMode = JAVAFX_LAUNCH_MODE_JAR;
                     break;
+                case LM_MODULE:
+                    fxLaunchMode = JAVAFX_LAUNCH_MODE_MODULE;
+                    break;
                 default:
                     // should not have gotten this far...
                     throw new InternalError(mode + ": Unknown launch mode");
--- a/jdk/src/java.base/share/classes/sun/security/provider/SunEntries.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/sun/security/provider/SunEntries.java	Wed Jul 05 22:30:23 2017 +0200
@@ -96,25 +96,32 @@
         if (nativeAvailable && useNativePRNG) {
             map.put("SecureRandom.NativePRNG",
                 "sun.security.provider.NativePRNG");
+            map.put("SecureRandom.NativePRNG ThreadSafe", "true");
         }
 
         map.put("SecureRandom.DRBG", "sun.security.provider.DRBG");
+        map.put("SecureRandom.DRBG ThreadSafe", "true");
 
         map.put("SecureRandom.SHA1PRNG",
              "sun.security.provider.SecureRandom");
+
+        map.put("SecureRandom.SHA1PRNG ThreadSafe", "true");
         if (nativeAvailable && !useNativePRNG) {
             map.put("SecureRandom.NativePRNG",
                 "sun.security.provider.NativePRNG");
+            map.put("SecureRandom.NativePRNG ThreadSafe", "true");
         }
 
         if (NativePRNG.Blocking.isAvailable()) {
             map.put("SecureRandom.NativePRNGBlocking",
                 "sun.security.provider.NativePRNG$Blocking");
+            map.put("SecureRandom.NativePRNGBlocking ThreadSafe", "true");
         }
 
         if (NativePRNG.NonBlocking.isAvailable()) {
             map.put("SecureRandom.NativePRNGNonBlocking",
                 "sun.security.provider.NativePRNG$NonBlocking");
+            map.put("SecureRandom.NativePRNGNonBlocking ThreadSafe", "true");
         }
 
         /*
@@ -329,6 +336,7 @@
         map.put("AlgorithmParameters.DSA ImplementedIn", "Software");
         map.put("KeyFactory.DSA ImplementedIn", "Software");
         map.put("SecureRandom.SHA1PRNG ImplementedIn", "Software");
+        map.put("SecureRandom.DRBG ImplementedIn", "Software");
         map.put("CertificateFactory.X.509 ImplementedIn", "Software");
         map.put("KeyStore.JKS ImplementedIn", "Software");
         map.put("CertPathValidator.PKIX ImplementedIn", "Software");
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java	Wed Jul 05 22:30:23 2017 +0200
@@ -403,6 +403,13 @@
                             EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
                             suite.name, null)) {
                         suites.add(suite);
+                    } else {
+                        if (debug != null && Debug.isOn("sslctx") &&
+                                Debug.isOn("verbose")) {
+                            System.out.println(
+                                    "Ignoring disabled cipher suite: " +
+                                            suite.name);
+                        }
                     }
                 } else if (debug != null &&
                         Debug.isOn("sslctx") && Debug.isOn("verbose")) {
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLSessionImpl.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLSessionImpl.java	Wed Jul 05 22:30:23 2017 +0200
@@ -960,17 +960,6 @@
             + "]";
     }
 
-    /**
-     * When SSL sessions are finalized, all values bound to
-     * them are removed.
-     */
-    @Override
-    protected void finalize() throws Throwable {
-        String[] names = getValueNames();
-        for (int i = 0; i < names.length; i++) {
-            removeValue(names[i]);
-        }
-    }
 }
 
 
--- a/jdk/src/java.base/share/lib/security/default.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.base/share/lib/security/default.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -155,7 +155,6 @@
 grant codeBase "jrt:/jdk.localedata" {
     permission java.lang.RuntimePermission "accessClassInPackage.sun.text.*";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*";
-    permission java.util.PropertyPermission "*", "read";
 };
 
 grant codeBase "jrt:/jdk.naming.dns" {
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java	Wed Jul 05 22:30:23 2017 +0200
@@ -431,6 +431,7 @@
         }
 
         @Override
+        @SuppressWarnings("deprecation")
         public void mouseReleased(final MouseEvent e) {
             if (didForwardEvent(e)) return;
 
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldFormattedUI.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldFormattedUI.java	Wed Jul 05 22:30:23 2017 +0200
@@ -55,6 +55,7 @@
         super.uninstallListeners();
     }
 
+    @SuppressWarnings("deprecation")
     public void mouseClicked(final MouseEvent e) {
         if (e.getClickCount() != 1) return;
 
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java	Wed Jul 05 22:30:23 2017 +0200
@@ -176,11 +176,12 @@
         }
 
         @Override
+        @SuppressWarnings("deprecation")
         T getInstance() {
             try {
                 ReflectUtil.checkPackageAccess(clazz);
                 return clazz.newInstance();
-            } catch (InstantiationException | IllegalAccessException ignored) {
+            } catch (ReflectiveOperationException ignored) {
             }
             return null;
         }
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java	Wed Jul 05 22:30:23 2017 +0200
@@ -672,7 +672,7 @@
                 TexturePaint color = (TexturePaint) sg2d.paint;
                 this.fGraphicsStatesInt.put(kColorStateIndex, kColorTexture);
                 texturePaintImage = color.getImage();
-                SurfaceData textureSurfaceData = BufImgSurfaceData.createData(texturePaintImage);
+                SurfaceData textureSurfaceData = OSXOffScreenSurfaceData.createNewSurface(texturePaintImage);
                 this.fGraphicsStatesInt.put(kColorWidthIndex, texturePaintImage.getWidth());
                 this.fGraphicsStatesInt.put(kColorHeightIndex, texturePaintImage.getHeight());
                 Rectangle2D anchor = color.getAnchorRect();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibleText.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibleText.java	Wed Jul 05 22:30:23 2017 +0200
@@ -293,6 +293,7 @@
         }, c);
     }
 
+    @SuppressWarnings("deprecation")
     static int[] getVisibleCharacterRange(final Accessible a) {
         final Accessible sa = CAccessible.getSwingAccessible(a);
         if (!(sa instanceof JTextComponent)) return null;
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Wed Jul 05 22:30:23 2017 +0200
@@ -38,6 +38,7 @@
 import java.util.*;
 import java.util.regex.*;
 import java.awt.datatransfer.*;
+import java.nio.charset.StandardCharsets;
 import sun.awt.datatransfer.*;
 
 public class CDataTransferer extends DataTransferer {
@@ -132,7 +133,7 @@
             String charset = Charset.defaultCharset().name();
             if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
                 try {
-                    charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), "UTF-8");
+                    charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), StandardCharsets.UTF_8);
                 } catch (UnsupportedFlavorException cannotHappen) {
                 }
             }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Wed Jul 05 22:30:23 2017 +0200
@@ -214,6 +214,7 @@
             this.setDefaultDragImage();
     }
 
+    @SuppressWarnings("deprecation")
     private void setDefaultDragImage(JTextComponent component) {
         DragGestureEvent trigger = getTrigger();
         int selectionStart = component.getSelectionStart();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java	Wed Jul 05 22:30:23 2017 +0200
@@ -196,7 +196,8 @@
                                   getLocalGraphicsEnvironment();
 
         LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
-        int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();
+        int scale =(int) Math.round(((LightweightFrame)peer.getTarget())
+                                                            .getScaleFactorX());
 
         Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
         for (GraphicsDevice d : ge.getScreenDevices()) {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Jul 05 22:30:23 2017 +0200
@@ -25,10 +25,12 @@
 
 package sun.lwawt.macosx;
 
+import com.apple.eawt.FullScreenAdapter;
+import com.apple.eawt.FullScreenUtilities;
+import com.apple.eawt.event.FullScreenEvent;
 import java.awt.*;
 import java.awt.Dialog.ModalityType;
 import java.awt.event.*;
-import java.awt.peer.WindowPeer;
 import java.beans.*;
 import java.lang.reflect.InvocationTargetException;
 
@@ -44,6 +46,7 @@
 import com.apple.laf.*;
 import com.apple.laf.ClientPropertyApplicator.Property;
 import com.sun.awt.AWTUtilities;
+import sun.lwawt.LWWindowPeer.PeerType;
 
 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
     private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
@@ -175,10 +178,24 @@
             c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString()));
         }},
         new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
-            c.setStyleBits(ZOOMABLE, Boolean.parseBoolean(value.toString()));
+            boolean zoomable = Boolean.parseBoolean(value.toString());
+            if (c.target instanceof RootPaneContainer
+                    && c.getPeer().getPeerType() == PeerType.FRAME) {
+                if (c.isInFullScreen && !zoomable) {
+                    c.toggleFullScreen();
+                }
+            }
+            c.setStyleBits(ZOOMABLE, zoomable);
         }},
         new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
-            c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString()));
+            boolean fullscrenable = Boolean.parseBoolean(value.toString());
+            if (c.target instanceof RootPaneContainer
+                    && c.getPeer().getPeerType() == PeerType.FRAME) {
+                if (c.isInFullScreen && !fullscrenable) {
+                    c.toggleFullScreen();
+                }
+            }
+            c.setStyleBits(FULLSCREENABLE, fullscrenable);
         }},
         new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
             nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
@@ -210,6 +227,8 @@
     private volatile boolean isFullScreenMode;
     private boolean isFullScreenAnimationOn;
 
+    private volatile boolean isInFullScreen;
+
     private Window target;
     private LWWindowPeer peer;
     protected CPlatformView contentView;
@@ -308,6 +327,8 @@
             styleBits = SET(styleBits, RESIZABLE, resizable);
             if (!resizable) {
                 styleBits = SET(styleBits, ZOOMABLE, false);
+            } else {
+                setCanFullscreen(true);
             }
         }
 
@@ -680,9 +701,25 @@
         updateFocusabilityForAutoRequestFocus(true);
     }
 
+    private void setCanFullscreen(final boolean canFullScreen) {
+        if (target instanceof RootPaneContainer
+                && getPeer().getPeerType() == PeerType.FRAME) {
+
+            if (isInFullScreen && !canFullScreen) {
+                toggleFullScreen();
+            }
+
+            final RootPaneContainer rpc = (RootPaneContainer) target;
+            rpc.getRootPane().putClientProperty(
+                    CPlatformWindow.WINDOW_FULLSCREENABLE, canFullScreen);
+        }
+    }
+
     @Override
     public void setResizable(final boolean resizable) {
+        setCanFullscreen(resizable);
         setStyleBits(RESIZABLE, resizable);
+        setStyleBits(ZOOMABLE, resizable);
     }
 
     @Override
@@ -1074,6 +1111,7 @@
     }
 
     private void windowDidEnterFullScreen() {
+        isInFullScreen = true;
         isFullScreenAnimationOn = false;
     }
 
@@ -1082,6 +1120,7 @@
     }
 
     private void windowDidExitFullScreen() {
+        isInFullScreen = false;
         isFullScreenAnimationOn = false;
     }
 }
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.h	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.h	Wed Jul 05 22:30:23 2017 +0200
@@ -26,6 +26,7 @@
 #include <jni.h>
 #import <Foundation/Foundation.h>
 #import <AppKit/AppKit.h>
+#import <AppKit/NSTrackingArea.h>
 
 #import "CPopupMenu.h"
 
@@ -64,12 +65,14 @@
 @public
     AWTTrayIcon *trayIcon;
     NSImage* image;
+    NSTrackingArea *trackingArea;
     BOOL isHighlighted;
 }
 -(id)initWithTrayIcon:(AWTTrayIcon *)theTrayIcon;
 -(void)setHighlighted:(BOOL)aFlag;
 -(void)setImage:(NSImage*)anImage;
 -(void)setTrayIcon:(AWTTrayIcon*)theTrayIcon;
+-(void)addTrackingArea;
 
 @end //AWTTrayIconView
 
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m	Wed Jul 05 22:30:23 2017 +0200
@@ -171,12 +171,27 @@
     [self setTrayIcon: theTrayIcon];
     isHighlighted = NO;
     image = nil;
+    trackingArea = nil;
+	
+    [self addTrackingArea];
+	
+    return self;
+}
 
-    return self;
+- (void)addTrackingArea {
+    NSTrackingAreaOptions options = NSTrackingMouseMoved | 
+                                    NSTrackingInVisibleRect | 
+                                    NSTrackingActiveAlways;
+    trackingArea = [[NSTrackingArea alloc] initWithRect: CGRectZero
+                                                options: options
+                                                owner: self
+                                                userInfo: nil];
+    [self addTrackingArea:trackingArea];
 }
 
 -(void) dealloc {
     [image release];
+    [trackingArea release];
     [super dealloc];
 }
 
@@ -269,6 +284,10 @@
     [trayIcon deliverJavaMouseEvent: event];
 }
 
+- (void) mouseMoved: (NSEvent *)event {
+    [trayIcon deliverJavaMouseEvent: event];
+}
+
 - (void) rightMouseDown:(NSEvent *)event {
     [trayIcon deliverJavaMouseEvent: event];
 }
--- a/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/DocumentHandler.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/DocumentHandler.java	Wed Jul 05 22:30:23 2017 +0200
@@ -277,10 +277,12 @@
      * @param attributes  the attributes attached to the element
      */
     @Override
+    @SuppressWarnings("deprecation")
     public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
         ElementHandler parent = this.handler;
         try {
-            this.handler = getElementHandler(qName).newInstance();
+            this.handler =
+                getElementHandler(qName).newInstance();
             this.handler.setOwner(this);
             this.handler.setParent(parent);
         }
--- a/jdk/src/java.desktop/share/classes/com/sun/beans/finder/InstanceFinder.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/beans/finder/InstanceFinder.java	Wed Jul 05 22:30:23 2017 +0200
@@ -86,6 +86,7 @@
         return null;
     }
 
+    @SuppressWarnings("deprecation")
     protected T instantiate(Class<?> type, String name) {
         if (type != null) {
             try {
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFaxDecompressor.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFaxDecompressor.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -101,7 +101,8 @@
         0xff  // 8
     };
 
-    // Table to be used when fillOrder = 2, for flipping bytes.
+    // Table to be used for flipping bytes when fillOrder is
+    // BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT (2).
     static byte flipTable[] = {
          0,  -128,    64,   -64,    32,   -96,    96,   -32,
         16,  -112,    80,   -48,    48,   -80,   112,   -16,
@@ -597,7 +598,8 @@
             TIFFField f;
 
             f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_FILL_ORDER);
-            this.fillOrder = f == null ? 1 : f.getAsInt(0);
+            this.fillOrder = f == null ?
+               BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT : f.getAsInt(0);
 
             f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
             this.compression = f == null ?
@@ -612,7 +614,7 @@
             f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_T6_OPTIONS);
             this.t6Options = f == null ? 0 : f.getAsInt(0);
         } else {
-            this.fillOrder = 1; // MSB-to-LSB
+            this.fillOrder = BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT;
 
             this.compression = BaselineTIFFTagSet.COMPRESSION_CCITT_RLE; // RLE
 
@@ -1458,7 +1460,7 @@
         int l = data.length - 1;
         int bp = this.bytePointer;
 
-        if (fillOrder == 1) {
+        if (fillOrder == BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT) {
             b = data[bp];
 
             if (bp == l) {
@@ -1471,7 +1473,7 @@
                 next = data[bp + 1];
                 next2next = data[bp + 2];
             }
-        } else if (fillOrder == 2) {
+        } else if (fillOrder == BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT) {
             b = flipTable[data[bp] & 0xff];
 
             if (bp == l) {
@@ -1527,14 +1529,14 @@
         int l = data.length - 1;
         int bp = this.bytePointer;
 
-        if (fillOrder == 1) {
+        if (fillOrder == BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT) {
             b = data[bp];
             if (bp == l) {
                 next = 0x00;
             } else {
                 next = data[bp + 1];
             }
-        } else if (fillOrder == 2) {
+        } else if (fillOrder == BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT) {
             b = flipTable[data[bp] & 0xff];
             if (bp == l) {
                 next = 0x00;
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java	Wed Jul 05 22:30:23 2017 +0200
@@ -49,6 +49,52 @@
     private long stripOrTileOffsetsPosition = -1;
     private long lastPosition = -1;
 
+    //
+    // A set of tag numbers corresponding to tags essential to decoding
+    // the image and metadata required to interpret its samples.
+    //
+    private static volatile Set<Integer> essentialTags = null;
+
+    private static void initializeEssentialTags() {
+        Set<Integer> tags = essentialTags;
+        if (tags == null) {
+            essentialTags = tags = Set.of(
+                BaselineTIFFTagSet.TAG_BITS_PER_SAMPLE,
+                BaselineTIFFTagSet.TAG_COLOR_MAP,
+                BaselineTIFFTagSet.TAG_COMPRESSION,
+                BaselineTIFFTagSet.TAG_EXTRA_SAMPLES,
+                BaselineTIFFTagSet.TAG_FILL_ORDER,
+                BaselineTIFFTagSet.TAG_ICC_PROFILE,
+                BaselineTIFFTagSet.TAG_IMAGE_LENGTH,
+                BaselineTIFFTagSet.TAG_IMAGE_WIDTH,
+                BaselineTIFFTagSet.TAG_JPEG_AC_TABLES,
+                BaselineTIFFTagSet.TAG_JPEG_DC_TABLES,
+                BaselineTIFFTagSet.TAG_JPEG_INTERCHANGE_FORMAT,
+                BaselineTIFFTagSet.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH,
+                BaselineTIFFTagSet.TAG_JPEG_PROC,
+                BaselineTIFFTagSet.TAG_JPEG_Q_TABLES,
+                BaselineTIFFTagSet.TAG_JPEG_RESTART_INTERVAL,
+                BaselineTIFFTagSet.TAG_JPEG_TABLES,
+                BaselineTIFFTagSet.TAG_PHOTOMETRIC_INTERPRETATION,
+                BaselineTIFFTagSet.TAG_PLANAR_CONFIGURATION,
+                BaselineTIFFTagSet.TAG_PREDICTOR,
+                BaselineTIFFTagSet.TAG_REFERENCE_BLACK_WHITE,
+                BaselineTIFFTagSet.TAG_ROWS_PER_STRIP,
+                BaselineTIFFTagSet.TAG_SAMPLES_PER_PIXEL,
+                BaselineTIFFTagSet.TAG_SAMPLE_FORMAT,
+                BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS,
+                BaselineTIFFTagSet.TAG_STRIP_OFFSETS,
+                BaselineTIFFTagSet.TAG_T4_OPTIONS,
+                BaselineTIFFTagSet.TAG_T6_OPTIONS,
+                BaselineTIFFTagSet.TAG_TILE_BYTE_COUNTS,
+                BaselineTIFFTagSet.TAG_TILE_LENGTH,
+                BaselineTIFFTagSet.TAG_TILE_OFFSETS,
+                BaselineTIFFTagSet.TAG_TILE_WIDTH,
+                BaselineTIFFTagSet.TAG_Y_CB_CR_COEFFICIENTS,
+                BaselineTIFFTagSet.TAG_Y_CB_CR_SUBSAMPLING
+            );
+        }
+    }
 
     /**
      * Converts a {@code TIFFDirectory} to a {@code TIFFIFD}.
@@ -507,6 +553,15 @@
 
         List<TIFFTagSet> tagSetList = getTagSetList();
 
+        boolean ensureEssentialTags = false;
+        TIFFTagSet baselineTagSet = null;
+        if (isPrimaryIFD && ignoreUnknownFields
+            && !tagSetList.contains(BaselineTIFFTagSet.getInstance())) {
+            ensureEssentialTags = true;
+            initializeEssentialTags();
+            baselineTagSet = BaselineTIFFTagSet.getInstance();
+        }
+
         List<Object> entries = new ArrayList<>();
         Object[] entryData = new Object[1]; // allocate once for later reuse.
 
@@ -530,6 +585,11 @@
             // Get the associated TIFFTag.
             TIFFTag tag = getTag(tagNumber, tagSetList);
 
+            if (tag == null && ensureEssentialTags
+                && essentialTags.contains(tagNumber)) {
+                tag = baselineTagSet.getTag(tagNumber);
+            }
+
             // Ignore unknown fields, fields with unknown type, and fields
             // with count out of int range.
             if((tag == null && ignoreUnknownFields)
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1174,7 +1174,14 @@
             int predictor = ((predictorField == null)
                     ? BaselineTIFFTagSet.PREDICTOR_NONE
                     : predictorField.getAsInt(0));
-            this.decompressor = new TIFFLZWDecompressor(predictor);
+
+            TIFFField fillOrderField
+                    = imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_FILL_ORDER);
+            int fillOrder = ((fillOrderField == null)
+                    ? BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT
+                    : fillOrderField.getAsInt(0));
+
+            this.decompressor = new TIFFLZWDecompressor(predictor, fillOrder);
         } else if (compression
                 == BaselineTIFFTagSet.COMPRESSION_JPEG) {
             this.decompressor = new TIFFJPEGDecompressor();
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFLZWDecompressor.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFLZWDecompressor.java	Wed Jul 05 22:30:23 2017 +0200
@@ -30,6 +30,10 @@
 
 class TIFFLZWDecompressor extends TIFFDecompressor {
 
+    private static final int CLEAR_CODE = 256;
+    private static final int EOI_CODE   = 257;
+    private static final int FIRST_CODE = 258;
+
     private static final int andTable[] = {
         511,
         1023,
@@ -39,6 +43,10 @@
 
     private int predictor;
 
+    // whether to reverse the bits in each byte of the input data, i.e.,
+    // convert right-to-left fill order (lsb) to left-to-right (msb).
+    private boolean flipBits;
+
     private byte[] srcData;
     private byte[] dstData;
 
@@ -51,7 +59,8 @@
     private int nextData = 0;
     private int nextBits = 0;
 
-    public TIFFLZWDecompressor(int predictor) throws IIOException {
+    public TIFFLZWDecompressor(int predictor, int fillOrder)
+        throws IIOException {
         super();
 
         if (predictor != BaselineTIFFTagSet.PREDICTOR_NONE &&
@@ -62,6 +71,8 @@
         }
 
         this.predictor = predictor;
+
+        flipBits = fillOrder == BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT;
     }
 
     public void decodeRaw(byte[] b,
@@ -88,6 +99,12 @@
         byte[] sdata = new byte[byteCount];
         stream.readFully(sdata);
 
+        if (flipBits) {
+            for (int i = 0; i < byteCount; i++) {
+                sdata[i] = TIFFFaxDecompressor.flipTable[sdata[i] & 0xff];
+            }
+        }
+
         int bytesPerRow = (srcWidth*bitsPerPixel + 7)/8;
         byte[] buf;
         int bufOffset;
@@ -133,11 +150,11 @@
         int code, oldCode = 0;
         byte[] string;
 
-        while ((code = getNextCode()) != 257) {
-            if (code == 256) {
+        while ((code = getNextCode()) != EOI_CODE) {
+            if (code == CLEAR_CODE) {
                 initializeStringTable();
                 code = getNextCode();
-                if (code == 257) {
+                if (code == EOI_CODE) {
                     break;
                 }
 
@@ -186,12 +203,12 @@
     public void initializeStringTable() {
         stringTable = new byte[4096][];
 
-        for (int i = 0; i < 256; i++) {
+        for (int i = 0; i < CLEAR_CODE; i++) {
             stringTable[i] = new byte[1];
             stringTable[i][0] = (byte)i;
         }
 
-        tableIndex = 258;
+        tableIndex = FIRST_CODE;
         bitsToGet = 9;
     }
 
@@ -281,7 +298,7 @@
             return code;
         } catch (ArrayIndexOutOfBoundsException e) {
             // Strip not terminated as expected: return EndOfInformation code.
-            return 257;
+            return EOI_CODE;
         }
     }
 }
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java	Wed Jul 05 22:30:23 2017 +0200
@@ -88,6 +88,7 @@
      *  or {@code Applet}
      * @param isRequested the value to set vsyncRequested state to
      */
+    @SuppressWarnings("deprecation")
     public static void setVsyncRequested(Container rootContainer,
                                          boolean isRequested) {
         assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
@@ -104,6 +105,7 @@
      * @param rootContainer topmost container. Should be either Window or Applet
      * @return {@code true} if vsync painting is requested for {@code rootContainer}
      */
+    @SuppressWarnings("deprecation")
     public static boolean isVsyncRequested(Container rootContainer) {
         assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
         return Boolean.TRUE == vsyncedMap.get(rootContainer);
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1125,6 +1125,7 @@
             this.methodName = methodName;
         }
 
+        @SuppressWarnings("deprecation")
         public Object createValue(UIDefaults table) {
             try {
                 Class<?> c = Class.forName(className, true,Thread.currentThread().
@@ -1136,11 +1137,7 @@
                 Method m = c.getMethod(methodName, (Class<?>[])null);
 
                 return m.invoke(c, (Object[])null);
-            } catch (ClassNotFoundException cnfe) {
-            } catch (IllegalAccessException iae) {
-            } catch (InvocationTargetException ite) {
-            } catch (NoSuchMethodException nsme) {
-            } catch (InstantiationException ie) {
+            } catch (ReflectiveOperationException e) {
             }
             return null;
         }
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType;
 
 import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
 import javax.swing.plaf.synth.*;
 
 import java.awt.*;
@@ -40,7 +41,6 @@
 import java.util.*;
 
 import javax.swing.*;
-import javax.swing.border.*;
 
 import javax.xml.parsers.*;
 import org.xml.sax.SAXException;
@@ -226,12 +226,8 @@
         JComponent titlePane = (JComponent)button.getParent();
         Container titlePaneParent = titlePane.getParent();
 
-        JInternalFrame jif;
-        if (titlePaneParent instanceof JInternalFrame) {
-            jif = (JInternalFrame)titlePaneParent;
-        } else if (titlePaneParent instanceof JInternalFrame.JDesktopIcon) {
-            jif = ((JInternalFrame.JDesktopIcon)titlePaneParent).getInternalFrame();
-        } else {
+        JInternalFrame jif = findInternalFrame(titlePaneParent);
+        if (jif == null) {
             return;
         }
 
@@ -332,6 +328,19 @@
         }
     }
 
+    JInternalFrame findInternalFrame(Component comp) {
+        if (comp.getParent() instanceof BasicInternalFrameTitlePane) {
+            comp = comp.getParent();
+        }
+        if (comp instanceof JInternalFrame) {
+            return  (JInternalFrame)comp;
+        } else if (comp instanceof JInternalFrame.JDesktopIcon) {
+            return ((JInternalFrame.JDesktopIcon)comp).getInternalFrame();
+        }
+        assert false : "cannot find the internal frame";
+        return null;
+    }
+
     void paintFrameBorder(SynthContext context, Graphics g, int x0, int y0, int width, int height) {
         updateFrameGeometry(context);
 
@@ -343,13 +352,8 @@
             return;
         }
 
-        JInternalFrame jif = null;
-        if (comp instanceof JInternalFrame) {
-            jif = (JInternalFrame)comp;
-        } else if (comp instanceof JInternalFrame.JDesktopIcon) {
-            jif = ((JInternalFrame.JDesktopIcon)comp).getInternalFrame();
-        } else {
-            assert false : "component is not JInternalFrame or JInternalFrame.JDesktopIcon";
+        JInternalFrame jif = findInternalFrame(comp);
+        if (jif == null) {
             return;
         }
 
@@ -1467,13 +1471,8 @@
         JComponent comp = context.getComponent();
         JComponent titlePane = findChild(comp, "InternalFrame.northPane");
 
-        JInternalFrame jif = null;
-        if (comp instanceof JInternalFrame) {
-            jif = (JInternalFrame)comp;
-        } else if (comp instanceof JInternalFrame.JDesktopIcon) {
-            jif = ((JInternalFrame.JDesktopIcon)comp).getInternalFrame();
-        } else {
-            assert false : "component is not JInternalFrame or JInternalFrame.JDesktopIcon";
+        JInternalFrame jif = findInternalFrame(comp);
+        if (jif == null) {
             return;
         }
 
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifTextUI.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifTextUI.java	Wed Jul 05 22:30:23 2017 +0200
@@ -124,6 +124,7 @@
          * @param g the graphics context
          * @see #damage
          */
+        @SuppressWarnings("deprecation")
         public void paint(Graphics g) {
             if(isVisible()) {
                 try {
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java	Wed Jul 05 22:30:23 2017 +0200
@@ -132,6 +132,7 @@
                 this.r = r;
             }
 
+            @SuppressWarnings("deprecation")
             public void run() {
                 JTextField field = (JTextField) getComponent();
                 if (field != null) {
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java	Wed Jul 05 22:30:23 2017 +0200
@@ -93,6 +93,7 @@
          * @param bounds the bounding box for the highlight
          * @param c the editor
          */
+        @SuppressWarnings("deprecation")
         public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
             Rectangle alloc = bounds.getBounds();
             try {
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java	Wed Jul 05 22:30:23 2017 +0200
@@ -70,6 +70,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public Soundbank getSoundbank(URL url)
             throws InvalidMidiDataException, IOException {
         if (!isZIP(url))
@@ -93,9 +94,7 @@
                             Object o = c.newInstance();
                             soundbanks.add((Soundbank) o);
                         }
-                    } catch (ClassNotFoundException ignored) {
-                    } catch (InstantiationException ignored) {
-                    } catch (IllegalAccessException ignored) {
+                    } catch (ReflectiveOperationException ignored) {
                     }
                 }
                 line = r.readLine();
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java	Wed Jul 05 22:30:23 2017 +0200
@@ -55,6 +55,7 @@
  * @author Arthur van Hoff, Kara Kytle, Jan Borgersen
  * @author Florian Bomers
  */
+@SuppressWarnings("deprecation")
 public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
 
     private static final boolean DEBUG = false;
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelAbstractOscillator.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelAbstractOscillator.java	Wed Jul 05 22:30:23 2017 +0200
@@ -134,13 +134,12 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public ModelOscillatorStream open(float samplerate) {
         ModelAbstractOscillator oscs;
         try {
             oscs = this.getClass().newInstance();
-        } catch (InstantiationException e) {
-            throw new IllegalArgumentException(e);
-        } catch (IllegalAccessException e) {
+        } catch (ReflectiveOperationException e) {
             throw new IllegalArgumentException(e);
         }
         oscs.setSampleRate(samplerate);
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java	Wed Jul 05 22:30:23 2017 +0200
@@ -4016,6 +4016,7 @@
          * {@code true}.
          * @see #createBuffers(int, BufferCapabilities)
          */
+        @SuppressWarnings("deprecation")
         protected FlipBufferStrategy(int numBuffers, BufferCapabilities caps)
             throws AWTException
         {
@@ -8133,6 +8134,7 @@
         return res;
     }
 
+    @SuppressWarnings("deprecation")
     final Component getNextFocusCandidate() {
         Container rootAncestor = getTraversalRoot();
         Component comp = this;
--- a/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java	Wed Jul 05 22:30:23 2017 +0200
@@ -75,6 +75,7 @@
     private LinkedList<KeyEvent> enqueuedKeyEvents = new LinkedList<KeyEvent>();
     private LinkedList<TypeAheadMarker> typeAheadMarkers = new LinkedList<TypeAheadMarker>();
     private boolean consumeNextKeyTyped;
+    private Component restoreFocusTo;
 
     static {
         AWTAccessor.setDefaultKeyboardFocusManagerAccessor(
@@ -145,19 +146,24 @@
     }
     private boolean restoreFocus(Window aWindow, Component vetoedComponent,
                                  boolean clearOnFailure) {
+        restoreFocusTo = null;
         Component toFocus =
             KeyboardFocusManager.getMostRecentFocusOwner(aWindow);
 
         if (toFocus != null && toFocus != vetoedComponent) {
-            Component heavyweight = getHeavyweight(aWindow);
-            if (heavyweight != null) {
-                setNativeFocusOwner(heavyweight);
-                Toolkit.getEventQueue().createSecondaryLoop(
-                        () -> getGlobalFocusedWindow() != aWindow, null, 50)
-                        .enter();
-            }
-            if (getGlobalFocusedWindow() == aWindow &&
-                              doRestoreFocus(toFocus, vetoedComponent, false)) {
+            if (getHeavyweight(aWindow) != getNativeFocusOwner()) {
+                // cannot restore focus synchronously
+                if (!toFocus.isShowing() || !toFocus.canBeFocusOwner()) {
+                    toFocus = toFocus.getNextFocusCandidate();
+                }
+                if (toFocus != null && toFocus != vetoedComponent) {
+                    if (!toFocus.requestFocus(false,
+                                                   FocusEvent.Cause.ROLLBACK)) {
+                        restoreFocusTo = toFocus;
+                    }
+                    return true;
+                }
+            } else if (doRestoreFocus(toFocus, vetoedComponent, false)) {
                 return true;
             }
         }
@@ -423,6 +429,8 @@
                     // may cause deadlock, thus we don't synchronize this block.
                     Component toFocus = KeyboardFocusManager.
                         getMostRecentFocusOwner(newFocusedWindow);
+                    boolean isFocusRestore = restoreFocusTo != null &&
+                                                      toFocus == restoreFocusTo;
                     if ((toFocus == null) &&
                         newFocusedWindow.isFocusableWindow())
                     {
@@ -441,7 +449,10 @@
                                        tempLost, toFocus);
                     }
                     if (tempLost != null) {
-                        tempLost.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
+                        tempLost.requestFocusInWindow(
+                                    isFocusRestore && tempLost == toFocus ?
+                                                FocusEvent.Cause.ROLLBACK :
+                                                FocusEvent.Cause.ACTIVATION);
                     }
 
                     if (toFocus != null && toFocus != tempLost) {
@@ -450,6 +461,7 @@
                         toFocus.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
                     }
                 }
+                restoreFocusTo = null;
 
                 Window realOppositeWindow = this.realOppositeWindowWR.get();
                 if (realOppositeWindow != we.getOppositeWindow()) {
@@ -499,6 +511,7 @@
             }
 
             case FocusEvent.FOCUS_GAINED: {
+                restoreFocusTo = null;
                 FocusEvent fe = (FocusEvent)e;
                 Component oldFocusOwner = getGlobalFocusOwner();
                 Component newFocusOwner = fe.getComponent();
--- a/jdk/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java	Wed Jul 05 22:30:23 2017 +0200
@@ -108,7 +108,7 @@
                 ClassLoader cl = ClassLoader.getSystemClassLoader();
                 geCls = Class.forName(nm, true, cl);
             }
-            ge = (GraphicsEnvironment)geCls.newInstance();
+            ge = (GraphicsEnvironment)geCls.getConstructor().newInstance();
 //          long t1 = System.currentTimeMillis();
 //          System.out.println("GE creation took " + (t1-t0)+ "ms.");
             if (isHeadless()) {
@@ -116,12 +116,9 @@
             }
         } catch (ClassNotFoundException e) {
             throw new Error("Could not find class: "+nm);
-        } catch (InstantiationException e) {
+        } catch (ReflectiveOperationException | IllegalArgumentException e) {
             throw new Error("Could not instantiate Graphics Environment: "
                             + nm);
-        } catch (IllegalAccessException e) {
-            throw new Error ("Could not access Graphics Environment: "
-                             + nm);
         }
         return ge;
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java	Wed Jul 05 22:30:23 2017 +0200
@@ -407,10 +407,21 @@
     }
 
     /**
-     * Displays progress for specified window.
+     * Displays a determinate progress bar in the task area for the specified
+     * window.
+     * <br>
+     * The visual behavior is platform and {@link State} dependent.
+     * <br>
+     * This call cancels the {@link State#INDETERMINATE INDETERMINATE} state
+     * of the window.
+     * <br>
+     * Note that when multiple windows is grouped in the task area
+     * the behavior is platform specific.
      *
      * @param w window to update
-     * @param value from 0 to 100, other to disable progress indication
+     * @param value from 0 to 100, other to switch to {@link State#OFF} state
+     *              and disable progress indication
+     * @see #setWindowProgressState(java.awt.Window, State)
      * @throws SecurityException if a security manager exists and it denies the
      * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
@@ -426,14 +437,21 @@
 
     /**
      * Sets a progress state for a specified window.
+     * <br>
+     * Each state displays a progress in a platform-dependent way.
+     * <br>
+     * Note than switching from {@link State#INDETERMINATE INDETERMINATE} state
+     * to any of determinate states may reset value set by
+     * {@link #setWindowProgressValue(java.awt.Window, int) setWindowProgressValue}
      *
      * @param w window
      * @param state to change to
      * @see State#OFF
      * @see State#NORMAL
      * @see State#PAUSED
+     * @see State#ERROR
      * @see State#INDETERMINATE
-     * @see State#ERROR
+     * @see #setWindowProgressValue(java.awt.Window, int)
      * @throws SecurityException if a security manager exists and it denies the
      * {@code RuntimePermission("canProcessApplicationEvents")} permission.
      * @throws UnsupportedOperationException if the current platform
--- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java	Wed Jul 05 22:30:23 2017 +0200
@@ -468,7 +468,7 @@
     private static void fallbackToLoadClassForAT(String atName) {
         try {
             Class<?> c = Class.forName(atName, false, ClassLoader.getSystemClassLoader());
-            c.newInstance();
+            c.getConstructor().newInstance();
         } catch (ClassNotFoundException e) {
             newAWTError(e, "Assistive Technology not found: " + atName);
         } catch (InstantiationException e) {
@@ -583,15 +583,13 @@
                     }
                     try {
                         if (cls != null) {
-                            toolkit = (Toolkit)cls.newInstance();
+                            toolkit = (Toolkit)cls.getConstructor().newInstance();
                             if (GraphicsEnvironment.isHeadless()) {
                                 toolkit = new HeadlessToolkit(toolkit);
                             }
                         }
-                    } catch (final InstantiationException ignored) {
-                        throw new AWTError("Could not instantiate Toolkit: " + nm);
-                    } catch (final IllegalAccessException ignored) {
-                        throw new AWTError("Could not access Toolkit: " + nm);
+                    } catch (final ReflectiveOperationException ignored) {
+                        throw new AWTError("Could not create Toolkit: " + nm);
                     }
                     return null;
                 }
--- a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java	Wed Jul 05 22:30:23 2017 +0200
@@ -79,13 +79,12 @@
             public PrinterJob run() {
                 String nm = System.getProperty("java.awt.printerjob", null);
                 try {
-                    return (PrinterJob)Class.forName(nm).newInstance();
+                    return (PrinterJob)Class.forName(nm).
+                                             getConstructor().newInstance();
                 } catch (ClassNotFoundException e) {
                     throw new AWTError("PrinterJob not found: " + nm);
-                } catch (InstantiationException e) {
+                } catch (ReflectiveOperationException e) {
                  throw new AWTError("Could not instantiate PrinterJob: " + nm);
-                } catch (IllegalAccessException e) {
-                    throw new AWTError("Could not access PrinterJob: " + nm);
                 }
             }
         });
--- a/jdk/src/java.desktop/share/classes/java/beans/AppletInitializer.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/beans/AppletInitializer.java	Wed Jul 05 22:30:23 2017 +0200
@@ -44,6 +44,7 @@
  */
 
 
+@SuppressWarnings("deprecation")
 public interface AppletInitializer {
 
     /**
--- a/jdk/src/java.desktop/share/classes/java/beans/Beans.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/beans/Beans.java	Wed Jul 05 22:30:23 2017 +0200
@@ -154,7 +154,7 @@
      * @exception IOException if an I/O error occurs.
      * @since 1.2
      */
-
+    @SuppressWarnings("deprecation")
     public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer)
                         throws IOException, ClassNotFoundException {
 
@@ -501,7 +501,7 @@
  * Package private support class.  This provides a default AppletContext
  * for beans which are applets.
  */
-
+@SuppressWarnings("deprecation")
 class BeansAppletContext implements AppletContext {
     Applet target;
     Hashtable<URL,Object> imageCache = new Hashtable<>();
@@ -586,6 +586,7 @@
  * Package private support class.  This provides an AppletStub
  * for beans which are applets.
  */
+@SuppressWarnings("deprecation")
 class BeansAppletStub implements AppletStub {
     transient boolean active;
     transient Applet target;
--- a/jdk/src/java.desktop/share/classes/java/beans/Introspector.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/beans/Introspector.java	Wed Jul 05 22:30:23 2017 +0200
@@ -36,6 +36,7 @@
 import java.lang.ref.Reference;
 import java.lang.ref.SoftReference;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 
@@ -1278,8 +1279,10 @@
      * First try the classloader of "sibling", then try the system
      * classloader then the class loader of the current Thread.
      */
+    @SuppressWarnings("deprecation")
     static Object instantiate(Class<?> sibling, String className)
                  throws InstantiationException, IllegalAccessException,
+                        NoSuchMethodException, InvocationTargetException,
                                                 ClassNotFoundException {
         // First check with sibling's classloader (if any).
         ClassLoader cl = sibling.getClassLoader();
--- a/jdk/src/java.desktop/share/classes/java/beans/MetaData.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/beans/MetaData.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1219,7 +1219,7 @@
         internalPersistenceDelegates.put("java.sql.Time", new java_util_Date_PersistenceDelegate());
     }
 
-    @SuppressWarnings("rawtypes")
+    @SuppressWarnings({"rawtypes", "deprecation"})
     public static synchronized PersistenceDelegate getPersistenceDelegate(Class type) {
         if (type == null) {
             return nullPersistenceDelegate;
@@ -1261,7 +1261,7 @@
             internalPersistenceDelegates.put(typeName, defaultPersistenceDelegate);
             try {
                 String name =  type.getName();
-                Class c = Class.forName("java.beans.MetaData$" + name.replace('.', '_')
+                Class<?> c = Class.forName("java.beans.MetaData$" + name.replace('.', '_')
                                         + "_PersistenceDelegate");
                 pd = (PersistenceDelegate)c.newInstance();
                 internalPersistenceDelegates.put(typeName, pd);
--- a/jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java	Wed Jul 05 22:30:23 2017 +0200
@@ -461,6 +461,7 @@
      *         not been defined or cannot be created
      * @since 1.5
      */
+    @SuppressWarnings("deprecation")
     public PropertyEditor createPropertyEditor(Object bean) {
         Object editor = null;
 
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFileFormat.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFileFormat.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * An instance of the {@code AudioFileFormat} class describes an audio file,
@@ -344,7 +345,7 @@
          * @param  extension the string that commonly marks the file type
          *         without leading dot
          */
-        public Type(String name, String extension) {
+        public Type(final String name, final String extension) {
             this.name = name;
             this.extension = extension;
         }
@@ -353,14 +354,14 @@
          * Finalizes the equals method.
          */
         @Override
-        public final boolean equals(Object obj) {
-            if (toString() == null) {
-                return (obj != null) && (obj.toString() == null);
+        public final boolean equals(final Object obj) {
+            if (this == obj) {
+                return true;
             }
-            if (obj instanceof Type) {
-                return toString().equals(obj.toString());
+            if (!(obj instanceof Type)) {
+                return false;
             }
-            return false;
+            return Objects.equals(name, ((Type) obj).name);
         }
 
         /**
@@ -368,10 +369,7 @@
          */
         @Override
         public final int hashCode() {
-            if (toString() == null) {
-                return 0;
-            }
-            return toString().hashCode();
+            return name != null ? name.hashCode() : 0;
         }
 
         /**
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * {@code AudioFormat} is the class that specifies a particular arrangement of
@@ -599,7 +600,7 @@
          *
          * @param  name the name of the new type of encoding
          */
-        public Encoding(String name) {
+        public Encoding(final String name) {
             this.name = name;
         }
 
@@ -607,14 +608,14 @@
          * Finalizes the equals method.
          */
         @Override
-        public final boolean equals(Object obj) {
-            if (toString() == null) {
-                return (obj != null) && (obj.toString() == null);
+        public final boolean equals(final Object obj) {
+            if (this == obj) {
+                return true;
             }
-            if (obj instanceof Encoding) {
-                return toString().equals(obj.toString());
+            if (!(obj instanceof Encoding)) {
+                return false;
             }
-            return false;
+            return Objects.equals(name, ((Encoding) obj).name);
         }
 
         /**
@@ -622,10 +623,7 @@
          */
         @Override
         public final int hashCode() {
-            if (toString() == null) {
-                return 0;
-            }
-            return toString().hashCode();
+            return name != null ? name.hashCode() : 0;
         }
 
         /**
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -129,7 +129,7 @@
      *         system
      * @throws NullPointerException if {@code stream} or {@code fileType} or
      *         {@code out} are {@code null}
-     * @see #isFileTypeSupported(AudioFileFormat.Type, AudioInputStream)
+     * @see #isFileTypeSupported(Type, AudioInputStream)
      * @see #getAudioFileTypes
      */
     public abstract int write(AudioInputStream stream, Type fileType,
@@ -149,7 +149,7 @@
      *         the system
      * @throws NullPointerException if {@code stream} or {@code fileType} or
      *         {@code out} are {@code null}
-     * @see #isFileTypeSupported
+     * @see #isFileTypeSupported(Type, AudioInputStream)
      * @see #getAudioFileTypes
      */
     public abstract int write(AudioInputStream stream, Type fileType, File out)
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Wed Jul 05 22:30:23 2017 +0200
@@ -555,6 +555,7 @@
      * @see #setComponentPopupMenu
      * @since 1.5
      */
+    @SuppressWarnings("deprecation")
     public JPopupMenu getComponentPopupMenu() {
 
         if(!getInheritsPopupMenu()) {
@@ -2913,6 +2914,7 @@
      * @param pressed true if the key is pressed
      * @return true if there is a key binding for <code>e</code>
      */
+    @SuppressWarnings("deprecation")
     boolean processKeyBindings(KeyEvent e, boolean pressed) {
       if (!SwingUtilities.isValidKeyEventForKeyBindings(e)) {
           return false;
@@ -4457,6 +4459,7 @@
      *          return value for this method
      * @see #getVisibleRect
      */
+    @SuppressWarnings("deprecation")
     static final void computeVisibleRect(Component c, Rectangle visibleRect) {
         Container p = c.getParent();
         Rectangle bounds = c.getBounds();
@@ -4625,6 +4628,7 @@
      *          or <code>null</code> if not in any container
      */
     @BeanProperty(bound = false)
+    @SuppressWarnings("deprecation")
     public Container getTopLevelAncestor() {
         for(Container p = this; p != null; p = p.getParent()) {
             if(p instanceof Window || p instanceof Applet) {
@@ -5032,6 +5036,7 @@
         this.paintingChild = paintingChild;
     }
 
+    @SuppressWarnings("deprecation")
     void _paintImmediately(int x, int y, int w, int h) {
         Graphics g;
         Container c;
--- a/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java	Wed Jul 05 22:30:23 2017 +0200
@@ -825,6 +825,7 @@
      *
      * @param reference the named location to scroll to
      */
+    @SuppressWarnings("deprecation")
     public void scrollToReference(String reference) {
         Document d = getDocument();
         if (d instanceof HTMLDocument) {
@@ -1179,6 +1180,7 @@
      * @return the editor kit, or <code>null</code> if there is nothing
      *   registered for the given type
      */
+    @SuppressWarnings("deprecation")
     public static EditorKit createEditorKitForContentType(String type) {
         Hashtable<String, EditorKit> kitRegistry = getKitRegisty();
         EditorKit k = kitRegistry.get(type);
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java	Wed Jul 05 22:30:23 2017 +0200
@@ -6043,6 +6043,7 @@
             this.focusManager = fm;
         }
 
+        @SuppressWarnings("deprecation")
         public void propertyChange(PropertyChangeEvent ev) {
             if (!isEditing() || getClientProperty("terminateEditOnFocusLost") != Boolean.TRUE) {
                 return;
--- a/jdk/src/java.desktop/share/classes/javax/swing/JViewport.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JViewport.java	Wed Jul 05 22:30:23 2017 +0200
@@ -27,6 +27,12 @@
 
 import java.awt.*;
 import java.awt.event.*;
+import java.awt.geom.AffineTransform;
+import static java.awt.geom.AffineTransform.TYPE_FLIP;
+import static java.awt.geom.AffineTransform.TYPE_MASK_SCALE;
+import static java.awt.geom.AffineTransform.TYPE_TRANSLATION;
+import java.awt.image.AbstractMultiResolutionImage;
+import java.awt.image.ImageObserver;
 import java.awt.peer.ComponentPeer;
 import java.beans.BeanProperty;
 import java.beans.Transient;
@@ -37,6 +43,8 @@
 import javax.accessibility.*;
 
 import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collections;
 
 import sun.awt.AWTAccessor;
 
@@ -739,7 +747,43 @@
             g.clipRect(0, 0, viewBounds.width, viewBounds.height);
         }
 
-        if (backingStoreImage == null) {
+        boolean recreateBackingStoreImage = (backingStoreImage == null);
+        int scaledWidth = width;
+        int scaledHeight = height;
+
+        if (g instanceof Graphics2D) {
+            double sw = width;
+            double sh = height;
+            Graphics2D g2d = (Graphics2D) g;
+            AffineTransform tx = g2d.getTransform();
+            int type = tx.getType();
+            if ((type & ~(TYPE_TRANSLATION | TYPE_FLIP)) == 0) {
+                // skip
+            } else if ((type & ~(TYPE_TRANSLATION | TYPE_FLIP | TYPE_MASK_SCALE)) == 0) {
+                sw = Math.abs(width * tx.getScaleX());
+                sh = Math.abs(height * tx.getScaleY());
+            } else {
+                sw = Math.abs(width * Math.hypot(tx.getScaleX(), tx.getShearY()));
+                sh = Math.abs(height * Math.hypot(tx.getShearX(), tx.getScaleY()));
+            }
+
+            scaledWidth = (int) Math.ceil(sw);
+            scaledHeight = (int) Math.ceil(sh);
+
+            if (!recreateBackingStoreImage) {
+                if (backingStoreImage instanceof BackingStoreMultiResolutionImage) {
+                    BackingStoreMultiResolutionImage mrImage
+                            = (BackingStoreMultiResolutionImage) backingStoreImage;
+                    recreateBackingStoreImage = (mrImage.scaledWidth != scaledWidth
+                            || mrImage.scaledHeight != scaledHeight);
+                } else {
+                    recreateBackingStoreImage = (width != scaledWidth
+                            || height != scaledHeight);
+                }
+            }
+        }
+
+        if (recreateBackingStoreImage) {
             // Backing store is enabled but this is the first call to paint.
             // Create the backing store, paint it and then copy to g.
             // The backing store image will be created with the size of
@@ -747,7 +791,8 @@
             // same size, otherwise when scrolling the backing image
             // the region outside of the clipped region will not be painted,
             // and result in empty areas.
-            backingStoreImage = createImage(width, height);
+            backingStoreImage = createScaledImage(width, height,
+                                                  scaledWidth, scaledHeight);
             Rectangle clip = g.getClipBounds();
             if (clip.width != width || clip.height != height) {
                 if (!isOpaque()) {
@@ -815,6 +860,74 @@
         scrollUnderway = false;
     }
 
+    private Image createScaledImage(final int width, final int height,
+                                    int scaledWidth, int scaledHeight)
+    {
+        if (scaledWidth == width && scaledHeight == height) {
+            return createImage(width, height);
+        }
+
+        Image rvImage = createImage(scaledWidth, scaledHeight);
+
+        return new BackingStoreMultiResolutionImage(width, height,
+                scaledWidth, scaledHeight, rvImage);
+    }
+
+    static class BackingStoreMultiResolutionImage
+            extends AbstractMultiResolutionImage {
+
+        private final int width;
+        private final int height;
+        private final int scaledWidth;
+        private final int scaledHeight;
+        private final Image rvImage;
+
+        public BackingStoreMultiResolutionImage(int width, int height,
+                int scaledWidth, int scaledHeight, Image rvImage) {
+            this.width = width;
+            this.height = height;
+            this.scaledWidth = scaledWidth;
+            this.scaledHeight = scaledHeight;
+            this.rvImage = rvImage;
+        }
+
+        @Override
+        public int getWidth(ImageObserver observer) {
+            return width;
+        }
+
+        @Override
+        public int getHeight(ImageObserver observer) {
+            return height;
+        }
+
+        @Override
+        protected Image getBaseImage() {
+            return rvImage;
+        }
+
+        @Override
+        public Graphics getGraphics() {
+            Graphics graphics = rvImage.getGraphics();
+            if (graphics instanceof Graphics2D) {
+                double sx = (double) scaledWidth / width;
+                double sy = (double) scaledHeight / height;
+                ((Graphics2D) graphics).scale(sx, sy);
+            }
+            return graphics;
+        }
+
+        @Override
+        public Image getResolutionVariant(double w, double h) {
+            return rvImage;
+        }
+
+        @Override
+        public java.util.List<Image> getResolutionVariants() {
+            return Collections.unmodifiableList(Arrays.asList(rvImage));
+        }
+    }
+
 
     /**
      * Sets the bounds of this viewport.  If the viewport's width
--- a/jdk/src/java.desktop/share/classes/javax/swing/KeyboardManager.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/KeyboardManager.java	Wed Jul 05 22:30:23 2017 +0200
@@ -137,6 +137,7 @@
      /**
        * Find the top focusable Window, Applet, or InternalFrame
        */
+     @SuppressWarnings("deprecation")
      private static Container getTopAncestor(JComponent c) {
         for(Container p = c.getParent(); p != null; p = p.getParent()) {
             if (p instanceof Window && ((Window)p).isFocusableWindow() ||
--- a/jdk/src/java.desktop/share/classes/javax/swing/PopupFactory.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/PopupFactory.java	Wed Jul 05 22:30:23 2017 +0200
@@ -614,6 +614,7 @@
          * Returns true if popup can fit the screen and the owner's top parent.
          * It determines can popup be lightweight or mediumweight.
          */
+        @SuppressWarnings("deprecation")
         boolean fitsOnScreen() {
             boolean result = false;
             Component component = getComponent();
@@ -783,6 +784,8 @@
             component.removeAll();
             recycleLightWeightPopup(this);
         }
+
+        @SuppressWarnings("deprecation")
         public void show() {
             Container parent = null;
 
@@ -938,6 +941,8 @@
             rootPane.getContentPane().removeAll();
             recycleMediumWeightPopup(this);
         }
+
+        @SuppressWarnings("deprecation")
         public void show() {
             Component component = getComponent();
             Container parent = null;
--- a/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Wed Jul 05 22:30:23 2017 +0200
@@ -408,6 +408,7 @@
      *
      * @see JComponent#repaint
      */
+    @SuppressWarnings("deprecation")
     private void addDirtyRegion0(Container c, int x, int y, int w, int h) {
         /* Special cases we don't have to bother with.
          */
@@ -521,10 +522,12 @@
      * @see JApplet#repaint
      * @since 1.6
      */
+    @SuppressWarnings("deprecation")
     public void addDirtyRegion(Applet applet, int x, int y, int w, int h) {
         addDirtyRegion0(applet, x, y, w, h);
     }
 
+    @SuppressWarnings("deprecation")
     void scheduleHeavyWeightPaints() {
         Map<Container,Rectangle> hws;
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java	Wed Jul 05 22:30:23 2017 +0200
@@ -416,6 +416,7 @@
      * @param p  a Point object (converted to the new coordinate system)
      * @param c  a Component object
      */
+    @SuppressWarnings("deprecation")
     public static void convertPointToScreen(Point p,Component c) {
             Rectangle b;
             int x,y;
@@ -455,6 +456,7 @@
      * @param p  a Point object (converted to the new coordinate system)
      * @param c  a Component object
      */
+    @SuppressWarnings("deprecation")
     public static void convertPointFromScreen(Point p,Component c) {
         Rectangle b;
         int x,y;
@@ -1655,6 +1657,7 @@
      * @param c the component
      * @return the first ancestor of c that's a Window or the last Applet ancestor
      */
+    @SuppressWarnings("deprecation")
     public static Component getRoot(Component c) {
         Component applet = null;
         for(Component p = c; p != null; p = p.getParent()) {
@@ -1695,6 +1698,7 @@
      * @return true if a binding has found and processed
      * @since 1.4
      */
+    @SuppressWarnings("deprecation")
     public static boolean processKeyBindings(KeyEvent event) {
         if (event != null) {
             if (event.isConsumed()) {
@@ -2209,6 +2213,7 @@
      * @see java.awt.Component#isVisible()
      * @since 1.7
      */
+    @SuppressWarnings("deprecation")
     static Container getValidateRoot(Container c, boolean visibleOnly) {
         Container root = null;
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/ToolTipManager.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/ToolTipManager.java	Wed Jul 05 22:30:23 2017 +0200
@@ -753,6 +753,7 @@
   // Returns: 0 no adjust
   //         -1 can't fit
   //         >0 adjust value by amount returned
+ @SuppressWarnings("deprecation")
   private int getPopupFitWidth(Rectangle popupRectInScreen, Component invoker){
     if (invoker != null){
       Container parent;
@@ -778,6 +779,7 @@
 
   // Returns:  0 no adjust
   //          >0 adjust by value return
+  @SuppressWarnings("deprecation")
   private int getPopupFitHeight(Rectangle popupRectInScreen, Component invoker){
     if (invoker != null){
       Container parent;
--- a/jdk/src/java.desktop/share/classes/javax/swing/UIManager.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIManager.java	Wed Jul 05 22:30:23 2017 +0200
@@ -513,6 +513,7 @@
      *
      * @since 9
      */
+    @SuppressWarnings("deprecation")
     public static LookAndFeel createLookAndFeel(String name)
             throws UnsupportedLookAndFeelException {
         Objects.requireNonNull(name);
@@ -526,14 +527,16 @@
                 if (info.getName().equals(name)) {
                     Class<?> cls = Class.forName(UIManager.class.getModule(),
                                                  info.getClassName());
-                    LookAndFeel laf = (LookAndFeel) cls.newInstance();
+                    LookAndFeel laf =
+                        (LookAndFeel) cls.newInstance();
                     if (!laf.isSupportedLookAndFeel()) {
                         break;
                     }
                     return laf;
                 }
             }
-        } catch (InstantiationException | IllegalAccessException ignore) {
+        } catch (ReflectiveOperationException |
+                 IllegalArgumentException ignore) {
         }
 
         throw new UnsupportedLookAndFeelException(name);
@@ -613,6 +616,7 @@
      * @throws ClassCastException if {@code className} does not identify
      *         a class that extends {@code LookAndFeel}
      */
+    @SuppressWarnings("deprecation")
     public static void setLookAndFeel(String className)
         throws ClassNotFoundException,
                InstantiationException,
@@ -625,7 +629,16 @@
         }
         else {
             Class<?> lnfClass = SwingUtilities.loadSystemClass(className);
-            setLookAndFeel((LookAndFeel)(lnfClass.newInstance()));
+            try {
+                LookAndFeel laf =
+                    (LookAndFeel)lnfClass.newInstance();
+                setLookAndFeel(laf);
+            } catch (ReflectiveOperationException | IllegalArgumentException e) {
+                InstantiationException ex =
+                    new InstantiationException("Wrapped Exception");
+                ex.initCause(e);
+                throw ex;
+            }
         }
     }
 
@@ -1086,6 +1099,7 @@
     /**
      * Finds the Multiplexing <code>LookAndFeel</code>.
      */
+    @SuppressWarnings("deprecation")
     private static LookAndFeel getMultiLookAndFeel() {
         LookAndFeel multiLookAndFeel = getLAFState().multiLookAndFeel;
         if (multiLookAndFeel == null) {
@@ -1093,7 +1107,8 @@
             String className = getLAFState().swingProps.getProperty(multiplexingLAFKey, defaultName);
             try {
                 Class<?> lnfClass = SwingUtilities.loadSystemClass(className);
-                multiLookAndFeel = (LookAndFeel)lnfClass.newInstance();
+                multiLookAndFeel =
+                        (LookAndFeel)lnfClass.newInstance();
             } catch (Exception exc) {
                 System.err.println("UIManager: failed loading " + className);
             }
@@ -1408,6 +1423,7 @@
     }
 
 
+    @SuppressWarnings("deprecation")
     private static void initializeAuxiliaryLAFs(Properties swingProps)
     {
         String auxLookAndFeelNames = swingProps.getProperty(auxiliaryLAFsKey);
@@ -1427,7 +1443,8 @@
             String className = p.nextToken();
             try {
                 Class<?> lnfClass = SwingUtilities.loadSystemClass(className);
-                LookAndFeel newLAF = (LookAndFeel)lnfClass.newInstance();
+                LookAndFeel newLAF =
+                        (LookAndFeel)lnfClass.newInstance();
                 newLAF.initialize();
                 auxLookAndFeels.addElement(newLAF);
             }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java	Wed Jul 05 22:30:23 2017 +0200
@@ -403,7 +403,7 @@
      */
     public static void drawString(JComponent c, Graphics2D g, String string,
                                   float x, float y) {
-        SwingUtilities2.drawString(c, g, string, (int) x, (int) y);
+        SwingUtilities2.drawString(c, g, string, x, y, true);
     }
 
     /**
@@ -439,7 +439,7 @@
     public static void drawStringUnderlineCharAt(JComponent c, Graphics2D g,
             String string, int underlinedIndex, float x, float y) {
         SwingUtilities2.drawStringUnderlineCharAt(c, g, string, underlinedIndex,
-                                                  (int) x, (int) y);
+                                                  x, y, true);
     }
 
     /**
@@ -482,6 +482,6 @@
      * @since 9
      */
     public static float getStringWidth(JComponent c, FontMetrics fm, String string) {
-        return SwingUtilities2.stringWidth(c, fm, string);
+        return SwingUtilities2.stringWidth(c, fm, string, true);
     }
 }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java	Wed Jul 05 22:30:23 2017 +0200
@@ -926,6 +926,7 @@
             }
         }
 
+        @SuppressWarnings("deprecation")
         boolean isInPopup(Component src) {
             for (Component c=src; c!=null; c=c.getParent()) {
                 if (c instanceof Applet || c instanceof Window) {
@@ -1143,6 +1144,7 @@
             }
         }
 
+        @SuppressWarnings("deprecation")
         public void stateChanged(ChangeEvent ev) {
             if (!(UIManager.getLookAndFeel() instanceof BasicLookAndFeel)) {
                 uninstall();
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1309,6 +1309,7 @@
      * @see javax.swing.text.View#getToolTipText
      * @since 1.4
      */
+    @SuppressWarnings("deprecation")
     public String getToolTipText(JTextComponent t, Point pt) {
         if (!painted) {
             return null;
@@ -2264,6 +2265,7 @@
          * <li>the press event is located over a selection
          * </ul>
          */
+        @SuppressWarnings("deprecation")
         protected boolean isDragPossible(MouseEvent e) {
             JTextComponent c = (JTextComponent)e.getSource();
             if (c.isEnabled()) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/MultiTextUI.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/MultiTextUI.java	Wed Jul 05 22:30:23 2017 +0200
@@ -85,6 +85,7 @@
      * the UI obtained from the default <code>LookAndFeel</code>
      * @since 1.4
      */
+    @SuppressWarnings("deprecation")
     public String getToolTipText(JTextComponent a, Point b) {
         String returnValue =
             ((TextUI) (uis.elementAt(0))).getToolTipText(a,b);
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java	Wed Jul 05 22:30:23 2017 +0200
@@ -304,6 +304,7 @@
      *
      * @param e the mouse event
      */
+    @SuppressWarnings("deprecation")
     protected void positionCaret(MouseEvent e) {
         Point pt = new Point(e.getX(), e.getY());
         Position.Bias[] biasRet = new Position.Bias[1];
@@ -323,6 +324,7 @@
      *
      * @param e the mouse event
      */
+    @SuppressWarnings("deprecation")
     protected void moveCaret(MouseEvent e) {
         Point pt = new Point(e.getX(), e.getY());
         Position.Bias[] biasRet = new Position.Bias[1];
@@ -615,6 +617,7 @@
      * @param g the graphics context
      * @see #damage
      */
+    @SuppressWarnings("deprecation")
     public void paint(Graphics g) {
         if(isVisible()) {
             try {
@@ -959,6 +962,7 @@
      * @see #isActive
      * @see Caret#setVisible
      */
+    @SuppressWarnings("deprecation")
     public void setVisible(boolean e) {
         // focus lost notification can come in later after the
         // caret has been deinstalled, in which case the component
@@ -1301,6 +1305,7 @@
      * event thread so that calling <code>modelToView</code>
      * is safe.
      */
+    @SuppressWarnings("deprecation")
     void repaintNewCaret() {
         if (component != null) {
             TextUI mapper = component.getUI();
@@ -1664,6 +1669,7 @@
          *
          * @param e the action event
          */
+        @SuppressWarnings("deprecation")
         public void actionPerformed(ActionEvent e) {
             if (width == 0 || height == 0) {
                 // setVisible(true) will cause a scroll, only do this if the
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1429,6 +1429,7 @@
         }
 
         /** The operation to perform when this action is triggered. */
+        @SuppressWarnings("deprecation")
         public void actionPerformed(ActionEvent e) {
             JTextComponent target = getTextComponent(e);
             if (target != null) {
@@ -1542,6 +1543,7 @@
          * Returns adjustsed {@code y} position that indicates the location to scroll to
          * after selecting <code>index</code>.
          */
+        @SuppressWarnings("deprecation")
         private int getAdjustedY(JTextComponent text, Rectangle visible, int index) {
             int result = visible.y;
 
@@ -1589,6 +1591,7 @@
         }
 
         /** The operation to perform when this action is triggered. */
+        @SuppressWarnings("deprecation")
         public void actionPerformed(ActionEvent e) {
             JTextComponent target = getTextComponent(e);
             if (target != null) {
@@ -1672,6 +1675,7 @@
         }
 
         /** The operation to perform when this action is triggered. */
+        @SuppressWarnings("deprecation")
         public void actionPerformed(ActionEvent e) {
             JTextComponent target = getTextComponent(e);
             if (target != null) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultHighlighter.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultHighlighter.java	Wed Jul 05 22:30:23 2017 +0200
@@ -405,6 +405,7 @@
          * @param bounds the bounding box for the highlight
          * @param c the editor
          */
+        @SuppressWarnings("deprecation")
         public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
             Rectangle alloc = bounds.getBounds();
             try {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/FieldView.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/FieldView.java	Wed Jul 05 22:30:23 2017 +0200
@@ -205,6 +205,7 @@
      *           that is returned, although there is no guarantee.
      *           The parent may choose to resize or break the view.
      */
+    @SuppressWarnings("deprecation")
     public float getPreferredSpan(int axis) {
         switch (axis) {
         case View.X_AXIS:
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java	Wed Jul 05 22:30:23 2017 +0200
@@ -785,6 +785,7 @@
      * @param p the point to calculate a drop location for
      * @return the drop location, or <code>null</code>
      */
+    @SuppressWarnings("deprecation")
     DropLocation dropLocationForPoint(Point p) {
         Position.Bias[] bias = new Position.Bias[1];
         int index = getUI().viewToModel(this, p, bias);
@@ -1959,6 +1960,7 @@
      * @see javax.swing.plaf.TextUI#getToolTipText
      * @see javax.swing.ToolTipManager#registerComponent
      */
+    @SuppressWarnings("deprecation")
     public String getToolTipText(MouseEvent event) {
         String retValue = super.getToolTipText(event);
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java	Wed Jul 05 22:30:23 2017 +0200
@@ -178,6 +178,7 @@
      * @return the location in the model that represents the
      *  next location visual position
      */
+    @SuppressWarnings("deprecation")
     protected int getNextNorthSouthVisualPositionFrom(int pos, Position.Bias b,
                                                       Shape a, int direction,
                                                       Position.Bias[] biasRet)
@@ -252,6 +253,7 @@
     // NOTE: This will not properly work if ParagraphView contains
     // other ParagraphViews. It won't raise, but this does not message
     // the children views with getNextVisualPositionFrom.
+    @SuppressWarnings("deprecation")
     protected int getClosestPositionTo(int pos, Position.Bias b, Shape a,
                                        int direction, Position.Bias[] biasRet,
                                        int rowIndex, int x)
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/PasswordView.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PasswordView.java	Wed Jul 05 22:30:23 2017 +0200
@@ -84,6 +84,7 @@
         return drawUnselectedTextImpl(g, x, y, p0, p1, true);
     }
 
+    @SuppressWarnings("deprecation")
     private float drawUnselectedTextImpl(Graphics g, float x, float y,
                                          int p0, int p1,
                                          boolean useFPAPI)
@@ -152,6 +153,7 @@
         return drawSelectedTextImpl(g, x, y, p0, p1, true);
     }
 
+    @SuppressWarnings("deprecation")
     private float drawSelectedTextImpl(Graphics g, float x, float y,
                                        int p0, int p1,
                                        boolean useFPAPI)
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java	Wed Jul 05 22:30:23 2017 +0200
@@ -471,6 +471,7 @@
      *   represent a valid location in the associated document
      * @see View#modelToView
      */
+    @SuppressWarnings("deprecation")
     public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
         // line coordinates
         Document doc = getDocument();
@@ -798,6 +799,7 @@
      * the given element.  It is assumed that the font
      * and font metrics are up-to-date.
      */
+    @SuppressWarnings("deprecation")
     private int getLineWidth(Element line) {
         if (line == null) {
             return 0;
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/Utilities.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/Utilities.java	Wed Jul 05 22:30:23 2017 +0200
@@ -107,7 +107,7 @@
                                              TabExpander e,
                                              int startOffset)
     {
-        return drawTabbedText(s, (int) x, (int) y, (Graphics) g, e, startOffset);
+        return drawTabbedText(null, s, x, y, g, e, startOffset, null, true);
     }
 
     /**
@@ -672,6 +672,7 @@
      *  a value of -1 will be returned.
      * @exception BadLocationException if the offset is out of range
      */
+    @SuppressWarnings("deprecation")
     public static final int getRowStart(JTextComponent c, int offs) throws BadLocationException {
         Rectangle r = c.modelToView(offs);
         if (r == null) {
@@ -702,6 +703,7 @@
      *  a value of -1 will be returned.
      * @exception BadLocationException if the offset is out of range
      */
+    @SuppressWarnings("deprecation")
     public static final int getRowEnd(JTextComponent c, int offs) throws BadLocationException {
         Rectangle2D r = c.modelToView2D(offs);
         if (r == null) {
@@ -744,6 +746,7 @@
         return getPositionAbove(c, offs, x, false);
     }
 
+    @SuppressWarnings("deprecation")
     static final int getPositionAbove(JTextComponent c, int offs, float x,
                                       boolean useFPAPI) throws BadLocationException
     {
@@ -818,6 +821,7 @@
         return getPositionBelow(c, offs, x, false);
     }
 
+    @SuppressWarnings("deprecation")
     static final int getPositionBelow(JTextComponent c, int offs, float x,
                                       boolean useFPAPI) throws BadLocationException
     {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/View.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/View.java	Wed Jul 05 22:30:23 2017 +0200
@@ -501,6 +501,7 @@
      * @exception IllegalArgumentException if <code>direction</code>
      *          doesn't have one of the legal values above
      */
+    @SuppressWarnings("deprecation")
     public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
                                          int direction, Position.Bias[] biasRet)
       throws BadLocationException {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Wed Jul 05 22:30:23 2017 +0200
@@ -352,6 +352,7 @@
      * @param p1 the ending document location to use
      * @return the break position
      */
+    @SuppressWarnings("deprecation")
     protected int calculateBreakPosition(int p0, int p1) {
         int p;
         Segment segment = SegmentCache.getSharedSegment();
@@ -749,6 +750,7 @@
          *   valid location in the associated document
          * @see View#modelToView
          */
+        @SuppressWarnings("deprecation")
         public Shape modelToView(int pos, Shape a, Position.Bias b)
                 throws BadLocationException {
             Rectangle alloc = a.getBounds();
@@ -793,6 +795,7 @@
          *  given point in the view
          * @see View#viewToModel
          */
+        @SuppressWarnings("deprecation")
         public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias) {
             // PENDING(prinz) implement bias properly
             bias[0] = Position.Bias.Forward;
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/AccessibleHTML.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/AccessibleHTML.java	Wed Jul 05 22:30:23 2017 +0200
@@ -936,6 +936,7 @@
              * @return the screen coordinates of the character's the bounding box,
              * if index is invalid returns an empty rectangle.
              */
+            @SuppressWarnings("deprecation")
             public Rectangle getCharacterBounds(int i) {
                 try {
                     return editor.getUI().modelToView(editor, i);
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java	Wed Jul 05 22:30:23 2017 +0200
@@ -683,6 +683,7 @@
          * @param e the mouse event
          * @see MouseListener#mouseClicked
          */
+        @SuppressWarnings("deprecation")
         public void mouseClicked(MouseEvent e) {
             JEditorPane editor = (JEditorPane) e.getSource();
 
@@ -701,6 +702,7 @@
         }
 
         // track the moving of the mouse.
+        @SuppressWarnings("deprecation")
         public void mouseMoved(MouseEvent e) {
             JEditorPane editor = (JEditorPane) e.getSource();
             if (!editor.isEnabled()) {
@@ -773,6 +775,7 @@
          * Returns a string anchor if the passed in element has a
          * USEMAP that contains the passed in location.
          */
+        @SuppressWarnings("deprecation")
         private String getMapHREF(JEditorPane html, HTMLDocument hdoc,
                                   Element elem, AttributeSet attr, int offset,
                                   int x, int y) {
@@ -813,6 +816,7 @@
          * the location <code>x</code>, <code>y</code>. <code>offset</code>
          * gives the offset into the Document to check for.
          */
+        @SuppressWarnings("deprecation")
         private boolean doesElementContainLocation(JEditorPane editor,
                                                    Element e, int offset,
                                                    int x, int y) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/ObjectView.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/ObjectView.java	Wed Jul 05 22:30:23 2017 +0200
@@ -85,6 +85,7 @@
      * as a specification of the classname, which
      * we try to load.
      */
+    @SuppressWarnings("deprecation")
     protected Component createComponent() {
         AttributeSet attr = getElement().getAttributes();
         String classname = (String) attr.getAttribute(HTML.Attribute.CLASSID);
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletAudioClip.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletAudioClip.java	Wed Jul 05 22:30:23 2017 +0200
@@ -41,6 +41,7 @@
  * @author Arthur van Hoff, Kara Kytle
  */
 
+@SuppressWarnings("deprecation")
 public class AppletAudioClip implements AudioClip {
 
     // url that this AudioClip is based on
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java	Wed Jul 05 22:30:23 2017 +0200
@@ -54,7 +54,7 @@
  *
  * @author      Arthur van Hoff
  */
-@SuppressWarnings("serial") // JDK implementation class
+@SuppressWarnings({"serial", "deprecation"}) // JDK implementation class
 public
 abstract class AppletPanel extends Panel implements AppletStub, Runnable {
 
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java	Wed Jul 05 22:30:23 2017 +0200
@@ -117,7 +117,7 @@
  * (The document named appletviewertags.html in the JDK's docs/tooldocs directory,
  *  once the JDK docs have been installed.)
  */
-@SuppressWarnings("serial") // JDK implementation class
+@SuppressWarnings({"serial", "deprecation"}) // JDK-implementation class
 public class AppletViewer extends Frame implements AppletContext, Printable {
 
     /**
@@ -157,7 +157,6 @@
     /**
      * Create the applet viewer.
      */
-    @SuppressWarnings("deprecation")
     public AppletViewer(int x, int y, URL doc, Hashtable<String, String> atts,
                         PrintStream statusMsgStream, AppletViewerFactory factory) {
         this.factory = factory;
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerPanel.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerPanel.java	Wed Jul 05 22:30:23 2017 +0200
@@ -197,6 +197,7 @@
      * Get the applet context. For now this is
      * also implemented by the AppletPanel class.
      */
+    @SuppressWarnings("deprecation")
     public AppletContext getAppletContext() {
         return (AppletContext)getParent();
     }
--- a/jdk/src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java	Wed Jul 05 22:30:23 2017 +0200
@@ -499,6 +499,7 @@
      * @return the parent applet or {@ null}
      * @since 1.6
      */
+    @SuppressWarnings("deprecation")
     public static Applet getAppletIfAncestorOf(Component comp) {
         Container parent = comp.getParent();
         Applet applet = null;
--- a/jdk/src/java.desktop/share/classes/sun/awt/FontConfiguration.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/FontConfiguration.java	Wed Jul 05 22:30:23 2017 +0200
@@ -971,7 +971,7 @@
 
             if (fcc != null) {
                 try {
-                    fc = (Charset) fcc.newInstance();
+                    fc = (Charset) fcc.getDeclaredConstructor().newInstance();
                 } catch (Exception e) {
                 }
             }
--- a/jdk/src/java.desktop/share/classes/sun/awt/LightweightFrame.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/LightweightFrame.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -141,17 +141,52 @@
      *
      * @return the scale factor
      * @see #notifyDisplayChanged(int)
+     * @Depricated replaced by {@link #getScaleFactorX()} and
+     * {@link #getScaleFactorY}
      */
+    @Deprecated(since = "9")
     public abstract int getScaleFactor();
 
     /**
+     * Returns the scale factor of this frame along x coordinate. The default
+     * value is 1.
+     *
+     * @return the x coordinate scale factor
+     * @see #notifyDisplayChanged(double, double)
+     * @since 9
+     */
+    public abstract double getScaleFactorX();
+
+    /**
+     * Returns the scale factor of this frame along y coordinate. The default
+     * value is 1.
+     *
+     * @return the y coordinate scale factor
+     * @see #notifyDisplayChanged(double, double)
+     * @since 9
+     */
+    public abstract double getScaleFactorY();
+
+    /**
      * Called when display of the hosted frame is changed.
      *
      * @param scaleFactor the scale factor
+     * @Depricated replaced by {@link #notifyDisplayChanged(double, double)}
      */
+    @Deprecated(since = "9")
     public abstract void notifyDisplayChanged(int scaleFactor);
 
     /**
+     * Called when display of the hosted frame is changed.
+     *
+     * @param scaleFactorX the scale factor
+     * @param scaleFactorY the scale factor
+     * @since 9
+     */
+    public abstract void notifyDisplayChanged(double scaleFactorX,
+                                              double scaleFactorY);
+
+    /**
      * Host window absolute bounds.
      */
     private int hostX, hostY, hostW, hostH;
@@ -202,4 +237,5 @@
      * Removes a drop target from the lightweight frame.
      */
     public abstract void removeDropTarget(DropTarget dt);
+
 }
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/GifImageDecoder.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/GifImageDecoder.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
  */
 package sun.awt.image;
 
-import java.util.Vector;
 import java.util.Hashtable;
 import java.io.InputStream;
 import java.io.IOException;
@@ -620,7 +619,6 @@
 
 class GifFrame {
     private static final boolean verbose = false;
-    private static IndexColorModel trans_model;
 
     static final int DISPOSAL_NONE      = 0x00;
     static final int DISPOSAL_SAVE      = 0x01;
@@ -718,12 +716,6 @@
             case DISPOSAL_BGCOLOR:
                 byte tpix;
                 if (model.getTransparentPixel() < 0) {
-                    model = trans_model;
-                    if (model == null) {
-                        model = new IndexColorModel(8, 1,
-                                                    new byte[4], 0, true);
-                        trans_model = model;
-                    }
                     tpix = 0;
                 } else {
                     tpix = (byte) model.getTransparentPixel();
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/VolatileSurfaceManager.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/VolatileSurfaceManager.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,6 +55,15 @@
     protected SunVolatileImage vImg;
 
     /**
+     * A reference to the AffineTransform corresponding to the graphics
+     * configuration of the volatile image. Affine Transformation is usually
+     * derived from the screen device. During the displayChanged() callback,
+     * the existing transform is compared with the updated screen transform to
+     * determine whether the software backed surface needs to be re-created
+     */
+    protected AffineTransform atCurrent;
+
+    /**
      * The accelerated SurfaceData object.
      */
     protected SurfaceData sdAccel;
@@ -93,6 +102,7 @@
     protected VolatileSurfaceManager(SunVolatileImage vImg, Object context) {
         this.vImg = vImg;
         this.context = context;
+        this.atCurrent = vImg.getGraphicsConfig().getDefaultTransform();
 
         GraphicsEnvironment ge =
             GraphicsEnvironment.getLocalGraphicsEnvironment();
@@ -210,6 +220,10 @@
             sdCurrent = getBackupSurface();
             sdAccel = null;
             returnCode = VolatileImage.IMAGE_RESTORED;
+        } else if (lostSurfaceTmp) {
+            // A software surface has been restored. This could be due to
+            // display mode change on a non-accelerated volatile image.
+            returnCode = VolatileImage.IMAGE_RESTORED;
         }
 
         if ((returnCode != VolatileImage.IMAGE_INCOMPATIBLE) &&
@@ -326,9 +340,6 @@
      * method in the rendering process to recreate the surface.
      */
     public void displayChanged() {
-        if (!isAccelerationEnabled()) {
-            return;
-        }
         lostSurface = true;
         if (sdAccel != null) {
             // First, nullify the software surface.  This guards against
@@ -345,6 +356,28 @@
         // Update graphicsConfig for the vImg in case it changed due to
         // this display change event
         vImg.updateGraphicsConfig();
+
+        // Compare the Graphics configuration transforms to determine
+        // whether the software backed surface needs to be invalidated.
+        AffineTransform atUpdated = vImg.getGraphicsConfig()
+                                        .getDefaultTransform();
+        if (!isAccelerationEnabled()) {
+            if (!atUpdated.equals(atCurrent)) {
+                // Ideally there is no need to re-create a software surface.
+                // But some OSs allow changes to display state at runtime. Such
+                // a provision would cause mismatch in graphics configuration of
+                // the display and the surface. Hence we re-create the software
+                // surface as well.
+                sdBackup = null;
+                sdCurrent = getBackupSurface();
+            } else {
+                // Software backed surface was not invalidated.
+                lostSurface = false;
+            }
+        }
+
+        // Update the AffineTransformation backing the volatile image
+        atCurrent = atUpdated;
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java	Wed Jul 05 22:30:23 2017 +0200
@@ -226,13 +226,10 @@
         }
         try {
             shellFolderManager =
-                (ShellFolderManager)managerClass.newInstance();
-        } catch (InstantiationException e) {
+                (ShellFolderManager)managerClass.getDeclaredConstructor().newInstance();
+        } catch (ReflectiveOperationException e) {
             throw new Error("Could not instantiate Shell Folder Manager: "
             + managerClass.getName());
-        } catch (IllegalAccessException e) {
-            throw new Error ("Could not access Shell Folder Manager: "
-            + managerClass.getName());
         }
 
         invoker = shellFolderManager.createInvoker();
--- a/jdk/src/java.desktop/share/classes/sun/font/FontManagerFactory.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/FontManagerFactory.java	Wed Jul 05 22:30:23 2017 +0200
@@ -80,10 +80,9 @@
                                                DEFAULT_CLASS);
                     ClassLoader cl = ClassLoader.getSystemClassLoader();
                     Class<?> fmClass = Class.forName(fmClassName, true, cl);
-                    instance = (FontManager) fmClass.newInstance();
-                } catch (ClassNotFoundException |
-                         InstantiationException |
-                         IllegalAccessException ex) {
+                    instance =
+                       (FontManager) fmClass.getDeclaredConstructor().newInstance();
+                } catch (ReflectiveOperationException ex) {
                     throw new InternalError(ex);
 
                 }
--- a/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java	Wed Jul 05 22:30:23 2017 +0200
@@ -362,6 +362,14 @@
         });
     }
 
+    /**
+     * If the module image layout changes the location of JDK fonts,
+     * this will be updated to reflect that.
+     */
+    public static final String getJDKFontDir() {
+        return jreFontDirName;
+    }
+
     public TrueTypeFont getEUDCFont() {
         // Overridden in Windows.
         return null;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/font/lookup/JDKFontLookup.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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.font.lookup;
+
+import sun.font.SunFontManager;
+
+/**
+ * Implementation-class accessed by other JDK modules to
+ * locate the JDK-provided fonts.
+ */
+public final class JDKFontLookup {
+
+    public final static String getJDKFontDir() {
+        return SunFontManager.getJDKFontDir();
+    }
+}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/cmm/CMSManager.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/cmm/CMSManager.java	Wed Jul 05 22:30:23 2017 +0200
@@ -57,7 +57,7 @@
         if (cmmProviderClass != null) {
             try {
                 Class<?> cls = Class.forName(cmmProviderClass);
-                provider = (CMMServiceProvider)cls.newInstance();
+                provider = (CMMServiceProvider)cls.getConstructor().newInstance();
             } catch (ReflectiveOperationException e) {
             }
         }
--- a/jdk/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitiveProxy.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitiveProxy.java	Wed Jul 05 22:30:23 2017 +0200
@@ -81,18 +81,15 @@
                         + relativeClassName;
         try {
             Class<?> clazz = Class.forName(name);
-            GraphicsPrimitive p = (GraphicsPrimitive) clazz.newInstance();
+            GraphicsPrimitive p =
+                (GraphicsPrimitive) clazz.getDeclaredConstructor().newInstance();
             if (!satisfiesSameAs(p)) {
                 throw new RuntimeException("Primitive " + p
                                            + " incompatible with proxy for "
                                            + name);
             }
             return p;
-        } catch (ClassNotFoundException ex) {
-            throw new RuntimeException(ex.toString());
-        } catch (InstantiationException ex) {
-            throw new RuntimeException(ex.toString());
-        } catch (IllegalAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             throw new RuntimeException(ex.toString());
         }
         // A RuntimeException should never happen in a deployed JDK, because
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java	Wed Jul 05 22:30:23 2017 +0200
@@ -127,7 +127,7 @@
         if (reClass != null) {
             try {
                 Class<?> cls = Class.forName(reClass);
-                reImpl = (RenderingEngine) cls.newInstance();
+                reImpl = (RenderingEngine) cls.getConstructor().newInstance();
             } catch (ReflectiveOperationException ignored0) {
             }
         }
@@ -135,7 +135,7 @@
             final String marlinREClass = "sun.java2d.marlin.MarlinRenderingEngine";
             try {
                 Class<?> cls = Class.forName(marlinREClass);
-                reImpl = (RenderingEngine) cls.newInstance();
+                reImpl = (RenderingEngine) cls.getConstructor().newInstance();
             } catch (ReflectiveOperationException ignored1) {
             }
         }
--- a/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,18 +25,7 @@
 
 package sun.swing;
 
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.EventQueue;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.MouseInfo;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Window;
+import java.awt.*;
 import java.awt.dnd.DragGestureEvent;
 import java.awt.dnd.DragGestureListener;
 import java.awt.dnd.DragGestureRecognizer;
@@ -46,6 +35,7 @@
 import java.awt.dnd.peer.DragSourceContextPeer;
 import java.awt.event.ContainerEvent;
 import java.awt.event.ContainerListener;
+import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
 import java.awt.image.DataBufferInt;
 import java.beans.PropertyChangeEvent;
@@ -89,7 +79,8 @@
 
     private BufferedImage bbImage;
 
-    private volatile int scaleFactor = 1;
+    private volatile double scaleFactorX;
+    private volatile double scaleFactorY;
 
     /**
      * {@code copyBufferEnabled}, true by default, defines the following strategy.
@@ -124,6 +115,10 @@
      */
     public JLightweightFrame() {
         super();
+        AffineTransform defaultTransform =
+                           getGraphicsConfiguration().getDefaultTransform();
+        scaleFactorX = defaultTransform.getScaleX();
+        scaleFactorY = defaultTransform.getScaleY();
         copyBufferEnabled = "true".equals(AccessController.
             doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true")));
 
@@ -157,8 +152,9 @@
             }
             Point p = SwingUtilities.convertPoint(c, x, y, jlf);
             Rectangle r = new Rectangle(p.x, p.y, w, h).intersection(
-                    new Rectangle(0, 0, bbImage.getWidth() / scaleFactor,
-                                  bbImage.getHeight() / scaleFactor));
+                    new Rectangle(0, 0,
+                          (int)Math.round(bbImage.getWidth() / scaleFactorX),
+                          (int)Math.round(bbImage.getHeight() / scaleFactorY)));
 
             if (!r.isEmpty()) {
                 notifyImageUpdated(r.x, r.y, r.width, r.height);
@@ -212,7 +208,7 @@
         g.setBackground(getBackground());
         g.setColor(getForeground());
         g.setFont(getFont());
-        g.scale(scaleFactor, scaleFactor);
+        g.scale(scaleFactorX, scaleFactorY);
         return g;
     }
 
@@ -237,28 +233,53 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public int getScaleFactor() {
-        return scaleFactor;
+        return (int)scaleFactorX;
+    }
+
+    @Override
+    public double getScaleFactorX() {
+        return scaleFactorX;
+    }
+
+    @Override
+    public double getScaleFactorY() {
+        return scaleFactorY;
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public void notifyDisplayChanged(final int scaleFactor) {
-        if (scaleFactor != this.scaleFactor) {
+        notifyDisplayChanged(scaleFactor, scaleFactor);
+    }
+
+    @Override
+    public void notifyDisplayChanged(final double scaleFactorX,
+                                                    final double scaleFactorY) {
+        if (Double.compare(scaleFactorX, this.scaleFactorX) != 0 ||
+                         Double.compare(scaleFactorY, this.scaleFactorY) != 0) {
             if (!copyBufferEnabled) content.paintLock();
             try {
                 if (bbImage != null) {
-                    resizeBuffer(getWidth(), getHeight(), scaleFactor);
+                    resizeBuffer(getWidth(), getHeight(), scaleFactorX,
+                                                                  scaleFactorY);
                 }
             } finally {
                 if (!copyBufferEnabled) content.paintUnlock();
             }
-            this.scaleFactor = scaleFactor;
+            this.scaleFactorX = scaleFactorX;
+            this.scaleFactorY = scaleFactorY;
+
+            if(isVisible()) {
+                final Object peer =
+                        AWTAccessor.getComponentAccessor().getPeer(this);
+                if (peer instanceof DisplayChangedListener) {
+                    ((DisplayChangedListener) peer).displayChanged();
+                }
+                repaint();
+            }
         }
-        final Object peer = AWTAccessor.getComponentAccessor().getPeer(this);
-        if (peer instanceof DisplayChangedListener) {
-            ((DisplayChangedListener) peer).displayChanged();
-        }
-        repaint();
     }
 
     @Override
@@ -270,7 +291,8 @@
         }
     }
 
-    private void syncCopyBuffer(boolean reset, int x, int y, int w, int h, int scale) {
+    private void syncCopyBuffer(boolean reset, int x, int y, int w, int h,
+                                                 double scaleX, double scaleY) {
         content.paintLock();
         try {
             int[] srcBuffer = ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData();
@@ -279,14 +301,14 @@
             }
             int linestride = bbImage.getWidth();
 
-            x *= scale;
-            y *= scale;
-            w *= scale;
-            h *= scale;
+            int startX = (int)Math.floor(x * scaleX);
+            int startY = (int)Math.floor(y * scaleY);
+            int width  = (int)Math.ceil((x + w) * scaleX) - startX;
+            int height = (int)Math.ceil((y + h) * scaleY) - startY;
 
-            for (int i=0; i<h; i++) {
-                int from = (y + i) * linestride + x;
-                System.arraycopy(srcBuffer, from, copyBuffer, from, w);
+            for (int i = 0; i < height; i++) {
+                int from = (startY + i) * linestride + startX;
+                System.arraycopy(srcBuffer, from, copyBuffer, from, width);
             }
         } finally {
             content.paintUnlock();
@@ -295,7 +317,8 @@
 
     private void notifyImageUpdated(int x, int y, int width, int height) {
         if (copyBufferEnabled) {
-            syncCopyBuffer(false, x, y, width, height, scaleFactor);
+            syncCopyBuffer(false, x, y, width, height, scaleFactorX,
+                                                                  scaleFactorY);
         }
         content.imageUpdated(x, y, width, height);
     }
@@ -382,8 +405,10 @@
             int newW = width;
             int newH = height;
             if (bbImage != null) {
-                int imgWidth = bbImage.getWidth() / scaleFactor;
-                int imgHeight = bbImage.getHeight() / scaleFactor;
+                int imgWidth = (int)Math.round(bbImage.getWidth() /
+                                                                  scaleFactorX);
+                int imgHeight = (int)Math.round(bbImage.getHeight() /
+                                                                  scaleFactorY);
                 if (width != imgWidth || height != imgHeight) {
                     createBB = true;
                     if (bbImage != null) {
@@ -407,7 +432,7 @@
                 }
             }
             if (createBB) {
-                resizeBuffer(newW, newH, scaleFactor);
+                resizeBuffer(newW, newH, scaleFactorX, scaleFactorY);
                 return;
             }
             content.imageReshaped(0, 0, width, height);
@@ -419,16 +444,19 @@
         }
     }
 
-    private void resizeBuffer(int width, int height, int newScaleFactor) {
-            bbImage = new BufferedImage(width*newScaleFactor,height*newScaleFactor,
+    private void resizeBuffer(int width, int height, double newScaleFactorX,
+                                                     double newScaleFactorY) {
+        bbImage = new BufferedImage((int)Math.round(width * newScaleFactorX),
+                                    (int)Math.round(height * newScaleFactorY),
                                         BufferedImage.TYPE_INT_ARGB_PRE);
         int[] pixels= ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData();
         if (copyBufferEnabled) {
-            syncCopyBuffer(true, 0, 0, width, height, newScaleFactor);
+            syncCopyBuffer(true, 0, 0, width, height, newScaleFactorX,
+                                                               newScaleFactorY);
             pixels = copyBuffer;
         }
         content.imageBufferReset(pixels, 0, 0, width, height,
-                                 width * newScaleFactor, newScaleFactor);
+                          bbImage.getWidth(), newScaleFactorX, newScaleFactorY);
     }
 
     @Override
--- a/jdk/src/java.desktop/share/classes/sun/swing/LightweightContent.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/swing/LightweightContent.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -117,7 +117,10 @@
      * @param height the logical height of the image
      * @param linestride the line stride of the pixel buffer
      * @param scale the scale factor of the pixel buffer
+     * @Depricated replaced by
+     * {@link #imageBufferReset(int[],int,int,int,int,int,double,double)}
      */
+    @Deprecated(since = "9")
     default public void imageBufferReset(int[] data,
                                  int x, int y,
                                  int width, int height,
@@ -128,11 +131,54 @@
     }
 
     /**
+     * {@code JLightweightFrame} calls this method to notify the client
+     * application that a new data buffer has been set as a content pixel
+     * buffer. Typically this occurs when a buffer of a larger size is
+     * created in response to a content resize event.
+     * <p>
+     * The method reports a reference to the pixel data buffer, the content
+     * image bounds within the buffer and the line stride of the buffer.
+     * These values have the following correlation.
+     * The {@code width} and {@code height} matches the layout size of the
+     * content (the component returned from the {@link #getComponent} method).
+     * The {@code x} and {@code y} is the origin of the content, {@code (0, 0)}
+     * in the layout coordinate space of the content, appearing at
+     * {@code data[y * scaleY * linestride + x * scaleX]} in the buffer.
+     * A pixel with indices {@code (i, j)}, where {@code (0 <= i < width)} and
+     * {@code (0 <= j < height)}, in the layout coordinate space of the content
+     * is represented by a {@code scaleX * scaleY} square of pixels in the
+     * physical coordinate space of the buffer. The top-left corner of the
+     * square has the following physical coordinate in the buffer:
+     * {@code data[(y + j) * scaleY * linestride + (x + i) * scaleX]}.
+     *
+     * @param data the content pixel data buffer of INT_ARGB_PRE type
+     * @param x the logical x coordinate of the image
+     * @param y the logical y coordinate of the image
+     * @param width the logical width of the image
+     * @param height the logical height of the image
+     * @param linestride the line stride of the pixel buffer
+     * @param scaleX the x coordinate scale factor of the pixel buffer
+     * @param scaleY the y coordinate scale factor of the pixel buffer
+     * @since 9
+     */
+    @SuppressWarnings("deprecation")
+    default public void imageBufferReset(int[] data,
+                                         int x, int y,
+                                         int width, int height,
+                                         int linestride,
+                                         double scaleX, double scaleY)
+    {
+        imageBufferReset(data, x, y, width, height, linestride,
+                                                       (int)Math.round(scaleX));
+    }
+
+    /**
      * The default implementation for #imageBufferReset uses a hard-coded value
      * of 1 for the scale factor. Both the old and the new methods provide
      * default implementations in order to allow a client application to run
      * with any JDK version without breaking backward compatibility.
      */
+    @SuppressWarnings("deprecation")
     default public void imageBufferReset(int[] data,
                                  int x, int y,
                                  int width, int height,
--- a/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Wed Jul 05 22:30:23 2017 +0200
@@ -318,7 +318,21 @@
      * @param fm FontMetrics used to measure the String width
      * @param string String to get the width of
      */
-    public static int stringWidth(JComponent c, FontMetrics fm, String string){
+    public static int stringWidth(JComponent c, FontMetrics fm, String string) {
+        return (int) stringWidth(c, fm, string, false);
+    }
+
+    /**
+     * Returns the width of the passed in String.
+     * If the passed String is {@code null}, returns zero.
+     *
+     * @param c JComponent that will display the string, may be null
+     * @param fm FontMetrics used to measure the String width
+     * @param string String to get the width of
+     * @param useFPAPI use floating point API
+     */
+    public static float stringWidth(JComponent c, FontMetrics fm, String string,
+            boolean useFPAPI){
         if (string == null || string.equals("")) {
             return 0;
         }
@@ -333,9 +347,9 @@
         if (needsTextLayout) {
             TextLayout layout = createTextLayout(c, string,
                                     fm.getFont(), fm.getFontRenderContext());
-            return (int) layout.getAdvance();
+            return layout.getAdvance();
         } else {
-            return fm.stringWidth(string);
+            return getFontStringWidth(string, fm, useFPAPI);
         }
     }
 
@@ -426,6 +440,21 @@
      */
     public static void drawString(JComponent c, Graphics g, String text,
                                   int x, int y) {
+        drawString(c, g, text, x, y, false);
+    }
+
+    /**
+     * Draws the string at the specified location.
+     *
+     * @param c JComponent that will display the string, may be null
+     * @param g Graphics to draw the text to
+     * @param text String to display
+     * @param x X coordinate to draw the text at
+     * @param y Y coordinate to draw the text at
+     * @param useFPAPI use floating point API
+     */
+    public static void drawString(JComponent c, Graphics g, String text,
+                                  float x, float y, boolean useFPAPI) {
         // c may be null
 
         // All non-editable widgets that draw strings call into this
@@ -509,7 +538,7 @@
                                                     g2.getFontRenderContext());
                     layout.draw(g2, x, y);
                 } else {
-                    g.drawString(text, x, y);
+                    g2.drawString(text, x, y);
                 }
 
                 if (oldAAValue != null) {
@@ -530,7 +559,7 @@
             }
         }
 
-        g.drawString(text, x, y);
+        g.drawString(text, (int) x, (int) y);
     }
 
     /**
@@ -544,17 +573,36 @@
      * @param x X coordinate to draw the text at
      * @param y Y coordinate to draw the text at
      */
+
     public static void drawStringUnderlineCharAt(JComponent c,Graphics g,
-                           String text, int underlinedIndex, int x,int y) {
+                           String text, int underlinedIndex, int x, int y) {
+        drawStringUnderlineCharAt(c, g, text, underlinedIndex, x, y, false);
+    }
+    /**
+     * Draws the string at the specified location underlining the specified
+     * character.
+     *
+     * @param c JComponent that will display the string, may be null
+     * @param g Graphics to draw the text to
+     * @param text String to display
+     * @param underlinedIndex Index of a character in the string to underline
+     * @param x X coordinate to draw the text at
+     * @param y Y coordinate to draw the text at
+     * @param useFPAPI use floating point API
+     */
+    public static void drawStringUnderlineCharAt(JComponent c, Graphics g,
+                                                 String text, int underlinedIndex,
+                                                 float x, float y,
+                                                 boolean useFPAPI) {
         if (text == null || text.length() <= 0) {
             return;
         }
-        SwingUtilities2.drawString(c, g, text, x, y);
+        SwingUtilities2.drawString(c, g, text, x, y, useFPAPI);
         int textLength = text.length();
         if (underlinedIndex >= 0 && underlinedIndex < textLength ) {
-            int underlineRectY = y;
+            float underlineRectY = y;
             int underlineRectHeight = 1;
-            int underlineRectX = 0;
+            float underlineRectX = 0;
             int underlineRectWidth = 0;
             boolean isPrinting = isPrinting(g);
             boolean needsTextLayout = isPrinting;
@@ -594,7 +642,7 @@
                     underlineRectWidth = rect.width;
                 }
             }
-            g.fillRect(underlineRectX, underlineRectY + 1,
+            g.fillRect((int) underlineRectX, (int) underlineRectY + 1,
                        underlineRectWidth, underlineRectHeight);
         }
     }
--- a/jdk/src/java.desktop/share/classes/sun/swing/text/TextComponentPrintable.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/share/classes/sun/swing/text/TextComponentPrintable.java	Wed Jul 05 22:30:23 2017 +0200
@@ -753,6 +753,7 @@
      * First step is to find yStart and yEnd for the every document position.
      * Second step is to merge all intersected segments ( [yStart, yEnd] ).
      */
+    @SuppressWarnings("deprecation")
     private void calculateRowsMetrics() {
         final int documentLength = printShell.getDocument().getLength();
         List<IntegerSegment> documentMetrics = new ArrayList<IntegerSegment>(LIST_SIZE);
--- a/jdk/src/java.desktop/unix/classes/sun/font/XMap.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/unix/classes/sun/font/XMap.java	Wed Jul 05 22:30:23 2017 +0200
@@ -172,7 +172,8 @@
         if (className != null) {
             try {
                 if (className.startsWith("sun.awt")) {
-                    enc = ((Charset)Class.forName(className).newInstance()).newEncoder();
+                    enc = ((Charset)Class.forName(className).getDeclaredConstructor().
+                                                  newInstance()).newEncoder();
                 } else {
                     enc = Charset.forName(className).newEncoder();
                 }
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp	Wed Jul 05 22:30:23 2017 +0200
@@ -128,7 +128,7 @@
                 return;
             }
             hDC = comp->GetDCFromComponent();
-            if (hDC != NULL) {
+            if (hDC != NULL && wsdo->device != NULL) {
                 ::SelectObject(hDC, nullbrush);
                 ::SelectObject(hDC, nullpen);
                 ::SelectClipRgn(hDC, (HRGN) NULL);
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Wed Jul 05 22:30:23 2017 +0200
@@ -3523,7 +3523,7 @@
 
     WORD wChar[2];
     int converted = 1;
-    UINT ch = ::MapVirtualKey(wkey, 2);
+    UINT ch = ::MapVirtualKeyEx(wkey, 2, GetKeyboardLayout());
     if (ch & 0x80000000) {
         // Dead key which is handled as a normal key
         isDeadKey = deadKeyActive = TRUE;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp	Wed Jul 05 22:30:23 2017 +0200
@@ -58,7 +58,11 @@
 JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setProgressValue
   (JNIEnv *, jobject, jlong window, jint value)
 {
-    m_Taskbar->SetProgressValue((HWND)window, value, 100);
+    if (value < 0 || value > 100) {
+        m_Taskbar->SetProgressState((HWND)window, TBPF_NOPROGRESS);
+    } else {
+        m_Taskbar->SetProgressValue((HWND)window, value, 100);
+    }
 }
 
 
@@ -88,6 +92,9 @@
             flag = TBPF_NOPROGRESS;
         } else if (strcmp(valueNative, "NORMAL") == 0) {
             flag = TBPF_NORMAL;
+
+            // Switching from TBPF_INDETERMINATE to TBPF_NORMAL has no effect
+            m_Taskbar->SetProgressState((HWND)window, TBPF_PAUSED);
         } else if (strcmp(valueNative, "PAUSED") == 0) {
             flag = TBPF_PAUSED;
         } else if (strcmp(valueNative, "INDETERMINATE") == 0) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.accessibility/windows/native/bridge/AccessBridgeCalls.c	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,1130 @@
+/*
+ *
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Wrapper functions around calls to the AccessBridge DLL
+ */
+
+
+#include <windows.h>
+#include <jni.h>
+
+
+//#define ACCESSBRIDGE_32
+//#define ACCESSBRIDGE_64
+
+#include "AccessBridgeCalls.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    HINSTANCE theAccessBridgeInstance;
+    AccessBridgeFPs theAccessBridge;
+
+    BOOL theAccessBridgeInitializedFlag = FALSE;
+
+#define LOAD_FP(result, type, name) \
+    if ((theAccessBridge.result = \
+        (type) GetProcAddress(theAccessBridgeInstance, name)) == (type) 0) { \
+        return FALSE; \
+    }
+
+    BOOL initializeAccessBridge() {
+
+#ifdef ACCESSBRIDGE_ARCH_32 // For 32 bit AT interfacing with Java on 64 bit OS
+        theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-32");
+#else
+#ifdef ACCESSBRIDGE_ARCH_64 // For 64 bit AT interfacing with Java on 64 bit OS
+                theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-64");
+#else // For 32 bit AT interfacing with Java on 32 bit OS
+        theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE");
+#endif
+#endif
+        if (theAccessBridgeInstance != 0) {
+            LOAD_FP(Windows_run, Windows_runFP, "Windows_run");
+
+            LOAD_FP(SetJavaShutdown, SetJavaShutdownFP, "setJavaShutdownFP");
+            LOAD_FP(SetFocusGained, SetFocusGainedFP, "setFocusGainedFP");
+            LOAD_FP(SetFocusLost, SetFocusLostFP, "setFocusLostFP");
+
+            LOAD_FP(SetCaretUpdate, SetCaretUpdateFP, "setCaretUpdateFP");
+
+            LOAD_FP(SetMouseClicked, SetMouseClickedFP, "setMouseClickedFP");
+            LOAD_FP(SetMouseEntered, SetMouseEnteredFP, "setMouseEnteredFP");
+            LOAD_FP(SetMouseExited, SetMouseExitedFP, "setMouseExitedFP");
+            LOAD_FP(SetMousePressed, SetMousePressedFP, "setMousePressedFP");
+            LOAD_FP(SetMouseReleased, SetMouseReleasedFP, "setMouseReleasedFP");
+
+            LOAD_FP(SetMenuCanceled, SetMenuCanceledFP, "setMenuCanceledFP");
+            LOAD_FP(SetMenuDeselected, SetMenuDeselectedFP, "setMenuDeselectedFP");
+            LOAD_FP(SetMenuSelected, SetMenuSelectedFP, "setMenuSelectedFP");
+            LOAD_FP(SetPopupMenuCanceled, SetPopupMenuCanceledFP, "setPopupMenuCanceledFP");
+            LOAD_FP(SetPopupMenuWillBecomeInvisible, SetPopupMenuWillBecomeInvisibleFP, "setPopupMenuWillBecomeInvisibleFP");
+            LOAD_FP(SetPopupMenuWillBecomeVisible, SetPopupMenuWillBecomeVisibleFP, "setPopupMenuWillBecomeVisibleFP");
+
+            LOAD_FP(SetPropertyNameChange, SetPropertyNameChangeFP, "setPropertyNameChangeFP");
+            LOAD_FP(SetPropertyDescriptionChange, SetPropertyDescriptionChangeFP, "setPropertyDescriptionChangeFP");
+            LOAD_FP(SetPropertyStateChange, SetPropertyStateChangeFP, "setPropertyStateChangeFP");
+            LOAD_FP(SetPropertyValueChange, SetPropertyValueChangeFP, "setPropertyValueChangeFP");
+            LOAD_FP(SetPropertySelectionChange, SetPropertySelectionChangeFP, "setPropertySelectionChangeFP");
+            LOAD_FP(SetPropertyTextChange, SetPropertyTextChangeFP, "setPropertyTextChangeFP");
+            LOAD_FP(SetPropertyCaretChange, SetPropertyCaretChangeFP, "setPropertyCaretChangeFP");
+            LOAD_FP(SetPropertyVisibleDataChange, SetPropertyVisibleDataChangeFP, "setPropertyVisibleDataChangeFP");
+            LOAD_FP(SetPropertyChildChange, SetPropertyChildChangeFP, "setPropertyChildChangeFP");
+            LOAD_FP(SetPropertyActiveDescendentChange, SetPropertyActiveDescendentChangeFP, "setPropertyActiveDescendentChangeFP");
+
+            LOAD_FP(SetPropertyTableModelChange, SetPropertyTableModelChangeFP, "setPropertyTableModelChangeFP");
+
+            LOAD_FP(ReleaseJavaObject, ReleaseJavaObjectFP, "releaseJavaObject");
+            LOAD_FP(GetVersionInfo, GetVersionInfoFP, "getVersionInfo");
+
+            LOAD_FP(IsJavaWindow, IsJavaWindowFP, "isJavaWindow");
+            LOAD_FP(IsSameObject, IsSameObjectFP, "isSameObject");
+            LOAD_FP(GetAccessibleContextFromHWND, GetAccessibleContextFromHWNDFP, "getAccessibleContextFromHWND");
+            LOAD_FP(getHWNDFromAccessibleContext, getHWNDFromAccessibleContextFP, "getHWNDFromAccessibleContext");
+
+            LOAD_FP(GetAccessibleContextAt, GetAccessibleContextAtFP, "getAccessibleContextAt");
+            LOAD_FP(GetAccessibleContextWithFocus, GetAccessibleContextWithFocusFP, "getAccessibleContextWithFocus");
+            LOAD_FP(GetAccessibleContextInfo, GetAccessibleContextInfoFP, "getAccessibleContextInfo");
+            LOAD_FP(GetAccessibleChildFromContext, GetAccessibleChildFromContextFP, "getAccessibleChildFromContext");
+            LOAD_FP(GetAccessibleParentFromContext, GetAccessibleParentFromContextFP, "getAccessibleParentFromContext");
+
+            /* begin AccessibleTable */
+            LOAD_FP(getAccessibleTableInfo, getAccessibleTableInfoFP, "getAccessibleTableInfo");
+            LOAD_FP(getAccessibleTableCellInfo, getAccessibleTableCellInfoFP, "getAccessibleTableCellInfo");
+
+            LOAD_FP(getAccessibleTableRowHeader, getAccessibleTableRowHeaderFP, "getAccessibleTableRowHeader");
+            LOAD_FP(getAccessibleTableColumnHeader, getAccessibleTableColumnHeaderFP, "getAccessibleTableColumnHeader");
+
+            LOAD_FP(getAccessibleTableRowDescription, getAccessibleTableRowDescriptionFP, "getAccessibleTableRowDescription");
+            LOAD_FP(getAccessibleTableColumnDescription, getAccessibleTableColumnDescriptionFP, "getAccessibleTableColumnDescription");
+
+            LOAD_FP(getAccessibleTableRowSelectionCount, getAccessibleTableRowSelectionCountFP,
+                    "getAccessibleTableRowSelectionCount");
+            LOAD_FP(isAccessibleTableRowSelected, isAccessibleTableRowSelectedFP,
+                    "isAccessibleTableRowSelected");
+            LOAD_FP(getAccessibleTableRowSelections, getAccessibleTableRowSelectionsFP,
+                    "getAccessibleTableRowSelections");
+
+            LOAD_FP(getAccessibleTableColumnSelectionCount, getAccessibleTableColumnSelectionCountFP,
+                    "getAccessibleTableColumnSelectionCount");
+            LOAD_FP(isAccessibleTableColumnSelected, isAccessibleTableColumnSelectedFP,
+                    "isAccessibleTableColumnSelected");
+            LOAD_FP(getAccessibleTableColumnSelections, getAccessibleTableColumnSelectionsFP,
+                    "getAccessibleTableColumnSelections");
+
+            LOAD_FP(getAccessibleTableRow, getAccessibleTableRowFP,
+                    "getAccessibleTableRow");
+            LOAD_FP(getAccessibleTableColumn, getAccessibleTableColumnFP,
+                    "getAccessibleTableColumn");
+            LOAD_FP(getAccessibleTableIndex, getAccessibleTableIndexFP,
+                    "getAccessibleTableIndex");
+
+            /* end AccessibleTable */
+
+            /* AccessibleRelationSet */
+            LOAD_FP(getAccessibleRelationSet, getAccessibleRelationSetFP, "getAccessibleRelationSet");
+
+            /* AccessibleHypertext */
+            LOAD_FP(getAccessibleHypertext, getAccessibleHypertextFP, "getAccessibleHypertext");
+            LOAD_FP(activateAccessibleHyperlink, activateAccessibleHyperlinkFP, "activateAccessibleHyperlink");
+            LOAD_FP(getAccessibleHyperlinkCount, getAccessibleHyperlinkCountFP, "getAccessibleHyperlinkCount");
+            LOAD_FP(getAccessibleHypertextExt, getAccessibleHypertextExtFP, "getAccessibleHypertextExt");
+            LOAD_FP(getAccessibleHypertextLinkIndex, getAccessibleHypertextLinkIndexFP, "getAccessibleHypertextLinkIndex");
+            LOAD_FP(getAccessibleHyperlink, getAccessibleHyperlinkFP, "getAccessibleHyperlink");
+
+            /* Accessible KeyBinding, Icon and Action */
+            LOAD_FP(getAccessibleKeyBindings, getAccessibleKeyBindingsFP, "getAccessibleKeyBindings");
+            LOAD_FP(getAccessibleIcons, getAccessibleIconsFP, "getAccessibleIcons");
+            LOAD_FP(getAccessibleActions, getAccessibleActionsFP, "getAccessibleActions");
+            LOAD_FP(doAccessibleActions, doAccessibleActionsFP, "doAccessibleActions");
+
+            /* AccessibleText */
+            LOAD_FP(GetAccessibleTextInfo, GetAccessibleTextInfoFP, "getAccessibleTextInfo");
+            LOAD_FP(GetAccessibleTextItems, GetAccessibleTextItemsFP, "getAccessibleTextItems");
+            LOAD_FP(GetAccessibleTextSelectionInfo, GetAccessibleTextSelectionInfoFP, "getAccessibleTextSelectionInfo");
+            LOAD_FP(GetAccessibleTextAttributes, GetAccessibleTextAttributesFP, "getAccessibleTextAttributes");
+            LOAD_FP(GetAccessibleTextRect, GetAccessibleTextRectFP, "getAccessibleTextRect");
+            LOAD_FP(GetAccessibleTextLineBounds, GetAccessibleTextLineBoundsFP, "getAccessibleTextLineBounds");
+            LOAD_FP(GetAccessibleTextRange, GetAccessibleTextRangeFP, "getAccessibleTextRange");
+
+            LOAD_FP(GetCurrentAccessibleValueFromContext, GetCurrentAccessibleValueFromContextFP, "getCurrentAccessibleValueFromContext");
+            LOAD_FP(GetMaximumAccessibleValueFromContext, GetMaximumAccessibleValueFromContextFP, "getMaximumAccessibleValueFromContext");
+            LOAD_FP(GetMinimumAccessibleValueFromContext, GetMinimumAccessibleValueFromContextFP, "getMinimumAccessibleValueFromContext");
+
+            LOAD_FP(AddAccessibleSelectionFromContext, AddAccessibleSelectionFromContextFP, "addAccessibleSelectionFromContext");
+            LOAD_FP(ClearAccessibleSelectionFromContext, ClearAccessibleSelectionFromContextFP, "clearAccessibleSelectionFromContext");
+            LOAD_FP(GetAccessibleSelectionFromContext, GetAccessibleSelectionFromContextFP, "getAccessibleSelectionFromContext");
+            LOAD_FP(GetAccessibleSelectionCountFromContext, GetAccessibleSelectionCountFromContextFP, "getAccessibleSelectionCountFromContext");
+            LOAD_FP(IsAccessibleChildSelectedFromContext, IsAccessibleChildSelectedFromContextFP, "isAccessibleChildSelectedFromContext");
+            LOAD_FP(RemoveAccessibleSelectionFromContext, RemoveAccessibleSelectionFromContextFP, "removeAccessibleSelectionFromContext");
+            LOAD_FP(SelectAllAccessibleSelectionFromContext, SelectAllAccessibleSelectionFromContextFP, "selectAllAccessibleSelectionFromContext");
+
+            LOAD_FP(setTextContents, setTextContentsFP, "setTextContents");
+            LOAD_FP(getParentWithRole, getParentWithRoleFP, "getParentWithRole");
+            LOAD_FP(getTopLevelObject, getTopLevelObjectFP, "getTopLevelObject");
+            LOAD_FP(getParentWithRoleElseRoot, getParentWithRoleElseRootFP, "getParentWithRoleElseRoot");
+            LOAD_FP(getObjectDepth, getObjectDepthFP, "getObjectDepth");
+            LOAD_FP(getActiveDescendent, getActiveDescendentFP, "getActiveDescendent");
+
+            // additional methods for Teton
+            LOAD_FP(getVirtualAccessibleName, getVirtualAccessibleNameFP, "getVirtualAccessibleName");
+            LOAD_FP(requestFocus, requestFocusFP, "requestFocus");
+            LOAD_FP(selectTextRange, selectTextRangeFP, "selectTextRange");
+            LOAD_FP(getTextAttributesInRange, getTextAttributesInRangeFP, "getTextAttributesInRange");
+            LOAD_FP(getVisibleChildrenCount, getVisibleChildrenCountFP, "getVisibleChildrenCount");
+            LOAD_FP(getVisibleChildren, getVisibleChildrenFP, "getVisibleChildren");
+            LOAD_FP(setCaretPosition, setCaretPositionFP, "setCaretPosition");
+            LOAD_FP(getCaretLocation, getCaretLocationFP, "getCaretLocation");
+
+            LOAD_FP(getEventsWaiting, getEventsWaitingFP, "getEventsWaiting");
+
+            theAccessBridge.Windows_run();
+
+            theAccessBridgeInitializedFlag = TRUE;
+            return TRUE;
+        } else {
+            return FALSE;
+        }
+    }
+
+
+    BOOL shutdownAccessBridge() {
+        BOOL result;
+        DWORD error;
+        theAccessBridgeInitializedFlag = FALSE;
+        if (theAccessBridgeInstance != (HANDLE) 0) {
+            result = FreeLibrary(theAccessBridgeInstance);
+            if (result != TRUE) {
+                error = GetLastError();
+            }
+            return TRUE;
+        }
+        return FALSE;
+    }
+
+
+    void SetJavaShutdown(AccessBridge_JavaShutdownFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetJavaShutdown(fp);
+        }
+    }
+
+    void SetFocusGained(AccessBridge_FocusGainedFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetFocusGained(fp);
+        }
+    }
+
+    void SetFocusLost(AccessBridge_FocusLostFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetFocusLost(fp);
+        }
+    }
+
+
+    void SetCaretUpdate(AccessBridge_CaretUpdateFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetCaretUpdate(fp);
+        }
+    }
+
+
+    void SetMouseClicked(AccessBridge_MouseClickedFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetMouseClicked(fp);
+        }
+    }
+
+    void SetMouseEntered(AccessBridge_MouseEnteredFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetMouseEntered(fp);
+        }
+    }
+
+    void SetMouseExited(AccessBridge_MouseExitedFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetMouseExited(fp);
+        }
+    }
+
+    void SetMousePressed(AccessBridge_MousePressedFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetMousePressed(fp);
+        }
+    }
+
+    void SetMouseReleased(AccessBridge_MouseReleasedFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetMouseReleased(fp);
+        }
+    }
+
+
+    void SetMenuCanceled(AccessBridge_MenuCanceledFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetMenuCanceled(fp);
+        }
+    }
+
+    void SetMenuDeselected(AccessBridge_MenuDeselectedFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetMenuDeselected(fp);
+        }
+    }
+
+    void SetMenuSelected(AccessBridge_MenuSelectedFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetMenuSelected(fp);
+        }
+    }
+
+    void SetPopupMenuCanceled(AccessBridge_PopupMenuCanceledFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPopupMenuCanceled(fp);
+        }
+    }
+
+    void SetPopupMenuWillBecomeInvisible(AccessBridge_PopupMenuWillBecomeInvisibleFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPopupMenuWillBecomeInvisible(fp);
+        }
+    }
+
+    void SetPopupMenuWillBecomeVisible(AccessBridge_PopupMenuWillBecomeVisibleFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPopupMenuWillBecomeVisible(fp);
+        }
+    }
+
+
+    void SetPropertyNameChange(AccessBridge_PropertyNameChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyNameChange(fp);
+        }
+    }
+
+    void SetPropertyDescriptionChange(AccessBridge_PropertyDescriptionChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyDescriptionChange(fp);
+        }
+    }
+
+    void SetPropertyStateChange(AccessBridge_PropertyStateChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyStateChange(fp);
+        }
+    }
+
+    void SetPropertyValueChange(AccessBridge_PropertyValueChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyValueChange(fp);
+        }
+    }
+
+    void SetPropertySelectionChange(AccessBridge_PropertySelectionChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertySelectionChange(fp);
+        }
+    }
+
+    void SetPropertyTextChange(AccessBridge_PropertyTextChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyTextChange(fp);
+        }
+    }
+
+    void SetPropertyCaretChange(AccessBridge_PropertyCaretChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyCaretChange(fp);
+        }
+    }
+
+    void SetPropertyVisibleDataChange(AccessBridge_PropertyVisibleDataChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyVisibleDataChange(fp);
+        }
+    }
+
+    void SetPropertyChildChange(AccessBridge_PropertyChildChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyChildChange(fp);
+        }
+    }
+
+    void SetPropertyActiveDescendentChange(AccessBridge_PropertyActiveDescendentChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyActiveDescendentChange(fp);
+        }
+    }
+
+    void SetPropertyTableModelChange(AccessBridge_PropertyTableModelChangeFP fp) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SetPropertyTableModelChange(fp);
+        }
+    }
+
+    /**
+     * General routines
+     */
+    void ReleaseJavaObject(long vmID, Java_Object object) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.ReleaseJavaObject(vmID, object);
+        }
+    }
+
+    BOOL GetVersionInfo(long vmID, AccessBridgeVersionInfo *info) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetVersionInfo(vmID, info);
+        }
+        return FALSE;
+    }
+
+
+    /**
+     * Window routines
+     */
+    BOOL IsJavaWindow(HWND window) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+                        BOOL ret ;
+                        ret = theAccessBridge.IsJavaWindow(window);
+            return ret ;
+
+        }
+        return FALSE;
+    }
+
+
+    /**
+     * Returns the virtual machine ID and AccessibleContext for a top-level window
+     */
+    BOOL GetAccessibleContextFromHWND(HWND target, long *vmID, AccessibleContext *ac) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleContextFromHWND(target, vmID, ac);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Returns the HWND from the AccessibleContext of a top-level window.  Returns 0
+     *   on error or if the AccessibleContext does not refer to a top-level window.
+     */
+    HWND getHWNDFromAccessibleContext(long vmID, JOBJECT64 accesibleContext) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getHWNDFromAccessibleContext(vmID, accesibleContext);
+        }
+        return (HWND)0;
+    }
+
+    /**
+     * returns whether two objects are the same
+     */
+    BOOL IsSameObject(long vmID, JOBJECT64 obj1, JOBJECT64 obj2) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.IsSameObject(vmID, obj1, obj2);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Sets editable text contents.  The AccessibleContext must implement AccessibleEditableText and
+     *   be editable.  The maximum text length is MAX_STRING_SIZE - 1.
+     * Returns whether successful
+     */
+    BOOL setTextContents (const long vmID, const AccessibleContext accessibleContext, const wchar_t *text) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.setTextContents(vmID, accessibleContext, text);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Returns the Accessible Context with the specified role that is the
+     * ancestor of a given object. The role is one of the role strings
+     * defined in AccessBridgePackages.h
+     * If there is no ancestor object that has the specified role,
+     * returns (AccessibleContext)0.
+     */
+    AccessibleContext getParentWithRole (const long vmID, const AccessibleContext accessibleContext,
+                                         const wchar_t *role) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getParentWithRole(vmID, accessibleContext, role);
+        }
+        return (AccessibleContext)0;
+    }
+
+    /**
+     * Returns the Accessible Context with the specified role that is the
+     * ancestor of a given object. The role is one of the role strings
+     * defined in AccessBridgePackages.h.  If an object with the specified
+     * role does not exist, returns the top level object for the Java Window.
+     * Returns (AccessibleContext)0 on error.
+     */
+    AccessibleContext getParentWithRoleElseRoot (const long vmID, const AccessibleContext accessibleContext,
+                                                 const wchar_t *role) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getParentWithRoleElseRoot(vmID, accessibleContext, role);
+        }
+        return (AccessibleContext)0;
+    }
+
+    /**
+     * Returns the Accessible Context for the top level object in
+     * a Java Window.  This is same Accessible Context that is obtained
+     * from GetAccessibleContextFromHWND for that window.  Returns
+     * (AccessibleContext)0 on error.
+     */
+    AccessibleContext getTopLevelObject (const long vmID, const AccessibleContext accessibleContext) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getTopLevelObject(vmID, accessibleContext);
+        }
+        return (AccessibleContext)0;
+    }
+
+    /**
+     * Returns how deep in the object hierarchy a given object is.
+     * The top most object in the object hierarchy has an object depth of 0.
+     * Returns -1 on error.
+     */
+    int getObjectDepth (const long vmID, const AccessibleContext accessibleContext) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getObjectDepth(vmID, accessibleContext);
+        }
+        return -1;
+    }
+
+    /**
+     * Returns the Accessible Context of the current ActiveDescendent of an object.
+     * This method assumes the ActiveDescendent is the component that is currently
+     * selected in a container object.
+     * Returns (AccessibleContext)0 on error or if there is no selection.
+     */
+    AccessibleContext getActiveDescendent (const long vmID, const AccessibleContext accessibleContext) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getActiveDescendent(vmID, accessibleContext);
+        }
+        return (AccessibleContext)0;
+    }
+
+
+    /**
+     * Accessible Context routines
+     */
+    BOOL GetAccessibleContextAt(long vmID, AccessibleContext acParent,
+                                jint x, jint y, AccessibleContext *ac) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleContextAt(vmID, acParent, x, y, ac);
+        }
+        return FALSE;
+    }
+
+    BOOL GetAccessibleContextWithFocus(HWND window, long *vmID, AccessibleContext *ac) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleContextWithFocus(window, vmID, ac);
+        }
+        return FALSE;
+    }
+
+    BOOL GetAccessibleContextInfo(long vmID, AccessibleContext ac, AccessibleContextInfo *info) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleContextInfo(vmID, ac, info);
+        }
+        return FALSE;
+    }
+
+    AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleChildFromContext(vmID, ac, index);
+        }
+        return (AccessibleContext) 0;
+    }
+
+    AccessibleContext GetAccessibleParentFromContext(long vmID, AccessibleContext ac) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleParentFromContext(vmID, ac);
+        }
+        return (AccessibleContext) 0;
+    }
+
+    /* begin AccessibleTable routines */
+
+    /*
+     * get information about an AccessibleTable
+     */
+    BOOL getAccessibleTableInfo(long vmID, AccessibleContext acParent, AccessibleTableInfo *tableInfo) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableInfo(vmID, acParent, tableInfo);
+        }
+        return FALSE;
+    }
+
+    /*
+     * get information about an AccessibleTable cell
+     */
+    BOOL getAccessibleTableCellInfo(long vmID, AccessibleTable accessibleTable,
+                                    jint row, jint column, AccessibleTableCellInfo *tableCellInfo) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableCellInfo(vmID, accessibleTable, row, column, tableCellInfo);
+        }
+        return FALSE;
+    }
+
+    /*
+     * get information about an AccessibleTable row header
+     */
+    BOOL getAccessibleTableRowHeader(long vmID, AccessibleContext acParent, AccessibleTableInfo *tableInfo) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableRowHeader(vmID, acParent, tableInfo);
+        }
+        return FALSE;
+    }
+
+    /*
+     * get information about an AccessibleTable column header
+     */
+    BOOL getAccessibleTableColumnHeader(long vmID, AccessibleContext acParent, AccessibleTableInfo *tableInfo) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableColumnHeader(vmID, acParent, tableInfo);
+        }
+        return FALSE;
+    }
+
+    /*
+     * return a description of an AccessibleTable row header
+     */
+    AccessibleContext getAccessibleTableRowDescription(long vmID, AccessibleContext acParent, jint row) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableRowDescription(vmID, acParent, row);
+        }
+        return (AccessibleContext)0;
+    }
+
+    /*
+     * return a description of an AccessibleTable column header
+     */
+    AccessibleContext getAccessibleTableColumnDescription(long vmID, AccessibleContext acParent, jint column) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableColumnDescription(vmID, acParent, column);
+        }
+        return (AccessibleContext)0;
+    }
+
+    /*
+     * return the number of rows selected in an AccessibleTable
+     */
+    jint getAccessibleTableRowSelectionCount(long vmID, AccessibleTable table) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableRowSelectionCount(vmID, table);
+        }
+        return -1;
+    }
+
+    /*
+     * return whether a row is selected in an AccessibleTable
+     */
+    BOOL isAccessibleTableRowSelected(long vmID, AccessibleTable table, jint row) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.isAccessibleTableRowSelected(vmID, table, row);
+        }
+        return FALSE;
+    }
+
+    /*
+     * get an array of selected rows in an AccessibleTable
+     */
+    BOOL getAccessibleTableRowSelections(long vmID, AccessibleTable table, jint count, jint *selections) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableRowSelections(vmID, table, count, selections);
+        }
+        return FALSE;
+    }
+
+    /*
+     * return the number of columns selected in an AccessibleTable
+     */
+    jint getAccessibleTableColumnSelectionCount(long vmID, AccessibleTable table) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableColumnSelectionCount(vmID, table);
+        }
+        return -1;
+    }
+
+    /*
+     * return whether a column is selected in an AccessibleTable
+     */
+    BOOL isAccessibleTableColumnSelected(long vmID, AccessibleTable table, jint column) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.isAccessibleTableColumnSelected(vmID, table, column);
+        }
+        return FALSE;
+    }
+
+    /*
+     * get an array of columns selected in an AccessibleTable
+     */
+    BOOL getAccessibleTableColumnSelections(long vmID, AccessibleTable table, jint count, jint *selections) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableColumnSelections(vmID, table, count, selections);
+        }
+        return FALSE;
+    }
+
+    /*
+     * return the row number for a cell at a given index
+     */
+    jint
+    getAccessibleTableRow(long vmID, AccessibleTable table, jint index) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableRow(vmID, table, index);
+        }
+        return -1;
+    }
+
+    /*
+     * return the column number for a cell at a given index
+     */
+    jint
+    getAccessibleTableColumn(long vmID, AccessibleTable table, jint index) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableColumn(vmID, table, index);
+        }
+        return -1;
+    }
+
+    /*
+     * return the index of a cell at a given row and column
+     */
+    jint
+    getAccessibleTableIndex(long vmID, AccessibleTable table, jint row, jint column) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleTableIndex(vmID, table, row, column);
+        }
+        return -1;
+    }
+
+    /* end AccessibleTable routines */
+
+
+    /**
+     * Accessible Text routines
+     */
+    BOOL GetAccessibleTextInfo(long vmID, AccessibleText at, AccessibleTextInfo *textInfo, jint x, jint y) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleTextInfo(vmID, at, textInfo, x, y);
+        }
+        return FALSE;
+    }
+
+    BOOL GetAccessibleTextItems(long vmID, AccessibleText at, AccessibleTextItemsInfo *textItems, jint index) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleTextItems(vmID, at, textItems, index);
+        }
+        return FALSE;
+    }
+
+    BOOL GetAccessibleTextSelectionInfo(long vmID, AccessibleText at, AccessibleTextSelectionInfo *textSelection) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleTextSelectionInfo(vmID, at, textSelection);
+        }
+        return FALSE;
+    }
+
+    BOOL GetAccessibleTextAttributes(long vmID, AccessibleText at, jint index, AccessibleTextAttributesInfo *attributes) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleTextAttributes(vmID, at, index, attributes);
+        }
+        return FALSE;
+    }
+
+    BOOL GetAccessibleTextRect(long vmID, AccessibleText at, AccessibleTextRectInfo *rectInfo, jint index) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleTextRect(vmID, at, rectInfo, index);
+        }
+        return FALSE;
+    }
+
+    BOOL GetAccessibleTextLineBounds(long vmID, AccessibleText at, jint index, jint *startIndex, jint *endIndex) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleTextLineBounds(vmID, at, index, startIndex, endIndex);
+        }
+        return FALSE;
+    }
+
+    BOOL GetAccessibleTextRange(long vmID, AccessibleText at, jint start, jint end, wchar_t *text, short len) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleTextRange(vmID, at, start, end, text, len);
+        }
+        return FALSE;
+    }
+
+    /**
+     * AccessibleRelationSet routines
+     */
+    BOOL getAccessibleRelationSet(long vmID, AccessibleContext accessibleContext,
+                                  AccessibleRelationSetInfo *relationSetInfo) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleRelationSet(vmID, accessibleContext, relationSetInfo);
+        }
+        return FALSE;
+    }
+
+    /**
+     * AccessibleHypertext routines
+     */
+
+    // Gets AccessibleHypertext for an AccessibleContext
+    BOOL getAccessibleHypertext(long vmID, AccessibleContext accessibleContext,
+                                AccessibleHypertextInfo *hypertextInfo) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleHypertext(vmID, accessibleContext, hypertextInfo);
+        }
+        return FALSE;
+    }
+
+    // Activates an AccessibleHyperlink for an AccessibleContext
+    BOOL activateAccessibleHyperlink(long vmID, AccessibleContext accessibleContext,
+                                     AccessibleHyperlink accessibleHyperlink) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.activateAccessibleHyperlink(vmID, accessibleContext, accessibleHyperlink);
+        }
+        return FALSE;
+    }
+
+    /*
+     * Returns the number of hyperlinks in a component
+     * Maps to AccessibleHypertext.getLinkCount.
+     * Returns -1 on error.
+     */
+    jint getAccessibleHyperlinkCount(const long vmID,
+                                     const AccessibleContext accessibleContext) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleHyperlinkCount(vmID, accessibleContext);
+        }
+        return -1;
+    }
+
+    /*
+     * This method is used to iterate through the hyperlinks in a component.  It
+     * returns hypertext information for a component starting at hyperlink index
+     * nStartIndex.  No more than MAX_HYPERLINKS AccessibleHypertextInfo objects will
+     * be returned for each call to this method.
+     * returns FALSE on error.
+     */
+    BOOL getAccessibleHypertextExt(const long vmID,
+                                   const AccessibleContext accessibleContext,
+                                   const jint nStartIndex,
+                                   /* OUT */ AccessibleHypertextInfo *hypertextInfo) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleHypertextExt(vmID,
+                                                             accessibleContext,
+                                                             nStartIndex,
+                                                             hypertextInfo);
+        }
+        return FALSE;
+    }
+
+    /*
+     * Returns the index into an array of hyperlinks that is associated with
+     * a character index in document;
+     * Maps to AccessibleHypertext.getLinkIndex.
+     * Returns -1 on error.
+     */
+    jint getAccessibleHypertextLinkIndex(const long vmID,
+                                         const AccessibleHypertext hypertext,
+                                         const jint nIndex) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleHypertextLinkIndex(vmID,
+                                                                   hypertext,
+                                                                   nIndex);
+        }
+        return -1;
+    }
+
+    /*
+     * Returns the nth hyperlink in a document.
+     * Maps to AccessibleHypertext.getLink.
+     * Returns -1 on error
+     */
+    BOOL getAccessibleHyperlink(const long vmID,
+                                const AccessibleHypertext hypertext,
+                                const jint nIndex,
+                                /* OUT */ AccessibleHyperlinkInfo *hyperlinkInfo) {
+
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleHyperlink(vmID,
+                                                          hypertext,
+                                                          nIndex,
+                                                          hyperlinkInfo);
+        }
+        return FALSE;
+    }
+
+
+    /* Accessible KeyBindings, Icons and Actions */
+    BOOL getAccessibleKeyBindings(long vmID, AccessibleContext accessibleContext,
+                                  AccessibleKeyBindings *keyBindings) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleKeyBindings(vmID, accessibleContext, keyBindings);
+        }
+        return FALSE;
+    }
+
+    BOOL getAccessibleIcons(long vmID, AccessibleContext accessibleContext,
+                            AccessibleIcons *icons) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleIcons(vmID, accessibleContext, icons);
+        }
+        return FALSE;
+    }
+
+    BOOL getAccessibleActions(long vmID, AccessibleContext accessibleContext,
+                              AccessibleActions *actions) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getAccessibleActions(vmID, accessibleContext, actions);
+        }
+        return FALSE;
+    }
+
+    BOOL doAccessibleActions(long vmID, AccessibleContext accessibleContext,
+                             AccessibleActionsToDo *actionsToDo, jint *failure) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.doAccessibleActions(vmID, accessibleContext, actionsToDo, failure);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Accessible Value routines
+     */
+    BOOL GetCurrentAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetCurrentAccessibleValueFromContext(vmID, av, value, len);
+        }
+        return FALSE;
+    }
+
+    BOOL GetMaximumAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetMaximumAccessibleValueFromContext(vmID, av, value, len);
+        }
+        return FALSE;
+    }
+
+    BOOL GetMinimumAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetMinimumAccessibleValueFromContext(vmID, av, value, len);
+        }
+        return FALSE;
+    }
+
+
+    /**
+     * Accessible Selection routines
+     */
+    void addAccessibleSelectionFromContext(long vmID, AccessibleSelection as, int i) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.AddAccessibleSelectionFromContext(vmID, as, i);
+        }
+    }
+
+    void clearAccessibleSelectionFromContext(long vmID, AccessibleSelection as) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.ClearAccessibleSelectionFromContext(vmID, as);
+        }
+    }
+
+    JOBJECT64 GetAccessibleSelectionFromContext(long vmID, AccessibleSelection as, int i) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleSelectionFromContext(vmID, as, i);
+        }
+        return (JOBJECT64) 0;
+    }
+
+    int GetAccessibleSelectionCountFromContext(long vmID, AccessibleSelection as) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.GetAccessibleSelectionCountFromContext(vmID, as);
+        }
+        return -1;
+    }
+
+    BOOL IsAccessibleChildSelectedFromContext(long vmID, AccessibleSelection as, int i) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.IsAccessibleChildSelectedFromContext(vmID, as, i);
+        }
+        return FALSE;
+    }
+
+    void RemoveAccessibleSelectionFromContext(long vmID, AccessibleSelection as, int i) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.RemoveAccessibleSelectionFromContext(vmID, as, i);
+        }
+    }
+
+    void SelectAllAccessibleSelectionFromContext(long vmID, AccessibleSelection as) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            theAccessBridge.SelectAllAccessibleSelectionFromContext(vmID, as);
+        }
+    }
+
+    /**
+     * Additional methods for Teton
+     */
+
+    /**
+     * Gets the AccessibleName for a component based upon the JAWS algorithm. Returns
+     * whether successful.
+     *
+     * Bug ID 4916682 - Implement JAWS AccessibleName policy
+     */
+    BOOL getVirtualAccessibleName(const long vmID, const AccessibleContext accessibleContext,
+                                  wchar_t *name, int len) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getVirtualAccessibleName(vmID, accessibleContext, name, len);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Request focus for a component. Returns whether successful;
+     *
+     * Bug ID 4944757 - requestFocus method needed
+     */
+    BOOL requestFocus(const long vmID, const AccessibleContext accessibleContext) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.requestFocus(vmID, accessibleContext);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Selects text between two indices.  Selection includes the text at the start index
+     * and the text at the end index. Returns whether successful;
+     *
+     * Bug ID 4944758 - selectTextRange method needed
+     */
+    BOOL selectTextRange(const long vmID, const AccessibleContext accessibleContext,
+                         const int startIndex, const int endIndex) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.selectTextRange(vmID, accessibleContext, startIndex, endIndex);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Get text attributes between two indices.  The attribute list includes the text at the
+     * start index and the text at the end index. Returns whether successful;
+     *
+     * Bug ID 4944761 - getTextAttributes between two indices method needed
+     */
+    BOOL getTextAttributesInRange(const long vmID, const AccessibleContext accessibleContext,
+                                  const int startIndex, const int endIndex,
+                                  AccessibleTextAttributesInfo *attributes, short *len) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getTextAttributesInRange(vmID, accessibleContext, startIndex,
+                                                            endIndex, attributes, len);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Returns the number of visible children of a component. Returns -1 on error.
+     *
+     * Bug ID 4944762- getVisibleChildren for list-like components needed
+     */
+    int getVisibleChildrenCount(const long vmID, const AccessibleContext accessibleContext) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getVisibleChildrenCount(vmID, accessibleContext);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Gets the visible children of an AccessibleContext. Returns whether successful;
+     *
+     * Bug ID 4944762- getVisibleChildren for list-like components needed
+     */
+    BOOL getVisibleChildren(const long vmID, const AccessibleContext accessibleContext,
+                            const int startIndex, VisibleChildrenInfo *visibleChildrenInfo) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getVisibleChildren(vmID, accessibleContext, startIndex,
+                                                      visibleChildrenInfo);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Set the caret to a text position. Returns whether successful;
+     *
+     * Bug ID 4944770 - setCaretPosition method needed
+     */
+    BOOL setCaretPosition(const long vmID, const AccessibleContext accessibleContext,
+                          const int position) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.setCaretPosition(vmID, accessibleContext, position);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Gets the text caret location
+     */
+    BOOL getCaretLocation(long vmID, AccessibleContext ac, AccessibleTextRectInfo *rectInfo, jint index) {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getCaretLocation(vmID, ac, rectInfo, index);
+        }
+        return FALSE;
+    }
+
+    /**
+     * Gets the number of events waiting to fire
+     */
+    int getEventsWaiting() {
+        if (theAccessBridgeInitializedFlag == TRUE) {
+            return theAccessBridge.getEventsWaiting();
+        }
+        return FALSE;
+    }
+
+#ifdef __cplusplus
+}
+#endif
--- a/jdk/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCallbacks.h	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCallbacks.h	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,6 @@
  */
 
 /*
- * AccessBridgeCallbacks.h      1.17 05/03/21
- */
-
-/*
  * Header file defining callback typedefs for Windows routines
  * which are called from Java (responding to events, etc.).
  */
--- a/jdk/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCalls.c	Fri Nov 25 11:16:51 2016 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1131 +0,0 @@
-/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * @(#)AccessBridgeCalls.c      1.25 05/08/22
- */
-
-/*
- * Wrapper functions around calls to the AccessBridge DLL
- */
-
-
-#include <windows.h>
-#include <jni.h>
-
-
-//#define ACCESSBRIDGE_32
-//#define ACCESSBRIDGE_64
-
-#include "AccessBridgeCalls.h"
-#include "AccessBridgeDebug.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-    HINSTANCE theAccessBridgeInstance;
-    AccessBridgeFPs theAccessBridge;
-
-    BOOL theAccessBridgeInitializedFlag = FALSE;
-
-#define LOAD_FP(result, type, name) \
-    PrintDebugString("LOAD_FP loading: %s ...", name); \
-    if ((theAccessBridge.result = \
-        (type) GetProcAddress(theAccessBridgeInstance, name)) == (type) 0) { \
-        PrintDebugString("LOAD_FP failed: %s", name); \
-        return FALSE; \
-    }
-
-    BOOL initializeAccessBridge() {
-
-#ifdef ACCESSBRIDGE_ARCH_32 // For 32bit AT new bridge
-        theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-32");
-#else
-#ifdef ACCESSBRIDGE_ARCH_64 // For 64bit AT new bridge
-                theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE-64");
-#else // legacy
-        theAccessBridgeInstance = LoadLibrary("WINDOWSACCESSBRIDGE");
-#endif
-#endif
-        if (theAccessBridgeInstance != 0) {
-            LOAD_FP(Windows_run, Windows_runFP, "Windows_run");
-
-            LOAD_FP(SetJavaShutdown, SetJavaShutdownFP, "setJavaShutdownFP");
-            LOAD_FP(SetFocusGained, SetFocusGainedFP, "setFocusGainedFP");
-            LOAD_FP(SetFocusLost, SetFocusLostFP, "setFocusLostFP");
-
-            LOAD_FP(SetCaretUpdate, SetCaretUpdateFP, "setCaretUpdateFP");
-
-            LOAD_FP(SetMouseClicked, SetMouseClickedFP, "setMouseClickedFP");
-            LOAD_FP(SetMouseEntered, SetMouseEnteredFP, "setMouseEnteredFP");
-            LOAD_FP(SetMouseExited, SetMouseExitedFP, "setMouseExitedFP");
-            LOAD_FP(SetMousePressed, SetMousePressedFP, "setMousePressedFP");
-            LOAD_FP(SetMouseReleased, SetMouseReleasedFP, "setMouseReleasedFP");
-
-            LOAD_FP(SetMenuCanceled, SetMenuCanceledFP, "setMenuCanceledFP");
-            LOAD_FP(SetMenuDeselected, SetMenuDeselectedFP, "setMenuDeselectedFP");
-            LOAD_FP(SetMenuSelected, SetMenuSelectedFP, "setMenuSelectedFP");
-            LOAD_FP(SetPopupMenuCanceled, SetPopupMenuCanceledFP, "setPopupMenuCanceledFP");
-            LOAD_FP(SetPopupMenuWillBecomeInvisible, SetPopupMenuWillBecomeInvisibleFP, "setPopupMenuWillBecomeInvisibleFP");
-            LOAD_FP(SetPopupMenuWillBecomeVisible, SetPopupMenuWillBecomeVisibleFP, "setPopupMenuWillBecomeVisibleFP");
-
-            LOAD_FP(SetPropertyNameChange, SetPropertyNameChangeFP, "setPropertyNameChangeFP");
-            LOAD_FP(SetPropertyDescriptionChange, SetPropertyDescriptionChangeFP, "setPropertyDescriptionChangeFP");
-            LOAD_FP(SetPropertyStateChange, SetPropertyStateChangeFP, "setPropertyStateChangeFP");
-            LOAD_FP(SetPropertyValueChange, SetPropertyValueChangeFP, "setPropertyValueChangeFP");
-            LOAD_FP(SetPropertySelectionChange, SetPropertySelectionChangeFP, "setPropertySelectionChangeFP");
-            LOAD_FP(SetPropertyTextChange, SetPropertyTextChangeFP, "setPropertyTextChangeFP");
-            LOAD_FP(SetPropertyCaretChange, SetPropertyCaretChangeFP, "setPropertyCaretChangeFP");
-            LOAD_FP(SetPropertyVisibleDataChange, SetPropertyVisibleDataChangeFP, "setPropertyVisibleDataChangeFP");
-            LOAD_FP(SetPropertyChildChange, SetPropertyChildChangeFP, "setPropertyChildChangeFP");
-            LOAD_FP(SetPropertyActiveDescendentChange, SetPropertyActiveDescendentChangeFP, "setPropertyActiveDescendentChangeFP");
-
-            LOAD_FP(SetPropertyTableModelChange, SetPropertyTableModelChangeFP, "setPropertyTableModelChangeFP");
-
-            LOAD_FP(ReleaseJavaObject, ReleaseJavaObjectFP, "releaseJavaObject");
-            LOAD_FP(GetVersionInfo, GetVersionInfoFP, "getVersionInfo");
-
-            LOAD_FP(IsJavaWindow, IsJavaWindowFP, "isJavaWindow");
-            LOAD_FP(IsSameObject, IsSameObjectFP, "isSameObject");
-            LOAD_FP(GetAccessibleContextFromHWND, GetAccessibleContextFromHWNDFP, "getAccessibleContextFromHWND");
-            LOAD_FP(getHWNDFromAccessibleContext, getHWNDFromAccessibleContextFP, "getHWNDFromAccessibleContext");
-
-            LOAD_FP(GetAccessibleContextAt, GetAccessibleContextAtFP, "getAccessibleContextAt");
-            LOAD_FP(GetAccessibleContextWithFocus, GetAccessibleContextWithFocusFP, "getAccessibleContextWithFocus");
-            LOAD_FP(GetAccessibleContextInfo, GetAccessibleContextInfoFP, "getAccessibleContextInfo");
-            LOAD_FP(GetAccessibleChildFromContext, GetAccessibleChildFromContextFP, "getAccessibleChildFromContext");
-            LOAD_FP(GetAccessibleParentFromContext, GetAccessibleParentFromContextFP, "getAccessibleParentFromContext");
-
-            /* begin AccessibleTable */
-            LOAD_FP(getAccessibleTableInfo, getAccessibleTableInfoFP, "getAccessibleTableInfo");
-            LOAD_FP(getAccessibleTableCellInfo, getAccessibleTableCellInfoFP, "getAccessibleTableCellInfo");
-
-            LOAD_FP(getAccessibleTableRowHeader, getAccessibleTableRowHeaderFP, "getAccessibleTableRowHeader");
-            LOAD_FP(getAccessibleTableColumnHeader, getAccessibleTableColumnHeaderFP, "getAccessibleTableColumnHeader");
-
-            LOAD_FP(getAccessibleTableRowDescription, getAccessibleTableRowDescriptionFP, "getAccessibleTableRowDescription");
-            LOAD_FP(getAccessibleTableColumnDescription, getAccessibleTableColumnDescriptionFP, "getAccessibleTableColumnDescription");
-
-            LOAD_FP(getAccessibleTableRowSelectionCount, getAccessibleTableRowSelectionCountFP,
-                    "getAccessibleTableRowSelectionCount");
-            LOAD_FP(isAccessibleTableRowSelected, isAccessibleTableRowSelectedFP,
-                    "isAccessibleTableRowSelected");
-            LOAD_FP(getAccessibleTableRowSelections, getAccessibleTableRowSelectionsFP,
-                    "getAccessibleTableRowSelections");
-
-            LOAD_FP(getAccessibleTableColumnSelectionCount, getAccessibleTableColumnSelectionCountFP,
-                    "getAccessibleTableColumnSelectionCount");
-            LOAD_FP(isAccessibleTableColumnSelected, isAccessibleTableColumnSelectedFP,
-                    "isAccessibleTableColumnSelected");
-            LOAD_FP(getAccessibleTableColumnSelections, getAccessibleTableColumnSelectionsFP,
-                    "getAccessibleTableColumnSelections");
-
-            LOAD_FP(getAccessibleTableRow, getAccessibleTableRowFP,
-                    "getAccessibleTableRow");
-            LOAD_FP(getAccessibleTableColumn, getAccessibleTableColumnFP,
-                    "getAccessibleTableColumn");
-            LOAD_FP(getAccessibleTableIndex, getAccessibleTableIndexFP,
-                    "getAccessibleTableIndex");
-
-            /* end AccessibleTable */
-
-            /* AccessibleRelationSet */
-            LOAD_FP(getAccessibleRelationSet, getAccessibleRelationSetFP, "getAccessibleRelationSet");
-
-            /* AccessibleHypertext */
-            LOAD_FP(getAccessibleHypertext, getAccessibleHypertextFP, "getAccessibleHypertext");
-            LOAD_FP(activateAccessibleHyperlink, activateAccessibleHyperlinkFP, "activateAccessibleHyperlink");
-            LOAD_FP(getAccessibleHyperlinkCount, getAccessibleHyperlinkCountFP, "getAccessibleHyperlinkCount");
-            LOAD_FP(getAccessibleHypertextExt, getAccessibleHypertextExtFP, "getAccessibleHypertextExt");
-            LOAD_FP(getAccessibleHypertextLinkIndex, getAccessibleHypertextLinkIndexFP, "getAccessibleHypertextLinkIndex");
-            LOAD_FP(getAccessibleHyperlink, getAccessibleHyperlinkFP, "getAccessibleHyperlink");
-
-            /* Accessible KeyBinding, Icon and Action */
-            LOAD_FP(getAccessibleKeyBindings, getAccessibleKeyBindingsFP, "getAccessibleKeyBindings");
-            LOAD_FP(getAccessibleIcons, getAccessibleIconsFP, "getAccessibleIcons");
-            LOAD_FP(getAccessibleActions, getAccessibleActionsFP, "getAccessibleActions");
-            LOAD_FP(doAccessibleActions, doAccessibleActionsFP, "doAccessibleActions");
-
-            /* AccessibleText */
-            LOAD_FP(GetAccessibleTextInfo, GetAccessibleTextInfoFP, "getAccessibleTextInfo");
-            LOAD_FP(GetAccessibleTextItems, GetAccessibleTextItemsFP, "getAccessibleTextItems");
-            LOAD_FP(GetAccessibleTextSelectionInfo, GetAccessibleTextSelectionInfoFP, "getAccessibleTextSelectionInfo");
-            LOAD_FP(GetAccessibleTextAttributes, GetAccessibleTextAttributesFP, "getAccessibleTextAttributes");
-            LOAD_FP(GetAccessibleTextRect, GetAccessibleTextRectFP, "getAccessibleTextRect");
-            LOAD_FP(GetAccessibleTextLineBounds, GetAccessibleTextLineBoundsFP, "getAccessibleTextLineBounds");
-            LOAD_FP(GetAccessibleTextRange, GetAccessibleTextRangeFP, "getAccessibleTextRange");
-
-            LOAD_FP(GetCurrentAccessibleValueFromContext, GetCurrentAccessibleValueFromContextFP, "getCurrentAccessibleValueFromContext");
-            LOAD_FP(GetMaximumAccessibleValueFromContext, GetMaximumAccessibleValueFromContextFP, "getMaximumAccessibleValueFromContext");
-            LOAD_FP(GetMinimumAccessibleValueFromContext, GetMinimumAccessibleValueFromContextFP, "getMinimumAccessibleValueFromContext");
-
-            LOAD_FP(AddAccessibleSelectionFromContext, AddAccessibleSelectionFromContextFP, "addAccessibleSelectionFromContext");
-            LOAD_FP(ClearAccessibleSelectionFromContext, ClearAccessibleSelectionFromContextFP, "clearAccessibleSelectionFromContext");
-            LOAD_FP(GetAccessibleSelectionFromContext, GetAccessibleSelectionFromContextFP, "getAccessibleSelectionFromContext");
-            LOAD_FP(GetAccessibleSelectionCountFromContext, GetAccessibleSelectionCountFromContextFP, "getAccessibleSelectionCountFromContext");
-            LOAD_FP(IsAccessibleChildSelectedFromContext, IsAccessibleChildSelectedFromContextFP, "isAccessibleChildSelectedFromContext");
-            LOAD_FP(RemoveAccessibleSelectionFromContext, RemoveAccessibleSelectionFromContextFP, "removeAccessibleSelectionFromContext");
-            LOAD_FP(SelectAllAccessibleSelectionFromContext, SelectAllAccessibleSelectionFromContextFP, "selectAllAccessibleSelectionFromContext");
-
-            LOAD_FP(setTextContents, setTextContentsFP, "setTextContents");
-            LOAD_FP(getParentWithRole, getParentWithRoleFP, "getParentWithRole");
-            LOAD_FP(getTopLevelObject, getTopLevelObjectFP, "getTopLevelObject");
-            LOAD_FP(getParentWithRoleElseRoot, getParentWithRoleElseRootFP, "getParentWithRoleElseRoot");
-            LOAD_FP(getObjectDepth, getObjectDepthFP, "getObjectDepth");
-            LOAD_FP(getActiveDescendent, getActiveDescendentFP, "getActiveDescendent");
-
-            // additional methods for Teton
-            LOAD_FP(getVirtualAccessibleName, getVirtualAccessibleNameFP, "getVirtualAccessibleName");
-            LOAD_FP(requestFocus, requestFocusFP, "requestFocus");
-            LOAD_FP(selectTextRange, selectTextRangeFP, "selectTextRange");
-            LOAD_FP(getTextAttributesInRange, getTextAttributesInRangeFP, "getTextAttributesInRange");
-            LOAD_FP(getVisibleChildrenCount, getVisibleChildrenCountFP, "getVisibleChildrenCount");
-            LOAD_FP(getVisibleChildren, getVisibleChildrenFP, "getVisibleChildren");
-            LOAD_FP(setCaretPosition, setCaretPositionFP, "setCaretPosition");
-            LOAD_FP(getCaretLocation, getCaretLocationFP, "getCaretLocation");
-
-            LOAD_FP(getEventsWaiting, getEventsWaitingFP, "getEventsWaiting");
-
-            theAccessBridge.Windows_run();
-
-            theAccessBridgeInitializedFlag = TRUE;
-            PrintDebugString("theAccessBridgeInitializedFlag = TRUE");
-            return TRUE;
-        } else {
-            return FALSE;
-        }
-    }
-
-
-    BOOL shutdownAccessBridge() {
-        BOOL result;
-        DWORD error;
-        theAccessBridgeInitializedFlag = FALSE;
-        if (theAccessBridgeInstance != (HANDLE) 0) {
-            result = FreeLibrary(theAccessBridgeInstance);
-            if (result != TRUE) {
-                error = GetLastError();
-            }
-            return TRUE;
-        }
-        return FALSE;
-    }
-
-
-    void SetJavaShutdown(AccessBridge_JavaShutdownFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetJavaShutdown(fp);
-        }
-    }
-
-    void SetFocusGained(AccessBridge_FocusGainedFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetFocusGained(fp);
-        }
-    }
-
-    void SetFocusLost(AccessBridge_FocusLostFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetFocusLost(fp);
-        }
-    }
-
-
-    void SetCaretUpdate(AccessBridge_CaretUpdateFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetCaretUpdate(fp);
-        }
-    }
-
-
-    void SetMouseClicked(AccessBridge_MouseClickedFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetMouseClicked(fp);
-        }
-    }
-
-    void SetMouseEntered(AccessBridge_MouseEnteredFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetMouseEntered(fp);
-        }
-    }
-
-    void SetMouseExited(AccessBridge_MouseExitedFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetMouseExited(fp);
-        }
-    }
-
-    void SetMousePressed(AccessBridge_MousePressedFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetMousePressed(fp);
-        }
-    }
-
-    void SetMouseReleased(AccessBridge_MouseReleasedFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetMouseReleased(fp);
-        }
-    }
-
-
-    void SetMenuCanceled(AccessBridge_MenuCanceledFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetMenuCanceled(fp);
-        }
-    }
-
-    void SetMenuDeselected(AccessBridge_MenuDeselectedFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetMenuDeselected(fp);
-        }
-    }
-
-    void SetMenuSelected(AccessBridge_MenuSelectedFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetMenuSelected(fp);
-        }
-    }
-
-    void SetPopupMenuCanceled(AccessBridge_PopupMenuCanceledFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPopupMenuCanceled(fp);
-        }
-    }
-
-    void SetPopupMenuWillBecomeInvisible(AccessBridge_PopupMenuWillBecomeInvisibleFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPopupMenuWillBecomeInvisible(fp);
-        }
-    }
-
-    void SetPopupMenuWillBecomeVisible(AccessBridge_PopupMenuWillBecomeVisibleFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPopupMenuWillBecomeVisible(fp);
-        }
-    }
-
-
-    void SetPropertyNameChange(AccessBridge_PropertyNameChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyNameChange(fp);
-        }
-    }
-
-    void SetPropertyDescriptionChange(AccessBridge_PropertyDescriptionChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyDescriptionChange(fp);
-        }
-    }
-
-    void SetPropertyStateChange(AccessBridge_PropertyStateChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyStateChange(fp);
-        }
-    }
-
-    void SetPropertyValueChange(AccessBridge_PropertyValueChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyValueChange(fp);
-        }
-    }
-
-    void SetPropertySelectionChange(AccessBridge_PropertySelectionChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertySelectionChange(fp);
-        }
-    }
-
-    void SetPropertyTextChange(AccessBridge_PropertyTextChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyTextChange(fp);
-        }
-    }
-
-    void SetPropertyCaretChange(AccessBridge_PropertyCaretChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyCaretChange(fp);
-        }
-    }
-
-    void SetPropertyVisibleDataChange(AccessBridge_PropertyVisibleDataChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyVisibleDataChange(fp);
-        }
-    }
-
-    void SetPropertyChildChange(AccessBridge_PropertyChildChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyChildChange(fp);
-        }
-    }
-
-    void SetPropertyActiveDescendentChange(AccessBridge_PropertyActiveDescendentChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyActiveDescendentChange(fp);
-        }
-    }
-
-    void SetPropertyTableModelChange(AccessBridge_PropertyTableModelChangeFP fp) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SetPropertyTableModelChange(fp);
-        }
-    }
-
-    /**
-     * General routines
-     */
-    void ReleaseJavaObject(long vmID, Java_Object object) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.ReleaseJavaObject(vmID, object);
-        }
-    }
-
-    BOOL GetVersionInfo(long vmID, AccessBridgeVersionInfo *info) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetVersionInfo(vmID, info);
-        }
-        return FALSE;
-    }
-
-
-    /**
-     * Window routines
-     */
-    BOOL IsJavaWindow(HWND window) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-                        BOOL ret ;
-                        ret = theAccessBridge.IsJavaWindow(window);
-            return ret ;
-
-        }
-        return FALSE;
-    }
-
-
-    /**
-     * Returns the virtual machine ID and AccessibleContext for a top-level window
-     */
-    BOOL GetAccessibleContextFromHWND(HWND target, long *vmID, AccessibleContext *ac) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleContextFromHWND(target, vmID, ac);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Returns the HWND from the AccessibleContext of a top-level window.  Returns 0
-     *   on error or if the AccessibleContext does not refer to a top-level window.
-     */
-    HWND getHWNDFromAccessibleContext(long vmID, JOBJECT64 accesibleContext) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getHWNDFromAccessibleContext(vmID, accesibleContext);
-        }
-        return (HWND)0;
-    }
-
-    /**
-     * returns whether two objects are the same
-     */
-    BOOL IsSameObject(long vmID, JOBJECT64 obj1, JOBJECT64 obj2) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.IsSameObject(vmID, obj1, obj2);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Sets editable text contents.  The AccessibleContext must implement AccessibleEditableText and
-     *   be editable.  The maximum text length is MAX_STRING_SIZE - 1.
-     * Returns whether successful
-     */
-    BOOL setTextContents (const long vmID, const AccessibleContext accessibleContext, const wchar_t *text) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.setTextContents(vmID, accessibleContext, text);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Returns the Accessible Context with the specified role that is the
-     * ancestor of a given object. The role is one of the role strings
-     * defined in AccessBridgePackages.h
-     * If there is no ancestor object that has the specified role,
-     * returns (AccessibleContext)0.
-     */
-    AccessibleContext getParentWithRole (const long vmID, const AccessibleContext accessibleContext,
-                                         const wchar_t *role) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getParentWithRole(vmID, accessibleContext, role);
-        }
-        return (AccessibleContext)0;
-    }
-
-    /**
-     * Returns the Accessible Context with the specified role that is the
-     * ancestor of a given object. The role is one of the role strings
-     * defined in AccessBridgePackages.h.  If an object with the specified
-     * role does not exist, returns the top level object for the Java Window.
-     * Returns (AccessibleContext)0 on error.
-     */
-    AccessibleContext getParentWithRoleElseRoot (const long vmID, const AccessibleContext accessibleContext,
-                                                 const wchar_t *role) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getParentWithRoleElseRoot(vmID, accessibleContext, role);
-        }
-        return (AccessibleContext)0;
-    }
-
-    /**
-     * Returns the Accessible Context for the top level object in
-     * a Java Window.  This is same Accessible Context that is obtained
-     * from GetAccessibleContextFromHWND for that window.  Returns
-     * (AccessibleContext)0 on error.
-     */
-    AccessibleContext getTopLevelObject (const long vmID, const AccessibleContext accessibleContext) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getTopLevelObject(vmID, accessibleContext);
-        }
-        return (AccessibleContext)0;
-    }
-
-    /**
-     * Returns how deep in the object hierarchy a given object is.
-     * The top most object in the object hierarchy has an object depth of 0.
-     * Returns -1 on error.
-     */
-    int getObjectDepth (const long vmID, const AccessibleContext accessibleContext) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getObjectDepth(vmID, accessibleContext);
-        }
-        return -1;
-    }
-
-    /**
-     * Returns the Accessible Context of the current ActiveDescendent of an object.
-     * This method assumes the ActiveDescendent is the component that is currently
-     * selected in a container object.
-     * Returns (AccessibleContext)0 on error or if there is no selection.
-     */
-    AccessibleContext getActiveDescendent (const long vmID, const AccessibleContext accessibleContext) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getActiveDescendent(vmID, accessibleContext);
-        }
-        return (AccessibleContext)0;
-    }
-
-
-    /**
-     * Accessible Context routines
-     */
-    BOOL GetAccessibleContextAt(long vmID, AccessibleContext acParent,
-                                jint x, jint y, AccessibleContext *ac) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleContextAt(vmID, acParent, x, y, ac);
-        }
-        return FALSE;
-    }
-
-    BOOL GetAccessibleContextWithFocus(HWND window, long *vmID, AccessibleContext *ac) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleContextWithFocus(window, vmID, ac);
-        }
-        return FALSE;
-    }
-
-    BOOL GetAccessibleContextInfo(long vmID, AccessibleContext ac, AccessibleContextInfo *info) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleContextInfo(vmID, ac, info);
-        }
-        return FALSE;
-    }
-
-    AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleChildFromContext(vmID, ac, index);
-        }
-        return (AccessibleContext) 0;
-    }
-
-    AccessibleContext GetAccessibleParentFromContext(long vmID, AccessibleContext ac) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleParentFromContext(vmID, ac);
-        }
-        return (AccessibleContext) 0;
-    }
-
-    /* begin AccessibleTable routines */
-
-    /*
-     * get information about an AccessibleTable
-     */
-    BOOL getAccessibleTableInfo(long vmID, AccessibleContext acParent, AccessibleTableInfo *tableInfo) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableInfo(vmID, acParent, tableInfo);
-        }
-        return FALSE;
-    }
-
-    /*
-     * get information about an AccessibleTable cell
-     */
-    BOOL getAccessibleTableCellInfo(long vmID, AccessibleTable accessibleTable,
-                                    jint row, jint column, AccessibleTableCellInfo *tableCellInfo) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableCellInfo(vmID, accessibleTable, row, column, tableCellInfo);
-        }
-        return FALSE;
-    }
-
-    /*
-     * get information about an AccessibleTable row header
-     */
-    BOOL getAccessibleTableRowHeader(long vmID, AccessibleContext acParent, AccessibleTableInfo *tableInfo) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableRowHeader(vmID, acParent, tableInfo);
-        }
-        return FALSE;
-    }
-
-    /*
-     * get information about an AccessibleTable column header
-     */
-    BOOL getAccessibleTableColumnHeader(long vmID, AccessibleContext acParent, AccessibleTableInfo *tableInfo) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableColumnHeader(vmID, acParent, tableInfo);
-        }
-        return FALSE;
-    }
-
-    /*
-     * return a description of an AccessibleTable row header
-     */
-    AccessibleContext getAccessibleTableRowDescription(long vmID, AccessibleContext acParent, jint row) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableRowDescription(vmID, acParent, row);
-        }
-        return (AccessibleContext)0;
-    }
-
-    /*
-     * return a description of an AccessibleTable column header
-     */
-    AccessibleContext getAccessibleTableColumnDescription(long vmID, AccessibleContext acParent, jint column) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableColumnDescription(vmID, acParent, column);
-        }
-        return (AccessibleContext)0;
-    }
-
-    /*
-     * return the number of rows selected in an AccessibleTable
-     */
-    jint getAccessibleTableRowSelectionCount(long vmID, AccessibleTable table) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableRowSelectionCount(vmID, table);
-        }
-        return -1;
-    }
-
-    /*
-     * return whether a row is selected in an AccessibleTable
-     */
-    BOOL isAccessibleTableRowSelected(long vmID, AccessibleTable table, jint row) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.isAccessibleTableRowSelected(vmID, table, row);
-        }
-        return FALSE;
-    }
-
-    /*
-     * get an array of selected rows in an AccessibleTable
-     */
-    BOOL getAccessibleTableRowSelections(long vmID, AccessibleTable table, jint count, jint *selections) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableRowSelections(vmID, table, count, selections);
-        }
-        return FALSE;
-    }
-
-    /*
-     * return the number of columns selected in an AccessibleTable
-     */
-    jint getAccessibleTableColumnSelectionCount(long vmID, AccessibleTable table) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableColumnSelectionCount(vmID, table);
-        }
-        return -1;
-    }
-
-    /*
-     * return whether a column is selected in an AccessibleTable
-     */
-    BOOL isAccessibleTableColumnSelected(long vmID, AccessibleTable table, jint column) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.isAccessibleTableColumnSelected(vmID, table, column);
-        }
-        return FALSE;
-    }
-
-    /*
-     * get an array of columns selected in an AccessibleTable
-     */
-    BOOL getAccessibleTableColumnSelections(long vmID, AccessibleTable table, jint count, jint *selections) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableColumnSelections(vmID, table, count, selections);
-        }
-        return FALSE;
-    }
-
-    /*
-     * return the row number for a cell at a given index
-     */
-    jint
-    getAccessibleTableRow(long vmID, AccessibleTable table, jint index) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableRow(vmID, table, index);
-        }
-        return -1;
-    }
-
-    /*
-     * return the column number for a cell at a given index
-     */
-    jint
-    getAccessibleTableColumn(long vmID, AccessibleTable table, jint index) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableColumn(vmID, table, index);
-        }
-        return -1;
-    }
-
-    /*
-     * return the index of a cell at a given row and column
-     */
-    jint
-    getAccessibleTableIndex(long vmID, AccessibleTable table, jint row, jint column) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleTableIndex(vmID, table, row, column);
-        }
-        return -1;
-    }
-
-    /* end AccessibleTable routines */
-
-
-    /**
-     * Accessible Text routines
-     */
-    BOOL GetAccessibleTextInfo(long vmID, AccessibleText at, AccessibleTextInfo *textInfo, jint x, jint y) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleTextInfo(vmID, at, textInfo, x, y);
-        }
-        return FALSE;
-    }
-
-    BOOL GetAccessibleTextItems(long vmID, AccessibleText at, AccessibleTextItemsInfo *textItems, jint index) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleTextItems(vmID, at, textItems, index);
-        }
-        return FALSE;
-    }
-
-    BOOL GetAccessibleTextSelectionInfo(long vmID, AccessibleText at, AccessibleTextSelectionInfo *textSelection) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleTextSelectionInfo(vmID, at, textSelection);
-        }
-        return FALSE;
-    }
-
-    BOOL GetAccessibleTextAttributes(long vmID, AccessibleText at, jint index, AccessibleTextAttributesInfo *attributes) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleTextAttributes(vmID, at, index, attributes);
-        }
-        return FALSE;
-    }
-
-    BOOL GetAccessibleTextRect(long vmID, AccessibleText at, AccessibleTextRectInfo *rectInfo, jint index) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleTextRect(vmID, at, rectInfo, index);
-        }
-        return FALSE;
-    }
-
-    BOOL GetAccessibleTextLineBounds(long vmID, AccessibleText at, jint index, jint *startIndex, jint *endIndex) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleTextLineBounds(vmID, at, index, startIndex, endIndex);
-        }
-        return FALSE;
-    }
-
-    BOOL GetAccessibleTextRange(long vmID, AccessibleText at, jint start, jint end, wchar_t *text, short len) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleTextRange(vmID, at, start, end, text, len);
-        }
-        return FALSE;
-    }
-
-    /**
-     * AccessibleRelationSet routines
-     */
-    BOOL getAccessibleRelationSet(long vmID, AccessibleContext accessibleContext,
-                                  AccessibleRelationSetInfo *relationSetInfo) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleRelationSet(vmID, accessibleContext, relationSetInfo);
-        }
-        return FALSE;
-    }
-
-    /**
-     * AccessibleHypertext routines
-     */
-
-    // Gets AccessibleHypertext for an AccessibleContext
-    BOOL getAccessibleHypertext(long vmID, AccessibleContext accessibleContext,
-                                AccessibleHypertextInfo *hypertextInfo) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleHypertext(vmID, accessibleContext, hypertextInfo);
-        }
-        return FALSE;
-    }
-
-    // Activates an AccessibleHyperlink for an AccessibleContext
-    BOOL activateAccessibleHyperlink(long vmID, AccessibleContext accessibleContext,
-                                     AccessibleHyperlink accessibleHyperlink) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.activateAccessibleHyperlink(vmID, accessibleContext, accessibleHyperlink);
-        }
-        return FALSE;
-    }
-
-    /*
-     * Returns the number of hyperlinks in a component
-     * Maps to AccessibleHypertext.getLinkCount.
-     * Returns -1 on error.
-     */
-    jint getAccessibleHyperlinkCount(const long vmID,
-                                     const AccessibleContext accessibleContext) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleHyperlinkCount(vmID, accessibleContext);
-        }
-        return -1;
-    }
-
-    /*
-     * This method is used to iterate through the hyperlinks in a component.  It
-     * returns hypertext information for a component starting at hyperlink index
-     * nStartIndex.  No more than MAX_HYPERLINKS AccessibleHypertextInfo objects will
-     * be returned for each call to this method.
-     * returns FALSE on error.
-     */
-    BOOL getAccessibleHypertextExt(const long vmID,
-                                   const AccessibleContext accessibleContext,
-                                   const jint nStartIndex,
-                                   /* OUT */ AccessibleHypertextInfo *hypertextInfo) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleHypertextExt(vmID,
-                                                             accessibleContext,
-                                                             nStartIndex,
-                                                             hypertextInfo);
-        }
-        return FALSE;
-    }
-
-    /*
-     * Returns the index into an array of hyperlinks that is associated with
-     * a character index in document;
-     * Maps to AccessibleHypertext.getLinkIndex.
-     * Returns -1 on error.
-     */
-    jint getAccessibleHypertextLinkIndex(const long vmID,
-                                         const AccessibleHypertext hypertext,
-                                         const jint nIndex) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleHypertextLinkIndex(vmID,
-                                                                   hypertext,
-                                                                   nIndex);
-        }
-        return -1;
-    }
-
-    /*
-     * Returns the nth hyperlink in a document.
-     * Maps to AccessibleHypertext.getLink.
-     * Returns -1 on error
-     */
-    BOOL getAccessibleHyperlink(const long vmID,
-                                const AccessibleHypertext hypertext,
-                                const jint nIndex,
-                                /* OUT */ AccessibleHyperlinkInfo *hyperlinkInfo) {
-
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleHyperlink(vmID,
-                                                          hypertext,
-                                                          nIndex,
-                                                          hyperlinkInfo);
-        }
-        return FALSE;
-    }
-
-
-    /* Accessible KeyBindings, Icons and Actions */
-    BOOL getAccessibleKeyBindings(long vmID, AccessibleContext accessibleContext,
-                                  AccessibleKeyBindings *keyBindings) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleKeyBindings(vmID, accessibleContext, keyBindings);
-        }
-        return FALSE;
-    }
-
-    BOOL getAccessibleIcons(long vmID, AccessibleContext accessibleContext,
-                            AccessibleIcons *icons) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleIcons(vmID, accessibleContext, icons);
-        }
-        return FALSE;
-    }
-
-    BOOL getAccessibleActions(long vmID, AccessibleContext accessibleContext,
-                              AccessibleActions *actions) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getAccessibleActions(vmID, accessibleContext, actions);
-        }
-        return FALSE;
-    }
-
-    BOOL doAccessibleActions(long vmID, AccessibleContext accessibleContext,
-                             AccessibleActionsToDo *actionsToDo, jint *failure) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.doAccessibleActions(vmID, accessibleContext, actionsToDo, failure);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Accessible Value routines
-     */
-    BOOL GetCurrentAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetCurrentAccessibleValueFromContext(vmID, av, value, len);
-        }
-        return FALSE;
-    }
-
-    BOOL GetMaximumAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetMaximumAccessibleValueFromContext(vmID, av, value, len);
-        }
-        return FALSE;
-    }
-
-    BOOL GetMinimumAccessibleValueFromContext(long vmID, AccessibleValue av, wchar_t *value, short len) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetMinimumAccessibleValueFromContext(vmID, av, value, len);
-        }
-        return FALSE;
-    }
-
-
-    /**
-     * Accessible Selection routines
-     */
-    void addAccessibleSelectionFromContext(long vmID, AccessibleSelection as, int i) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.AddAccessibleSelectionFromContext(vmID, as, i);
-        }
-    }
-
-    void clearAccessibleSelectionFromContext(long vmID, AccessibleSelection as) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.ClearAccessibleSelectionFromContext(vmID, as);
-        }
-    }
-
-    JOBJECT64 GetAccessibleSelectionFromContext(long vmID, AccessibleSelection as, int i) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleSelectionFromContext(vmID, as, i);
-        }
-        return (JOBJECT64) 0;
-    }
-
-    int GetAccessibleSelectionCountFromContext(long vmID, AccessibleSelection as) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.GetAccessibleSelectionCountFromContext(vmID, as);
-        }
-        return -1;
-    }
-
-    BOOL IsAccessibleChildSelectedFromContext(long vmID, AccessibleSelection as, int i) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.IsAccessibleChildSelectedFromContext(vmID, as, i);
-        }
-        return FALSE;
-    }
-
-    void RemoveAccessibleSelectionFromContext(long vmID, AccessibleSelection as, int i) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.RemoveAccessibleSelectionFromContext(vmID, as, i);
-        }
-    }
-
-    void SelectAllAccessibleSelectionFromContext(long vmID, AccessibleSelection as) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            theAccessBridge.SelectAllAccessibleSelectionFromContext(vmID, as);
-        }
-    }
-
-    /**
-     * Additional methods for Teton
-     */
-
-    /**
-     * Gets the AccessibleName for a component based upon the JAWS algorithm. Returns
-     * whether successful.
-     *
-     * Bug ID 4916682 - Implement JAWS AccessibleName policy
-     */
-    BOOL getVirtualAccessibleName(const long vmID, const AccessibleContext accessibleContext,
-                                  wchar_t *name, int len) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getVirtualAccessibleName(vmID, accessibleContext, name, len);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Request focus for a component. Returns whether successful;
-     *
-     * Bug ID 4944757 - requestFocus method needed
-     */
-    BOOL requestFocus(const long vmID, const AccessibleContext accessibleContext) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.requestFocus(vmID, accessibleContext);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Selects text between two indices.  Selection includes the text at the start index
-     * and the text at the end index. Returns whether successful;
-     *
-     * Bug ID 4944758 - selectTextRange method needed
-     */
-    BOOL selectTextRange(const long vmID, const AccessibleContext accessibleContext,
-                         const int startIndex, const int endIndex) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.selectTextRange(vmID, accessibleContext, startIndex, endIndex);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Get text attributes between two indices.  The attribute list includes the text at the
-     * start index and the text at the end index. Returns whether successful;
-     *
-     * Bug ID 4944761 - getTextAttributes between two indices method needed
-     */
-    BOOL getTextAttributesInRange(const long vmID, const AccessibleContext accessibleContext,
-                                  const int startIndex, const int endIndex,
-                                  AccessibleTextAttributesInfo *attributes, short *len) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getTextAttributesInRange(vmID, accessibleContext, startIndex,
-                                                            endIndex, attributes, len);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Returns the number of visible children of a component. Returns -1 on error.
-     *
-     * Bug ID 4944762- getVisibleChildren for list-like components needed
-     */
-    int getVisibleChildrenCount(const long vmID, const AccessibleContext accessibleContext) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getVisibleChildrenCount(vmID, accessibleContext);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Gets the visible children of an AccessibleContext. Returns whether successful;
-     *
-     * Bug ID 4944762- getVisibleChildren for list-like components needed
-     */
-    BOOL getVisibleChildren(const long vmID, const AccessibleContext accessibleContext,
-                            const int startIndex, VisibleChildrenInfo *visibleChildrenInfo) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getVisibleChildren(vmID, accessibleContext, startIndex,
-                                                      visibleChildrenInfo);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Set the caret to a text position. Returns whether successful;
-     *
-     * Bug ID 4944770 - setCaretPosition method needed
-     */
-    BOOL setCaretPosition(const long vmID, const AccessibleContext accessibleContext,
-                          const int position) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.setCaretPosition(vmID, accessibleContext, position);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Gets the text caret location
-     */
-    BOOL getCaretLocation(long vmID, AccessibleContext ac, AccessibleTextRectInfo *rectInfo, jint index) {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getCaretLocation(vmID, ac, rectInfo, index);
-        }
-        return FALSE;
-    }
-
-    /**
-     * Gets the number of events waiting to fire
-     */
-    int getEventsWaiting() {
-        if (theAccessBridgeInitializedFlag == TRUE) {
-            return theAccessBridge.getEventsWaiting();
-        }
-        return FALSE;
-    }
-
-#ifdef __cplusplus
-}
-#endif
--- a/jdk/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCalls.h	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.accessibility/windows/native/include/bridge/AccessBridgeCalls.h	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,25 @@
  * questions.
  */
 
+/* Note: In addition to this header file AccessBridgeCalls.c must be compiled and
+ * linked to your application.  AccessBridgeCalls.c implements the Java Access
+ * Bridge API and also hides the complexities associated with interfacing to the
+ * associated Java Access Bridge DLL which is installed when Java is installed.
+ *
+ * AccessBridgeCalls.c is available for download from the OpenJDK repository using
+ * the following link:
+ *
+ * http://hg.openjdk.java.net/jdk9/jdk9/jdk/raw-file/tip/src/jdk.accessibility/windows/native/bridge/AccessBridgeCalls.c
+ *
+ * Also note that the API is used in the jaccessinspector and jaccesswalker tools.
+ * The source for those tools is available in the OpenJDK repository at these links:
+ *
+ * http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/tip/src/jdk.accessibility/windows/native/jaccessinspector/jaccessinspector.cpp
+ * http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/tip/src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalker.cpp
+ *
+ *
+ */
+
 /*
  * Wrapper functions around calls to the AccessBridge DLL
  */
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/SunMSCAPI.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/SunMSCAPI.java	Wed Jul 05 22:30:23 2017 +0200
@@ -33,6 +33,8 @@
 import java.security.ProviderException;
 import java.util.HashMap;
 import java.util.Arrays;
+import java.util.Map;
+
 import static sun.security.util.SecurityConstants.PROVIDER_VER;
 
 /**
@@ -133,8 +135,11 @@
                 /*
                  * Secure random
                  */
+                HashMap<String, String> srattrs = new HashMap<>(1);
+                srattrs.put("ThreadSafe", "true");
                 putService(new ProviderService(p, "SecureRandom",
-                           "Windows-PRNG", "sun.security.mscapi.PRNG"));
+                           "Windows-PRNG", "sun.security.mscapi.PRNG",
+                           null, srattrs));
 
                 /*
                  * Key store
--- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/SunPKCS11.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/SunPKCS11.java	Wed Jul 05 22:30:23 2017 +0200
@@ -987,7 +987,8 @@
 
         P11Service(Token token, String type, String algorithm,
                 String className, String[] al, long mechanism) {
-            super(token.provider, type, algorithm, className, toList(al), null);
+            super(token.provider, type, algorithm, className, toList(al),
+                    type.equals(SR) ? Map.of("ThreadSafe", "true") : null);
             this.token = token;
             this.mechanism = mechanism & 0xFFFFFFFFL;
         }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Wed Jul 05 22:30:23 2017 +0200
@@ -32,6 +32,7 @@
 import java.nio.file.Files;
 import java.nio.file.PathMatcher;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.MissingResourceException;
@@ -190,19 +191,12 @@
             if (options.help) {
                 if (unhandled.isEmpty()) {
                     log.println(TASK_HELPER.getMessage("main.usage", PROGNAME));
-
-                    for (Option<?> o : RECOGNIZED_OPTIONS) {
-                        String name = o.aliases()[0];
-
-                        if (name.startsWith("--")) {
-                            name = name.substring(2);
-                        } else if (name.startsWith("-")) {
-                            name = name.substring(1);
-                        }
-
-                        log.println(TASK_HELPER.getMessage("main.opt." + name));
-                    }
-
+                    Arrays.asList(RECOGNIZED_OPTIONS).stream()
+                        .filter(option -> !option.isHidden())
+                        .sorted()
+                        .forEach(option -> {
+                             log.println(TASK_HELPER.getMessage(option.resourceName()));
+                        });
                     log.println(TASK_HELPER.getMessage("main.opt.footer"));
                 } else {
                     try {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Wed Jul 05 22:30:23 2017 +0200
@@ -60,34 +60,36 @@
 warn.prefix=Warning:
 
 main.opt.dir=\
-\  --dir                             Target directory for extract directive
+\       --dir                        Target directory for extract directive
 
 main.opt.include=\
-\  --include <pattern-list>          Pattern list for filtering entries.
+\       --include <pattern-list>     Pattern list for filtering entries.
+
+main.opt.full-version=\
+\       --full-version               Print full version information
+
+main.opt.help=\
+\  -h,  --help                       Print usage message
+
+main.opt.verbose=\
+\       --verbose                    Listing prints entry size and offset\n\
+\                                    attributes
+
+main.opt.version=\
+\       --version                    Print version information
+
+main.command.files=\
+\       @<filename>                  Read options from file
 
 main.opt.footer=\
 \n\
-\For options requiring a <pattern-list>, the value will be a comma\
-\ separated list of elements each using one the following forms:\n\
+\For options requiring a <pattern-list>, the value will be a comma separated\n\
+\list of elements each using one the following forms:\n\
 \  <glob-pattern>\n\
 \  glob:<glob-pattern>\n\
 \  regex:<regex-pattern>
 
 
-main.opt.full-version=\
-\  --full-version                    Print full version information
-
-main.opt.help=\
-\  -h,  --help                       Print usage message
-
-main.opt.verbose=\
-\  --verbose                         Listing prints entry size and offset attributes
-
-main.opt.version=\
-\  --version                         Print version information
-
-main.command.files=\
-\  @<filename>                       Read options from file
 
 err.not.a.task=task must be one of <extract | info | list | verify>: {0}
 err.missing.arg=no value given for {0}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java	Wed Jul 05 22:30:23 2017 +0200
@@ -27,6 +27,7 @@
 import java.lang.reflect.Layer;
 import java.nio.ByteOrder;
 import java.nio.file.Path;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -278,6 +279,13 @@
      */
     public void build(JlinkConfiguration config, PluginsConfiguration pluginsConfig) {
         Objects.requireNonNull(config);
+        if (pluginsConfig == null) {
+            pluginsConfig = new PluginsConfiguration();
+        }
+
+        // add all auto-enabled plugins from boot layer
+        pluginsConfig = addAutoEnabledPlugins(pluginsConfig);
+
         try {
             JlinkTask.createImage(config, pluginsConfig);
         } catch (Exception ex) {
@@ -285,6 +293,19 @@
         }
     }
 
+    private PluginsConfiguration addAutoEnabledPlugins(PluginsConfiguration pluginsConfig) {
+        List<Plugin> plugins = new ArrayList<>(pluginsConfig.getPlugins());
+        List<Plugin> bootPlugins = PluginRepository.getPlugins(Layer.boot());
+        for (Plugin bp : bootPlugins) {
+            if (Utils.isAutoEnabled(bp)) {
+                bp.configure(Collections.emptyMap());
+                plugins.add(bp);
+            }
+        }
+        return new PluginsConfiguration(plugins, pluginsConfig.getImageBuilder(),
+            pluginsConfig.getLastSorterPluginName());
+    }
+
     /**
      * Post process the image with a plugin configuration.
      *
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Wed Jul 05 22:30:23 2017 +0200
@@ -134,7 +134,7 @@
         }, true, "--full-version"),
         new Option<JlinkTask>(false, (task, opt, arg) -> {
             task.options.ignoreSigning = true;
-        }, true, "--ignore-signing-information"),};
+        }, "--ignore-signing-information"),};
 
     private static final String PROGNAME = "jlink";
     private final OptionsValues options = new OptionsValues();
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Wed Jul 05 22:30:23 2017 +0200
@@ -46,8 +46,8 @@
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 import java.util.Set;
+import java.util.stream.Stream;
 
-import jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin;
 import jdk.tools.jlink.internal.plugins.ExcludeJmodSectionPlugin;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.plugin.Plugin.Category;
@@ -90,8 +90,7 @@
         public boolean showUsage;
     }
 
-    public static class Option<T> {
-
+    public static class Option<T> implements Comparable<T> {
         public interface Processing<T> {
 
             void process(T task, String opt, String arg) throws BadArgs;
@@ -100,17 +99,34 @@
         final boolean hasArg;
         final Processing<T> processing;
         final boolean hidden;
-        final String[] aliases;
+        final String name;
+        final String shortname;
 
-        public Option(boolean hasArg, Processing<T> processing, boolean hidden, String... aliases) {
+        public Option(boolean hasArg, Processing<T> processing, boolean hidden, String name, String shortname) {
+            if (!name.startsWith("--")) {
+                throw new RuntimeException("option name missing --, " + name);
+            }
+            if (!shortname.isEmpty() && !shortname.startsWith("-")) {
+                throw new RuntimeException("short name missing -, " + shortname);
+            }
+
             this.hasArg = hasArg;
             this.processing = processing;
-            this.aliases = aliases;
             this.hidden = hidden;
+            this.name = name;
+            this.shortname = shortname;
         }
 
-        public Option(boolean hasArg, Processing<T> processing, String... aliases) {
-            this(hasArg, processing, false, aliases);
+        public Option(boolean hasArg, Processing<T> processing, String name, String shortname) {
+            this(hasArg, processing, false, name, shortname);
+        }
+
+        public Option(boolean hasArg, Processing<T> processing, boolean hidden, String name) {
+            this(hasArg, processing, hidden, name, "");
+        }
+
+        public Option(boolean hasArg, Processing<T> processing, String name) {
+            this(hasArg, processing, false, name, "");
         }
 
         public boolean isHidden() {
@@ -118,16 +134,10 @@
         }
 
         public boolean matches(String opt) {
-            for (String a : aliases) {
-                if (a.equals(opt)) {
-                    return true;
-                } else if (opt.startsWith("--")
-                        && (hasArg && opt.startsWith(a + "="))) {
-                    return true;
-                }
-            }
-            return false;
-        }
+            return opt.equals(name) ||
+                   opt.equals(shortname) ||
+                   hasArg && opt.startsWith("--") && opt.startsWith(name + "=");
+         }
 
         public boolean ignoreRest() {
             return false;
@@ -137,28 +147,54 @@
             processing.process(task, opt, arg);
         }
 
-        public String[] aliases() {
-            return aliases;
+        public String getName() {
+            return name;
+        }
+
+        public String resourceName() {
+            return resourcePrefix() + name.substring(2);
+        }
+
+        public String getShortname() {
+            return shortname;
+        }
+
+        public String resourcePrefix() {
+            return "main.opt.";
+        }
+
+        @Override
+        public int compareTo(Object object) {
+            if (!(object instanceof Option<?>)) {
+                throw new RuntimeException("comparing non-Option");
+            }
+
+            Option<?> option = (Option<?>)object;
+
+            return name.compareTo(option.name);
+        }
+
+    }
+
+    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);
+        }
+
+        public PluginOption(boolean hasArg,
+                Processing<PluginsHelper> processing, boolean hidden, String name) {
+            super(hasArg, processing, hidden, name, "");
+        }
+
+        public String resourcePrefix() {
+            return "plugin.opt.";
         }
     }
 
-    private static class PlugOption extends Option<PluginsOptions> {
-
-        public PlugOption(boolean hasArg,
-                Processing<PluginsOptions> processing, boolean hidden, String... aliases) {
-            super(hasArg, processing, hidden, aliases);
-        }
-
-        public PlugOption(boolean hasArg,
-                Processing<PluginsOptions> processing, String... aliases) {
-            super(hasArg, processing, aliases);
-        }
-    }
-
-    private final class PluginsOptions {
+    private final class PluginsHelper {
 
         private static final String PLUGINS_PATH = "--plugin-module-path";
-        private static final String POST_PROCESS = "--post-process-path";
 
         private Layer pluginsLayer = Layer.boot();
         private final List<Plugin> plugins;
@@ -170,10 +206,10 @@
         // Each such occurrence results in a Map of arguments. So, there could be multiple
         // args maps per plugin instance.
         private final Map<Plugin, List<Map<String, String>>> pluginToMaps = new HashMap<>();
-        private final List<PlugOption> pluginsOptions = new ArrayList<>();
-        private final List<PlugOption> mainOptions = new ArrayList<>();
+        private final List<PluginOption> pluginsOptions = new ArrayList<>();
+        private final List<PluginOption> mainOptions = new ArrayList<>();
 
-        private PluginsOptions(String pp) throws BadArgs {
+        private PluginsHelper(String pp) throws BadArgs {
 
             if (pp != null) {
                 String[] dirs = pp.split(File.pathSeparator);
@@ -193,13 +229,13 @@
                     addOrderedPluginOptions(plugin, optionsSeen);
                 }
             }
-            mainOptions.add(new PlugOption(false,
+            mainOptions.add(new PluginOption(false,
                     (task, opt, arg) -> {
                         // This option is handled prior
                         // to have the options parsed.
                     },
-                    "--plugin-module-path"));
-            mainOptions.add(new PlugOption(true, (task, opt, arg) -> {
+                    false, "--plugin-module-path"));
+            mainOptions.add(new PluginOption(true, (task, opt, arg) -> {
                     for (Plugin plugin : plugins) {
                         if (plugin.getName().equals(arg)) {
                             pluginToMaps.remove(plugin);
@@ -208,24 +244,24 @@
                     }
                     throw newBadArgs("err.no.such.plugin", arg);
                 },
-                "--disable-plugin"));
-            mainOptions.add(new PlugOption(true, (task, opt, arg) -> {
+                false, "--disable-plugin"));
+            mainOptions.add(new PluginOption(true, (task, opt, arg) -> {
                 Path path = Paths.get(arg);
                 if (!Files.exists(path) || !Files.isDirectory(path)) {
                     throw newBadArgs("err.image.must.exist", path);
                 }
                 existingImage = path.toAbsolutePath();
-            }, true, POST_PROCESS));
-            mainOptions.add(new PlugOption(true,
+            }, true, "--post-process-path"));
+            mainOptions.add(new PluginOption(true,
                     (task, opt, arg) -> {
                         lastSorter = arg;
                     },
                     true, "--resources-last-sorter"));
-            mainOptions.add(new PlugOption(false,
+            mainOptions.add(new PluginOption(false,
                     (task, opt, arg) -> {
                         listPlugins = true;
                     },
-                    "--list-plugins"));
+                    false, "--list-plugins"));
         }
 
         private List<Map<String, String>> argListFor(Plugin plugin) {
@@ -261,8 +297,8 @@
             }
             optionsSeen.add(option);
 
-            PlugOption plugOption
-                    = new PlugOption(plugin.hasArguments(),
+            PluginOption plugOption
+                    = new PluginOption(plugin.hasArguments(),
                             (task, opt, arg) -> {
                                 if (!Utils.isFunctional(plugin)) {
                                     throw newBadArgs("err.provider.not.functional",
@@ -312,7 +348,7 @@
                                     }
                                 }
                             },
-                            "--" + option);
+                            false, "--" + option);
             pluginsOptions.add(plugOption);
 
             if (Utils.isFunctional(plugin)) {
@@ -322,44 +358,44 @@
 
                 if (plugin instanceof DefaultCompressPlugin) {
                     plugOption
-                        = new PlugOption(false,
+                        = new PluginOption(false,
                             (task, opt, arg) -> {
                                 Map<String, String> m = addArgumentMap(plugin);
                                 m.put(DefaultCompressPlugin.NAME, DefaultCompressPlugin.LEVEL_2);
-                            }, "-c");
+                            }, false, "--compress", "-c");
                     mainOptions.add(plugOption);
                 } else if (plugin instanceof StripDebugPlugin) {
                     plugOption
-                        = new PlugOption(false,
+                        = new PluginOption(false,
                             (task, opt, arg) -> {
                                 addArgumentMap(plugin);
-                            }, "-G");
+                            }, false, "--strip-debug", "-G");
                     mainOptions.add(plugOption);
                 } else if (plugin instanceof ExcludeJmodSectionPlugin) {
-                    plugOption = new PlugOption(false, (task, opt, arg) -> {
+                    plugOption = new PluginOption(false, (task, opt, arg) -> {
                             Map<String, String> m = addArgumentMap(plugin);
                             m.put(ExcludeJmodSectionPlugin.NAME,
                                   ExcludeJmodSectionPlugin.MAN_PAGES);
-                        }, "--no-man-pages");
+                        }, false, "--no-man-pages");
                     mainOptions.add(plugOption);
 
-                    plugOption = new PlugOption(false, (task, opt, arg) -> {
+                    plugOption = new PluginOption(false, (task, opt, arg) -> {
                         Map<String, String> m = addArgumentMap(plugin);
                         m.put(ExcludeJmodSectionPlugin.NAME,
                               ExcludeJmodSectionPlugin.INCLUDE_HEADER_FILES);
-                    }, "--no-header-files");
+                    }, false, "--no-header-files");
                     mainOptions.add(plugOption);
                 }
             }
         }
 
-        private PlugOption getOption(String name) throws BadArgs {
-            for (PlugOption o : pluginsOptions) {
+        private PluginOption getOption(String name) throws BadArgs {
+            for (PluginOption o : pluginsOptions) {
                 if (o.matches(name)) {
                     return o;
                 }
             }
-            for (PlugOption o : mainOptions) {
+            for (PluginOption o : mainOptions) {
                 if (o.matches(name)) {
                     return o;
                 }
@@ -461,7 +497,7 @@
         private String getPluginsPath(String[] args) throws BadArgs {
             String pp = null;
             for (int i = 0; i < args.length; i++) {
-                if (args[i].equals(PluginsOptions.PLUGINS_PATH)) {
+                if (args[i].equals(PluginsHelper.PLUGINS_PATH)) {
                     if (i == args.length - 1) {
                         throw new BadArgs("err.no.plugins.path").showUsage(true);
                     } else {
@@ -498,13 +534,13 @@
             // Must extract it prior to do any option analysis.
             // Required to interpret custom plugin options.
             // Unit tests can call Task multiple time in same JVM.
-            pluginOptions = new PluginsOptions(getPluginsPath(args));
+            pluginOptions = new PluginsHelper(getPluginsPath(args));
 
             // First extract plugins path if any
             String pp = null;
             List<String> filteredArgs = new ArrayList<>();
             for (int i = 0; i < args.length; i++) {
-                if (args[i].equals(PluginsOptions.PLUGINS_PATH)) {
+                if (args[i].equals(PluginsHelper.PLUGINS_PATH)) {
                     if (i == args.length - 1) {
                         throw new BadArgs("err.no.plugins.path").showUsage(true);
                     } else {
@@ -529,7 +565,7 @@
             for (int i = 0; i < args.length; i++) {
                 if (args[i].charAt(0) == '-') {
                     String name = args[i];
-                    PlugOption pluginOption = null;
+                    PluginOption pluginOption = null;
                     Option<T> option = getOption(name);
                     if (option == null) {
                         pluginOption = pluginOptions.getOption(name);
@@ -585,32 +621,13 @@
         }
 
         public void showHelp(String progName) {
-            showHelp(progName, true);
-        }
-
-        private void showHelp(String progName, boolean showsImageBuilder) {
             log.println(bundleHelper.getMessage("main.usage", progName));
-            for (Option<?> o : options) {
-                String name = o.aliases[0].substring(1); // there must always be at least one name
-                name = name.charAt(0) == '-' ? name.substring(1) : name;
-                if (o.isHidden() || name.equals("h")) {
-                    continue;
-                }
-                log.println(bundleHelper.getMessage("main.opt." + name));
-            }
-
-            for (Option<?> o : pluginOptions.mainOptions) {
-                if (o.aliases[0].equals(PluginsOptions.POST_PROCESS)
-                        && !showsImageBuilder) {
-                    continue;
-                }
-                String name = o.aliases[0].substring(1); // there must always be at least one name
-                name = name.charAt(0) == '-' ? name.substring(1) : name;
-                if (o.isHidden()) {
-                    continue;
-                }
-                log.println(bundleHelper.getMessage("plugin.opt." + name));
-            }
+            Stream.concat(options.stream(), pluginOptions.mainOptions.stream())
+                .filter(option -> !option.isHidden())
+                .sorted()
+                .forEach(option -> {
+                     log.println(bundleHelper.getMessage(option.resourceName()));
+                });
 
             log.println(bundleHelper.getMessage("main.command.files"));
         }
@@ -619,6 +636,7 @@
             log.println("\n" + bundleHelper.getMessage("main.extended.help"));
             List<Plugin> pluginList = PluginRepository.
                     getPlugins(pluginOptions.pluginsLayer);
+
             for (Plugin plugin : Utils.getSortedPlugins(pluginList)) {
                 showPlugin(plugin, log);
             }
@@ -671,7 +689,7 @@
         }
     }
 
-    private PluginsOptions pluginOptions;
+    private PluginsHelper pluginOptions;
     private PrintWriter log;
     private final ResourceBundleHelper bundleHelper;
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java	Wed Jul 05 22:30:23 2017 +0200
@@ -118,8 +118,6 @@
                                         null));
         }
 
-        plugins.add(Jlink.newPlugin("installed-modules", Collections.emptyMap(), null));
-
         // build the image
         Jlink.PluginsConfiguration pluginConfig = new Jlink.PluginsConfiguration(
             plugins, new DefaultImageBuilder(outputDir), null);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Wed Jul 05 22:30:23 2017 +0200
@@ -24,46 +24,51 @@
 #
 
 main.usage.summary=\
-Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output <path>\n\
-use --help for a list of possible options
+Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output\n\
+\<path> use --help for a list of possible options
 
 main.usage=\
-Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output <path>\n\
-\Possible options include:
+Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output
+\<path> Possible options include:
 
 error.prefix=Error:
 warn.prefix=Warning:
 
 main.opt.help=\
-\  -h, --help                        Print this help message
+\  -h, --help                            Print this help message
 
 main.opt.version=\
-\  --version                         Version information
+\      --version                         Version information
 
 main.opt.module-path=\
-\  -p <modulepath>\n\
-\  --module-path <modulepath>        Module path
+\  -p, --module-path <path>              Module path
 
 main.opt.add-modules=\
-\  --add-modules <mod>[,<mod>...]    Root modules to resolve
+\      --add-modules <mod>[,<mod>...]    Root modules to resolve
 
 main.opt.limit-modules=\
-\  --limit-modules <mod>[,<mod>...]  Limit the universe of observable modules
+\      --limit-modules <mod>[,<mod>...]  Limit the universe of observable\n\
+\                                        modules
 
 main.opt.output=\
-\  --output <path>                   Location of output path
+\      --output <path>                   Location of output path
 
 main.command.files=\
-\  @<filename>                       Read options from file
+\      @<filename>                       Read options from file
 
 main.opt.endian=\
-\  --endian <little|big>             Byte order of generated jimage (default:native)
+\      --endian <little|big>             Byte order of generated jimage\n\
+\                                        (default:native)
 
 main.opt.save-opts=\
-\  --save-opts <filename>            Save jlink options in the given file
+\      --save-opts <filename>            Save jlink options in the given file
 
 main.opt.ignore-signing-information=\
-\  --ignore-signing-information      Ignore signing information in modular JARs
+\      --ignore-signing-information      Suppress a fatal error when signed\n\
+\                                        modular JARs are linked in the image.\n\
+\                                        The signature related files of the\n\
+\                                        signed modular JARs are not copied to\n\
+\                                        the runtime image.
 
 main.msg.bug=\
 An exception has occurred in jlink. \
@@ -75,13 +80,13 @@
 \List of available plugins:
 
 main.extended.help.footer=\
-\For options requiring a <pattern-list>, the value will be a comma\
-\ separated list of elements each using one the following forms:\n\
+\For options requiring a <pattern-list>, the value will be a comma separated\n\
+\list of elements each using one the following forms:\n\
 \  <glob-pattern>\n\
 \  glob:<glob-pattern>\n\
 \  regex:<regex-pattern>\n\
-\  @<filename> where filename is the name of a file containing patterns to be\
-\ used, one pattern per line\n\
+\  @<filename> where filename is the name of a file containing patterns to be\n\
+\              used, one pattern per line\n\
 \n\
 
 
@@ -110,6 +115,6 @@
 err.not.modular.format=selected module {0} ({1}) not in jmod or modular JAR format
 err.signing=signed modular JAR {0} is currently not supported,\
 \ use --ignore-signing-information to suppress error
-warn.signing=signed modular JAR {0} is currently not supported
+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}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Wed Jul 05 22:30:23 2017 +0200
@@ -132,32 +132,33 @@
 List of available plugin options:
 
 plugin.opt.list-plugins=\
-\  --list-plugins                    List available plugins
+\      --list-plugins                    List available plugins
 
 plugin.opt.post-process-path=\
-\  --post-process-path <imagefile>   Post process an existing image
+\      --post-process-path <imagefile>   Post process an existing image
 
 plugin.opt.resources-last-sorter=\
-\  --resources-last-sorter <name>    The last plugin allowed to sort resources
+\      --resources-last-sorter <name>    The last plugin allowed to sort\n\
+\                                        resources
 
 plugin.opt.plugin-module-path=\
-\  --plugin-module-path <modulepath> Custom plugin module path
+\      --plugin-module-path <modulepath> Custom plugin module path
 
 plugin.opt.disable-plugin=\
-\  --disable-plugin <pluginname>     Disable the plugin mentioned
+\      --disable-plugin <pluginname>     Disable the plugin mentioned
 
-plugin.opt.c=\
-\  -c, --compress=<0|1|2>            Enable compression of resources\
-\n                                    More details in --list-plugins option
+plugin.opt.compress=\
+\  -c, --compress=<0|1|2>                Enable compression of resources\n\
+\                                        More details in --list-plugins option
 
-plugin.opt.G=\
-\  -G, --strip-debug                 Strip debug information
+plugin.opt.strip-debug=\
+\  -G, --strip-debug                     Strip debug information
 
 plugin.opt.no-man-pages=\
-\  --no-man-pages                    Exclude man pages
+\      --no-man-pages                    Exclude man pages
 
 plugin.opt.no-header-files=\
-\  --no-header-files                 Exclude include header files
+\      --no-header-files                 Exclude include header files
 
 main.plugin.name=\
 \Plugin Name
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_de_GR.properties	Fri Nov 25 11:16:51 2016 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-# 
-# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  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.
-# 
-
-# (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
-# (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
-#
-# The original version of this source code and documentation
-# is copyrighted and owned by Taligent, Inc., a wholly-owned
-# subsidiary of IBM. These materials are provided under terms
-# of a License Agreement between Taligent and Sun. This technology
-# is protected by multiple US and International patents.
-#
-# This notice and attribution to Taligent may not be removed.
-# Taligent is a registered trademark of Taligent, Inc.
-
-EUR=\u20AC
-GRD=\u03B4\u03C1\u03C7
--- a/jdk/test/Makefile	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/Makefile	Wed Jul 05 22:30:23 2017 +0200
@@ -55,7 +55,7 @@
 UNAME     = uname
 UNIQ      = uniq
 WC        = wc
-ZIP       = zip
+ZIPEXE    = zip
 
 # Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
 UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
@@ -162,7 +162,7 @@
 ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`     \
 	           && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
 	           && $(CHMOD) -R a+r . \
-	           && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
+	           && $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . )
 
 # important results files
 SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
--- a/jdk/test/ProblemList.txt	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/ProblemList.txt	Wed Jul 05 22:30:23 2017 +0200
@@ -135,7 +135,7 @@
 java/lang/instrument/BootClassPath/BootClassPathTest.sh         8072130 macosx-all
 
 java/lang/management/MemoryMXBean/Pending.java                  8158837 generic-all
-java/lang/management/MemoryMXBean/PendingAllGC.sh               8158760 generic-all
+java/lang/management/MemoryMXBean/PendingAllGC.sh               8158837 generic-all
 
 ############################################################################
 
@@ -252,10 +252,14 @@
 
 # core_tools
 
-tools/pack200/CommandLineTests.java                             7143279,8059906 generic-all
+tools/pack200/CommandLineTests.java                             8059906 generic-all
 
 tools/launcher/FXLauncherTest.java                              8068049 linux-all,macosx-all
 
+tools/jimage/JImageExtractTest.java                             8169713 generic-all
+tools/jimage/JImageListTest.java                                8169713 generic-all
+tools/jimage/JImageVerifyTest.java                              8169713 generic-all
+
 ############################################################################
 
 # jdk_jdi
@@ -300,6 +304,6 @@
 
 # jdk_other
 
-com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java                   8141370 linux-i586,macosx-all
+com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java                   8169942 linux-i586,macosx-all,windows-x64
 
 ############################################################################
--- a/jdk/test/com/sun/jndi/dns/CheckAccess.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/com/sun/jndi/dns/CheckAccess.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,11 +24,13 @@
 /*
  * @test
  * @bug 6657619
+ * @modules jdk.naming.dns
  * @summary DnsContext.debug is public static mutable (findbugs)
  * @author Vincent Ryan
  */
 
-import java.lang.reflect.*;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 
 /*
  * Check that the 'debug' class member is no longer publicly accessible.
--- a/jdk/test/com/sun/jndi/dns/Test6991580.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/com/sun/jndi/dns/Test6991580.java	Wed Jul 05 22:30:23 2017 +0200
@@ -30,13 +30,14 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
-/**
+/*
  * @test
  * @bug 6991580 8080108 8133035
  * @requires os.family != "windows"
  * @summary IPv6 Nameservers in resolv.conf throws NumberFormatException
- * @modules jdk.naming.dns/com.sun.jndi.dns
- * @build IPv6NameserverPlatformParsingTest
+ * @modules java.desktop
+ *          jdk.naming.dns/com.sun.jndi.dns
+ * @compile --add-modules jdk.naming.dns IPv6NameserverPlatformParsingTest.java
  * @run main/manual Test6991580
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/jndi/ldap/TEST.properties	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,1 @@
+modules = java.naming
--- a/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
  *     successfully.
  * @modules java.rmi/sun.rmi.registry java.rmi/sun.rmi.server
  *     java.rmi/sun.rmi.transport java.rmi/sun.rmi.transport.tcp
+ *     jdk.naming.rmi
  * @library ../../../../../../java/rmi/testlibrary
  * @build TestLibrary
  * @run main UnbindIdempotent
@@ -49,8 +50,10 @@
 
         try {
             rctx = (Context)ictx.lookup("rmi://localhost:" + Integer.toString(registryPort));
+            System.out.println("Got context: " + rctx.getClass());
         } catch (NamingException e) {
             // Unable to set up for test.
+            System.err.println("WARNING: The test skipped due to NamingException: " + e);
             return;
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/nio/sctp/TEST.properties	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,2 @@
+modules = jdk.sctp
+
--- a/jdk/test/java/awt/FileDialog/FileDialogIconTest/FileDialogIconTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/awt/FileDialog/FileDialogIconTest/FileDialogIconTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -22,21 +22,28 @@
  */
 
 /* @test
- * @bug 8157163
+ * @bug 8157163 8159132
  * @summary AWT FileDialog does not inherit icon image from parent Frame
  * @requires os.family=="windows"
  * @run main FileDialogIconTest
  */
-import javax.swing.*;
-import java.awt.*;
+
+import java.awt.Color;
+import java.awt.Dialog;
+import java.awt.FileDialog;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Image;
 import java.awt.image.BufferedImage;
-import java.lang.reflect.InvocationTargetException;
+import javax.swing.SwingUtilities;
 
 public class FileDialogIconTest {
     private static Frame frame;
     private static Dialog dialog;
 
-    public static void main(final String[] args) throws InterruptedException, InvocationTargetException, AWTException {
+    public static void main(final String[] args) throws Exception {
         Robot robot;
         Point p;
         try {
@@ -51,9 +58,9 @@
             dialog.setModal(false);
             dialog.setVisible(true);
             robot.waitForIdle();
-            robot.delay(200);
+            robot.delay(1000);
 
-            p = new Point(10, 10);
+            p = new Point(20, 20);
             SwingUtilities.convertPointToScreen(p, dialog);
             Color color = robot.getPixelColor(p.x, p.y);
             if (!Color.RED.equals(color)) {
--- a/jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,237 +22,103 @@
  */
 
 /*
-  test
-  @bug       6386592
-  @summary   Tests that disposing a dialog doesn't activate its invisible owner.
-  @author    anton.tarasov@sun.com: area=awt.focus
-  @run       applet DisposeDialogNotActivateOwnerTest.html
+  @test
+  @key headful
+  @bug 6386592 8160766
+  @summary Tests that disposing a dialog doesn't activate its invisible owner.
 */
 
-import java.awt.*;
-import java.awt.event.*;
-import java.applet.Applet;
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.InputEvent;
 
-public class DisposeDialogNotActivateOwnerTest extends Applet {
+public class DisposeDialogNotActivateOwnerTest {
     Robot robot;
-
-    Frame frame = new Frame("Owner Frame");
-    Dialog dialog = new Dialog(new Frame(), "Owned Dialog");
-    Button frameButton = new Button("button");
-
-    static boolean passed = false;
+    Frame frame;
+    Frame dialogInvisibleOwner;
+    Dialog dialog;
+    Button frameButton;
+    static volatile boolean buttonReceivedFocus = false;
 
     public static void main(String[] args) {
-        DisposeDialogNotActivateOwnerTest app = new DisposeDialogNotActivateOwnerTest();
-        app.init();
-        app.start();
+        DisposeDialogNotActivateOwnerTest test =
+                new DisposeDialogNotActivateOwnerTest();
+        test.performTest();
+        test.dispose();
     }
 
-    public void init() {
+    public DisposeDialogNotActivateOwnerTest() {
         try {
             robot = new Robot();
         } catch (AWTException e) {
-            throw new RuntimeException("Error: unable to create robot", e);
+            throw new RuntimeException("Error: unable to create robot");
         }
-        // Create instructions for the user here, as well as set up
-        // the environment -- set the layout manager, add buttons,
-        // etc.
-        this.setLayout (new BorderLayout ());
-        Sysout.createDialogWithInstructions(new String[]
-            {"This is automatic test. Simply wait until it is done."
-            });
+
+        dialogInvisibleOwner = new Frame("Dialog Invisible Owner Frame");
+        dialog = new Dialog(dialogInvisibleOwner, "Owned Dialog");
 
-        frame.setBounds(800, 50, 200, 100);
+        frame = new Frame("A Frame");
+        frameButton = new Button("button");
+        frameButton.addFocusListener(new FocusAdapter() {
+            public void focusGained(FocusEvent e) {
+                buttonReceivedFocus = true;
+            }
+        });
+        frame.setBounds(0, 0, 400, 200);
         frame.add(frameButton);
-        dialog.setBounds(800, 300, 200, 100);
+        dialog.setBounds(100, 50, 200, 100);
     }
 
-    public void start() {
-
-        frameButton.addFocusListener(new FocusAdapter() {
-                public void focusGained(FocusEvent e) {
-                    passed = true;
-                }
-            });
-
+    public void performTest() {
         frame.setVisible(true);
         robot.waitForIdle();
-
-        // make sure the frame is focused
-        clickOn(frame);
+        clickOnTitle(frame);
+        robot.waitForIdle();
+        robot.delay(200);
         if (!frame.isFocused()) {
-            throw new RuntimeException("Error: a frame didn't get initial focus.");
+            dispose();
+            throw new RuntimeException("Error: frame didn't get initial focus");
         }
 
         dialog.setVisible(true);
         robot.waitForIdle();
-
-        // make sure the dialog is focused
+        robot.delay(200);
         if (!dialog.isFocused()) {
-            throw new RuntimeException("Error: a dialog didn't get initial focus.");
+            dispose();
+            throw new RuntimeException("Error: dialog didn't get initial focus");
         }
 
         dialog.dispose();
         robot.waitForIdle();
-
-        if (passed) {
-            Sysout.println("Test passed.");
-        } else {
-            throw new RuntimeException("Test failed: a dialog activates invisible owner when disposed!");
+        robot.delay(200);
+        if (!buttonReceivedFocus) {
+            dispose();
+            throw new RuntimeException(
+                "Test failed: Dialog activates invisible owner when disposed!");
         }
     }
 
-    void clickOn(Component c) {
+    public void dispose() {
+        frame.dispose();
+        dialog.dispose();
+        dialogInvisibleOwner.dispose();
+    }
+
+    void clickOnTitle(Component c) {
         Point p = c.getLocationOnScreen();
         Dimension d = c.getSize();
-
-        if (c instanceof Frame) {
-            robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2);
-        } else {
-            robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
-        }
-
+        robot.mouseMove(p.x + (int)(d.getWidth() / 2),
+                        p.y + ((Frame)c).getInsets().top / 2);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.delay(20);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-
-        robot.waitForIdle();
     }
 }
-
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
-  chunk of code whose purpose is to make user
-  interaction uniform, and thereby make it simpler
-  to read and understand someone else's test.
- ****************************************************/
-
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
-  for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
-  WithInstructions method.  Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
-  with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
-  as standalone.
- */
-
-class Sysout
-{
-    static TestDialog dialog;
-
-    public static void createDialogWithInstructions( String[] instructions )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        dialog.printInstructions( instructions );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
-    }
-
-    public static void createDialog( )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        String[] defInstr = { "Instructions will appear here. ", "" } ;
-        dialog.printInstructions( defInstr );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
-    }
-
-
-    public static void printInstructions( String[] instructions )
-    {
-        dialog.printInstructions( instructions );
-    }
-
-
-    public static void println( String messageIn )
-    {
-        dialog.displayMessage( messageIn );
-    }
-
-}// Sysout  class
-
-/**
-  This is part of the standard test machinery.  It provides a place for the
-   test instructions to be displayed, and a place for interactive messages
-   to the user to be displayed.
-  To have the test instructions displayed, see Sysout.
-  To have a message to the user be displayed, see Sysout.
-  Do not call anything in this dialog directly.
-  */
-class TestDialog extends Dialog
-{
-
-    TextArea instructionsText;
-    TextArea messageText;
-    int maxStringLength = 80;
-
-    //DO NOT call this directly, go through Sysout
-    public TestDialog( Frame frame, String name )
-    {
-        super( frame, name );
-        int scrollBoth = TextArea.SCROLLBARS_BOTH;
-        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
-        add( "North", instructionsText );
-
-        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
-        add("Center", messageText);
-
-        pack();
-
-        setVisible(true);
-    }// TestDialog()
-
-    //DO NOT call this directly, go through Sysout
-    public void printInstructions( String[] instructions )
-    {
-        //Clear out any current instructions
-        instructionsText.setText( "" );
-
-        //Go down array of instruction strings
-
-        String printStr, remainingStr;
-        for( int i=0; i < instructions.length; i++ )
-        {
-            //chop up each into pieces maxSringLength long
-            remainingStr = instructions[ i ];
-            while( remainingStr.length() > 0 )
-            {
-                //if longer than max then chop off first max chars to print
-                if( remainingStr.length() >= maxStringLength )
-                {
-                    //Try to chop on a word boundary
-                    int posOfSpace = remainingStr.
-                        lastIndexOf( ' ', maxStringLength - 1 );
-
-                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
-
-                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
-                    remainingStr = remainingStr.substring( posOfSpace + 1 );
-                }
-                //else just print
-                else
-                {
-                    printStr = remainingStr;
-                    remainingStr = "";
-                }
-
-                instructionsText.append( printStr + "\n" );
-
-            }// while
-
-        }// for
-
-    }//printInstructions()
-
-    //DO NOT call this directly, go through Sysout
-    public void displayMessage( String messageIn )
-    {
-        messageText.append( messageIn + "\n" );
-        System.out.println(messageIn);
-    }
-
-}// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.html	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,40 @@
+<!--
+Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 only, as
+published by the Free Software Foundation.
+
+This code is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+version 2 for more details (a copy is included in the LICENSE file that
+accompanied this code).
+
+You should have received a copy of the GNU General Public License version
+2 along with this work; if not, write to the Free Software Foundation,
+Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+or visit www.oracle.com if you need additional information or have any
+questions.
+-->
+
+<html>
+<head>
+<title> SpanishDiacriticsTest </title>
+</head>
+<body>
+<applet code="SpanishDiacriticsTest.class" width=350 height=200></applet>
+
+Test run requires the following keyboard layout to be installed:
+Windows OS: Spanish (United States) with 'Latin American' keyboard layout
+
+1. A frame with a text field should be displayed at upper left corner
+2. Set focus to the text field and switch to Spanish with 'Latin American' keyboard layout
+3. Type the following: ' ' o - i.e. single quote two times (using [ key on US keyboard) then o character.
+
+If you the text field displays ''o, (i.e. o should be without acute) then the test is passed; otherwise failed.
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/InputMethods/SpanishDiacriticsTest/SpanishDiacriticsTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8169355
+ * @summary Check if Spanish diacritical signs could be typed for TextField
+ * @author Dmitry Markov
+ * @run applet/manual=yesno SpanishDiacriticsTest.html
+*/
+
+import javax.swing.*;
+import java.applet.Applet;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.util.concurrent.locks.LockSupport;
+
+public class SpanishDiacriticsTest extends Applet {
+    @Override
+    public void init() {
+        SwingUtilities.invokeLater(() -> {
+            JFrame frame = new JFrame();
+            JTextField textField = new JTextField(20);
+            textField.addKeyListener(new KeyAdapter() {
+                @Override
+                public void keyTyped(KeyEvent e) {
+                    LockSupport.parkNanos(1_000_000_000L);
+                }
+            });
+            frame.add(textField);
+            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+            frame.pack();
+            frame.setVisible(true);
+        });
+    }
+}
+
--- a/jdk/test/java/awt/KeyboardFocusmanager/DefaultPolicyChange/DefaultPolicyChange_Swing.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/awt/KeyboardFocusmanager/DefaultPolicyChange/DefaultPolicyChange_Swing.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,32 +23,25 @@
 
 /*
   @test
-  @bug 6741526
+  @bug 6741526 8004693
   @summary KeyboardFocusManager.setDefaultFocusTraversalPolicy(FocusTraversalPolicy) affects created components
-  @library ../../regtesthelpers
-  @build Sysout
   @author Andrei Dmitriev : area=awt-focus
   @run main DefaultPolicyChange_Swing
 */
 
 import java.awt.*;
+
 import javax.swing.*;
 import javax.swing.table.DefaultTableModel;
-import test.java.awt.regtesthelpers.Sysout;
 
 public class DefaultPolicyChange_Swing {
-    public static void main(String []s) {
-        EventQueue.invokeLater(new Runnable(){
-            public void run (){
-                DefaultPolicyChange_Swing.runTestSwing();
-            }
-        });
+
+    public static void main(final String[] s) throws Exception {
+        EventQueue.invokeAndWait(DefaultPolicyChange_Swing::runTestSwing);
     }
+
     private static void runTestSwing(){
         KeyboardFocusManager currentKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
-        FocusTraversalPolicy defaultFTP = currentKFM.getDefaultFocusTraversalPolicy();
-        ContainerOrderFocusTraversalPolicy newFTP = new ContainerOrderFocusTraversalPolicy();
-
 
         JFrame jf = new JFrame("Test1");
         JWindow jw = new JWindow(jf);
@@ -71,22 +64,35 @@
             throw new RuntimeException("Failure! Swing toplevel must have LayoutFocusTraversalPolicy installed");
         }
 
+        FocusTraversalPolicy[] defaultFTP = {
+                jf.getFocusTraversalPolicy(), jw.getFocusTraversalPolicy(),
+                jd.getFocusTraversalPolicy()
+        };
+
         jf.setVisible(true);
 
         System.out.println("Now will set another policy.");
+        ContainerOrderFocusTraversalPolicy newFTP = new ContainerOrderFocusTraversalPolicy();
         currentKFM.setDefaultFocusTraversalPolicy(newFTP);
 
-        FocusTraversalPolicy resultFTP = jw.getFocusTraversalPolicy();
+        FocusTraversalPolicy[] resultFTP = {
+                jf.getFocusTraversalPolicy(), jw.getFocusTraversalPolicy(),
+                jd.getFocusTraversalPolicy()
+        };
 
         System.out.println("FTP current on jf= " + jf.getFocusTraversalPolicy());
         System.out.println("FTP current on jw= " + jw.getFocusTraversalPolicy());
         System.out.println("FTP current on jd= " + jd.getFocusTraversalPolicy());
 
-        if (!resultFTP.equals(defaultFTP)) {
-            Sysout.println("Failure! FocusTraversalPolicy should not change");
-            Sysout.println("Was: " + defaultFTP);
-            Sysout.println("Become: " + resultFTP);
-            throw new RuntimeException("Failure! FocusTraversalPolicy should not change");
+        jf.dispose();
+
+        for (int i=0; i < 3; i++) {
+            if (!resultFTP[i].equals(defaultFTP[i])) {
+                System.out.println("Failure! FocusTraversalPolicy should not change");
+                System.out.println("Was: " + defaultFTP[i]);
+                System.out.println("Become: " + resultFTP[i]);
+                throw new RuntimeException("Failure! FocusTraversalPolicy should not change");
+            }
         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/OpaquePNGToGIFTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,422 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+ /*
+ * @test
+ * @bug     6334602
+ * @summary Test verifies that when we create GIF image from Opaque PNG images
+ *          it should not be transparent.
+ * @modules java.desktop/com.sun.imageio.plugins.gif
+ * @run     main/manual OpaquePNGToGIFTest
+ */
+
+import java.awt.image.BufferedImage;
+import com.sun.imageio.plugins.gif.GIFImageMetadata;
+import java.awt.Canvas;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+public final class OpaquePNGToGIFTest extends Frame {
+
+    Image img = null;
+    private Dimension prefImgSize = new Dimension(100, 100);
+    private Color canvasColor = new Color(0, 255, 0);
+    File outputFile = null;
+    ImageCanvas imageCanvas = new ImageCanvas();
+    FileOutputStream fos;
+    private static GridBagLayout layout;
+    private static JPanel mainControlPanel;
+    private static JPanel resultButtonPanel;
+    private static JPanel canvasPanel;
+    private static JLabel instructionText;
+    private static JButton startTestButton;
+    private static JButton passButton;
+    private static JButton failButton;
+    private static JDialog dialog;
+    private static Frame instructionFrame;
+    private static Frame imageFrame;
+    Toolkit tk;
+    ImageWriter writer = null;
+    boolean testPassed, testGeneratedInterrupt, startButtonClicked;
+    private static Thread mainThread;
+
+    public OpaquePNGToGIFTest() throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            try {
+                startTest();
+            } catch (Exception ex) {
+                Logger.getLogger(OpaquePNGToGIFTest.class.getName()).
+                        log(Level.SEVERE, null, ex);
+            }
+        });
+        mainThread = Thread.currentThread();
+        try {
+            Thread.sleep(60000);
+        } catch (InterruptedException e) {
+            if (!testPassed && testGeneratedInterrupt) {
+                throw new RuntimeException("Test failed or didnt run"
+                        + " properly");
+            }
+        }
+        if (!testGeneratedInterrupt) {
+            if (img != null) {
+                img.flush();
+            }
+            instructionFrame.dispose();
+            if (startButtonClicked) {
+                imageFrame.dispose();
+            }
+            fos.close();
+            Files.delete(outputFile.toPath());
+            throw new RuntimeException("user has not executed the test");
+        }
+    }
+
+    public void startTest() throws Exception {
+        instructionFrame = new Frame();
+        dialog = new JDialog(instructionFrame);
+        dialog.setTitle("Instruction Dialog");
+        layout = new GridBagLayout();
+        mainControlPanel = new JPanel(layout);
+        resultButtonPanel = new JPanel(layout);
+        canvasPanel = new JPanel();
+        GridBagConstraints gbc = new GridBagConstraints();
+        String instructions
+                = "<html>    INSTRUCTIONS:<br><br>"
+                + "After clicking on Start Test button you will see Red<br> "
+                + " circle drawn with light blue background, if the circle<br>"
+                + " color changes from Red to Green then press button Fail,<br>"
+                + " if it stays Red then press button Pass.<br><br></html>";
+        instructionText = new JLabel();
+        instructionText.setText(instructions);
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(instructionText, gbc);
+        startTestButton = new JButton("Start Test");
+        startTestButton.setActionCommand("Start Test");
+        startTestButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                try {
+                    startButtonClicked = true;
+                    imageFrame = new Frame();
+
+                    Iterator it = ImageIO.getImageWritersByFormatName("GIF");
+                    while (it.hasNext()) {
+                        writer = (ImageWriter) it.next();
+                        break;
+                    }
+                    // read input opaque PNG image.
+                    String fileName = "opaque_input.png";
+                    String sep = System.getProperty("file.separator");
+                    String dir = System.getProperty("test.src", ".");
+                    System.out.println(dir + "     " + sep);
+                    String filePath = dir + sep + fileName;
+                    File inputFile = new File(filePath);
+                    ImageInputStream iis = ImageIO.
+                            createImageInputStream(inputFile);
+                    ImageReader reader = null;
+                    Iterator readerIter = ImageIO.getImageReaders(iis);
+                    while (readerIter.hasNext()) {
+                        reader = (ImageReader) readerIter.next();
+                        break;
+                    }
+
+                    reader.setInput(iis);
+                    IIOMetadata imgData = reader.getImageMetadata(0);
+                    BufferedImage bi = reader.read(0);
+
+                    //create temporary GIF imageas output
+                    File directory = new File(dir + sep);
+                    outputFile = File.createTempFile("output",
+                            ".gif", directory);
+                    createAnimatedImage(bi, imgData,
+                            writer, outputFile);
+                    writer.dispose();
+                    iis.close();
+                    if (outputFile == null) {
+                        throw new RuntimeException("Unable to create output GIF"
+                                + " file");
+                    }
+                    // extract GIF image using Toolkit and show it on a Panel.
+                    tk = Toolkit.getDefaultToolkit();
+                    img = tk.getImage(dir + sep + outputFile.getName());
+                    directory.delete();
+                    imageCanvas.setBackground(canvasColor);
+                    imageCanvas.setImage(img);
+                    imageCanvas.setPreferredSize(prefImgSize);
+                    canvasPanel.doLayout();
+
+                    canvasPanel.add(imageCanvas);
+                    imageFrame.add("Center", canvasPanel);
+                    imageFrame.setSize(200, 200);
+                    imageFrame.setVisible(true);
+                    imageFrame.addWindowListener(new WindowAdapter() {
+                        @Override
+                        public void windowClosing(WindowEvent e) {
+                            try {
+                                img.flush();
+                                instructionFrame.dispose();
+                                imageFrame.dispose();
+                                fail();
+                            } finally {
+                                try {
+                                    fos.close();
+                                    Files.delete(outputFile.toPath());
+                                } catch (IOException ex) {
+                                    Logger.getLogger(OpaquePNGToGIFTest.class.
+                                            getName()).log(Level.SEVERE, null,
+                                                    ex);
+                                }
+                            }
+                        }
+                    });
+                } catch (IOException ex) {
+                    Logger.getLogger(OpaquePNGToGIFTest.class.getName()).
+                            log(Level.SEVERE, null, ex);
+                }
+            }
+        });
+        passButton = new JButton("Pass");
+        passButton.setActionCommand("Pass");
+        passButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                try {
+                    if (img != null) {
+                        img.flush();
+                    }
+                    instructionFrame.dispose();
+                    if (!startButtonClicked) {
+                        fail();
+                    } else {
+                        imageFrame.dispose();
+                        pass();
+                    }
+                } finally {
+                    try {
+                        fos.close();
+                        Files.delete(outputFile.toPath());
+                    } catch (IOException ex) {
+                        Logger.getLogger(OpaquePNGToGIFTest.class.
+                                getName()).log(Level.SEVERE, null, ex);
+                    }
+                }
+            }
+        });
+        failButton = new JButton("Fail");
+        failButton.setActionCommand("Fail");
+        failButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                try {
+                    if (img != null) {
+                        img.flush();
+                    }
+                    instructionFrame.dispose();
+                    if (!startButtonClicked) {
+                        fail();
+                    } else {
+                        imageFrame.dispose();
+                        fail();
+                    }
+                } finally {
+                    try {
+                        fos.close();
+                        Files.delete(outputFile.toPath());
+                    } catch (IOException ex) {
+                        Logger.getLogger(OpaquePNGToGIFTest.class.
+                                getName()).log(Level.SEVERE, null, ex);
+                    }
+                }
+            }
+        });
+        gbc.gridx = 1;
+        gbc.gridy = 0;
+        resultButtonPanel.add(startTestButton, gbc);
+        gbc.gridx = 2;
+        gbc.gridy = 0;
+        resultButtonPanel.add(passButton, gbc);
+        gbc.gridx = 3;
+        gbc.gridy = 0;
+        resultButtonPanel.add(failButton, gbc);
+
+        gbc.gridx = 0;
+        gbc.gridy = 1;
+        mainControlPanel.add(resultButtonPanel, gbc);
+
+        dialog.add(mainControlPanel);
+        dialog.setSize(400, 200);
+        dialog.setLocationRelativeTo(null);
+        dialog.setVisible(true);
+
+        dialog.addWindowListener(new WindowAdapter() {
+            @Override
+            public void windowClosing(WindowEvent e) {
+                try {
+                    if (img != null) {
+                        img.flush();
+                    }
+                    instructionFrame.dispose();
+                    if (!startButtonClicked) {
+                        fail();
+                    } else {
+                        imageFrame.dispose();
+                        fail();
+                    }
+                } finally {
+                    try {
+                        fos.close();
+                        Files.delete(outputFile.toPath());
+                    } catch (IOException ex) {
+                        Logger.getLogger(OpaquePNGToGIFTest.class.
+                                getName()).log(Level.SEVERE, null, ex);
+                    }
+                }
+            }
+        });
+    }
+
+    public synchronized void pass() {
+        testPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public synchronized void fail() {
+        testPassed = false;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public void createAnimatedImage(BufferedImage bi, IIOMetadata metadata,
+            ImageWriter writer, File outputFile) {
+        try {
+
+            fos = new FileOutputStream(outputFile);
+            ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
+            System.out.println(ios);
+            writer.setOutput(ios);
+
+            ImageWriteParam param = writer.getDefaultWriteParam();
+            IIOMetadata streamData = writer.getDefaultStreamMetadata(param);
+
+            writer.prepareWriteSequence(streamData);
+            ImageTypeSpecifier specify = new ImageTypeSpecifier(bi);
+            IIOMetadata imgData = writer.convertImageMetadata(
+                    (IIOMetadata) metadata, specify, param);
+            GIFImageMetadata gifData = setAnimationProperties(imgData);
+            IIOImage iim = new IIOImage(bi, null, gifData);
+            param.setProgressiveMode(param.MODE_DISABLED);
+            writer.writeToSequence(iim, param);
+            writer.endWriteSequence();
+            ios.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public GIFImageMetadata setAnimationProperties(IIOMetadata data) {
+        ArrayList appIDs = new ArrayList();
+        appIDs.add(new String("NETSCAPE").getBytes());
+        ArrayList authCodes = new ArrayList();
+        authCodes.add(new String("2.0").getBytes());
+        ArrayList appData = new ArrayList();
+        byte[] authData = {1, 0, 0};
+        appData.add(authData);
+
+        GIFImageMetadata gifData = (GIFImageMetadata) data;
+        gifData.delayTime = 200;
+        // If we set disposalMethod to 2 then only the issue is reproduced.
+        gifData.disposalMethod = 2;
+        gifData.userInputFlag = false;
+
+        gifData.applicationIDs = appIDs;
+        gifData.authenticationCodes = authCodes;
+        gifData.applicationData = appData;
+
+        return gifData;
+    }
+
+    public static void main(String args[]) throws Exception {
+        OpaquePNGToGIFTest test = new OpaquePNGToGIFTest();
+    }
+
+    class ImageCanvas extends Canvas {
+
+        Image im = null;
+
+        public void setImage(Image img) {
+            im = img;
+        }
+
+        public void clearImage() {
+            im = null;
+            repaint();
+        }
+
+        public void paint(Graphics g) {
+            Graphics2D g2d = (Graphics2D) g;
+
+            if (im != null) {
+                g2d.drawImage(im, 1, 1, getWidth(), getHeight(), this);
+            }
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/VolatileImage/VolatileImageConfigurationTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8165212
+ * @summary This manual test case displays scale values of Graphics and the
+ *          underlying device configuration. Any change to host display's DPI
+ *          value should reflect corresponding changes in the scale values
+ *          of both Frame and Backbuffer (VolatileImage).
+ * @run main/othervm/manual -Dsun.java2d.d3d=false -Dsun.java2d.opengl=false VolatileImageConfigurationTest
+ */
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.geom.AffineTransform;
+import java.awt.image.VolatileImage;
+import java.awt.HeadlessException;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JButton;
+import javax.swing.SwingUtilities;
+
+public class VolatileImageConfigurationTest
+        extends JFrame
+        implements ActionListener {
+    /* Test frame and completion status */
+    private static JFrame testFrame;
+    private static volatile boolean testComplete = false;
+    private static volatile boolean testResult = false;
+
+    /* Main frame's dimensions */
+    private static final int TEST_WIDTH = 600;
+    private static final int TEST_HEIGHT = 600;
+    private static final int TEST_MIN_DURATION = 3000;
+    private static final int TEST_TOTAL_DURATION = 45000;
+
+    /*
+     * Frame will display information text explaining how to run the manual
+     * test, and two buttons- Pass and Fail to determine the end-result.
+     */
+    private JTextArea infoTextArea;
+    private JPanel buttonPanel;
+    private JPanel testPanel;
+    private JButton passButton;
+    private JButton failButton;
+
+    public VolatileImageConfigurationTest() {
+        /* Default constructor. Initialize the UI components */
+        super("Volatile Image Configuration Update Test");
+        initComponents();
+    }
+
+    private void initComponents() {
+        /* Create the text area with steps to execute the test */
+        String description
+                = "\n Volatile Image Configuration Update Test.\n"
+                + " 1. The test displays scale values of component and the"
+                + " underlying graphics device configuration.\n"
+                + " 2. Kindly change the display's DPI settings from OS"
+                + " control panel and observe the application.\n"
+                + " 3. Select Pass if the scale values for both component & "
+                + "underlying device configuration are updated as per the "
+                + "\ndisplay's DPI value.\n";
+        infoTextArea = new JTextArea(description);
+
+        /* Create the test panel where user will observe the drawing */
+        testPanel = new DisplayPanel();
+
+        /* Create the buttons with event listeners */
+        passButton = new JButton("Pass");
+        passButton.setActionCommand("Pass");
+        passButton.setEnabled(true);
+        passButton.addActionListener(this);
+
+        failButton = new JButton("Fail");
+        failButton.setActionCommand("Fail");
+        failButton.setEnabled(true);
+        failButton.addActionListener(this);
+
+        /* Add the buttons to a separate panel with flowlayout */
+        buttonPanel = new JPanel(new FlowLayout());
+        buttonPanel.add(passButton);
+        buttonPanel.add(failButton);
+
+        /* Add all the created components to the master frame */
+        setLayout(new BorderLayout(10, 10));
+        add(infoTextArea, BorderLayout.NORTH);
+        add(buttonPanel, BorderLayout.SOUTH);
+        add(testPanel, BorderLayout.CENTER);
+
+        /* Set the dimensions */
+        setSize(TEST_WIDTH, TEST_HEIGHT);
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        /* Button event listener */
+        String command = e.getActionCommand();
+
+        if (command.equals("Pass")) {
+            /* Test has passed. Dispose the frame with success message */
+            testComplete = true;
+            testResult = true;
+            System.out.println("Test Passed.");
+        } else if (command.equals("Fail")) {
+            /* Test has failed. Dispose the frame and throw exception */
+            testComplete = true;
+            testResult = false;
+        }
+    }
+
+    private static void constructTestUI() {
+        /* Construct the test's user interface */
+        testFrame = new VolatileImageConfigurationTest();
+        testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        testFrame.setLocationRelativeTo(null);
+        testFrame.setVisible(true);
+    }
+
+    private static void destructTestUI() {
+        /* Destroy the test's user interface */
+        testFrame.dispose();
+    }
+
+    static class DisplayPanel extends JPanel {
+        /* Display panel settings */
+        private static final int PANEL_WIDTH = 600;
+        private static final int PANEL_HEIGHT = 500;
+        private static final int PANEL_X = 20;
+        private static final int PANEL_Y = 80;
+        private static final String MSG = "%s scale: [%2.2f, %2.2f]";
+        private VolatileImage vImg;
+
+        public DisplayPanel() throws HeadlessException {
+            setSize(PANEL_WIDTH, PANEL_HEIGHT);
+        }
+
+        @Override
+        public void paint(Graphics g) {
+            super.paint(g);
+
+            g.setColor(Color.WHITE);
+            g.fillRect(0, 0, PANEL_WIDTH, PANEL_HEIGHT);
+            /* Display graphics configuration values of the component */
+            drawInfo(g, PANEL_X, PANEL_Y, "Frame", Color.BLUE);
+            int attempts = 0;
+            do {
+                /* Display graphics configuration values of volatile image */
+                drawBackingStoreImage(g);
+            } while (vImg.contentsLost() && ++attempts < 3);
+        }
+
+        private void drawInfo(Graphics g, int x, int y,
+                String msg, Color color) {
+            g.setColor(color);
+            g.setFont(g.getFont().deriveFont(24f));
+            Graphics2D g2d = (Graphics2D) g;
+            AffineTransform tx = g2d.getTransform();
+
+            g.drawString(msg, x, y);
+            String text = String.format(MSG,
+                                        "Graphics",
+                                        tx.getScaleX(),
+                                        tx.getScaleY());
+            int dy = 20;
+            g.drawString(text, x, y + dy);
+
+            tx = g2d.getDeviceConfiguration().getDefaultTransform();
+            text = String.format(MSG,
+                                 "Device Config",
+                                 tx.getScaleX(),
+                                 tx.getScaleY());
+            g.drawString(text, x, y + 2 * dy);
+        }
+
+        private void drawBackingStoreImage(Graphics g) {
+            Graphics2D g2d = (Graphics2D) g;
+            GraphicsConfiguration gc = g2d.getDeviceConfiguration();
+            if (vImg == null ||
+                vImg.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) {
+                /* Create a new volatile image */
+                vImg = createVolatileImage(PANEL_WIDTH, PANEL_HEIGHT / 3);
+            }
+
+            Graphics vImgGraphics = vImg.createGraphics();
+            vImgGraphics.setColor(Color.WHITE);
+            vImgGraphics.fillRect(0, 0, PANEL_WIDTH, PANEL_HEIGHT / 3);
+            drawInfo(vImgGraphics,
+                     PANEL_X,
+                     PANEL_Y,
+                     "Backbuffer",
+                     Color.MAGENTA);
+            g.drawImage(vImg, 0, PANEL_Y * 2, this);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    /* Construct the test interface */
+                    constructTestUI();
+                } catch (Exception ex) {
+                    /* Throw an exception indicating error while creating UI */
+                    throw new RuntimeException("Test Failed. Error while "
+                            + "creating the test interface.");
+                }
+            }
+        });
+
+        try {
+            /* Provide sufficient time for user to act upon the manual test */
+            long totalWaitDuration = 0;
+            do {
+                Thread.sleep(TEST_MIN_DURATION);
+                totalWaitDuration += TEST_MIN_DURATION;
+            } while (!testComplete && totalWaitDuration < TEST_TOTAL_DURATION);
+        } catch(InterruptedException ite) {
+            /* No-op. The thread continues execution further */
+        }
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    /* Destroy the test interface */
+                    destructTestUI();
+                } catch (Exception ex) {
+                    /* No-op */
+                }
+            }
+        });
+
+        /* Check for the test result and throw exception if required */
+        if (testResult == false) {
+            throw new RuntimeException("Test Failed. Incorrect scale values "
+                + "were seen during the test execution.");
+        }
+    }
+}
\ No newline at end of file
--- a/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/MultiResIconTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/MultiResIconTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -24,9 +24,10 @@
 /**
  * @test
  * @key headful
- * @bug 8149371
+ * @bug 8149371 8169043
  * @summary multi-res. image: -Dsun.java2d.uiScale does not work for Window
  * icons (some ambiguity for Window.setIconImages()?)
+ * @requires (os.family == "windows")
  * @run main/othervm/manual -Dsun.java2d.uiScale=2 MultiResIconTest
  */
 import java.awt.Color;
@@ -58,6 +59,7 @@
     private static JDialog f;
     private static CountDownLatch latch;
     private static TestFrame frame;
+    private static boolean testPassed;
 
     private static BufferedImage generateImage(int x, Color c) {
 
@@ -70,12 +72,13 @@
         return img;
     }
 
-    public MultiResIconTest() {
-        try {
-            latch = new CountDownLatch(1);
-            createUI();
-            latch.await();
-        } catch (Exception ex) {
+    public MultiResIconTest() throws Exception {
+        latch = new CountDownLatch(1);
+        createUI();
+        latch.await();
+
+        if (!testPassed) {
+            throw new RuntimeException("User Pressed Failed Button");
         }
     }
 
@@ -89,7 +92,10 @@
             resultButtonPanel = new JPanel(layout);
             GridBagConstraints gbc = new GridBagConstraints();
             String instructions
-                    = "<html>    INSTRUCTIONS:<br><br>"
+                    = "<html>    INSTRUCTIONS:<br>"
+                    + "This test is for Windows OS only.<br>"
+                    + "Make sure that 'Use Small Icons' setting is not set<br>"
+                    + "on Windows Taskbar Properties <br>"
                     + "1) Test frame title icon and frame color should be green."
                     + "<br>"
                     + "2) Test frame task bar icon should be blue<br>"
@@ -106,6 +112,7 @@
             passButton = new JButton("Pass");
             passButton.setActionCommand("Pass");
             passButton.addActionListener((ActionEvent e) -> {
+                testPassed = true;
                 latch.countDown();
                 f.dispose();
                 frame.dispose();
@@ -115,6 +122,7 @@
             failButton.addActionListener(new ActionListener() {
                 @Override
                 public void actionPerformed(ActionEvent e) {
+                    testPassed = false;
                     latch.countDown();
                     f.dispose();
                     frame.dispose();
@@ -140,6 +148,7 @@
             f.addWindowListener(new WindowAdapter() {
                 @Override
                 public void windowClosing(WindowEvent e) {
+                    testPassed = false;
                     latch.countDown();
                     f.dispose();
                     frame.dispose();
@@ -191,7 +200,7 @@
         }
     }
 
-    public static void main(String[] args) {
+    public static void main(String[] args) throws Exception {
         new MultiResIconTest();
     }
 }
Binary file jdk/test/java/awt/image/opaque_input.png has changed
--- a/jdk/test/java/awt/print/PrinterJob/Margins.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/awt/print/PrinterJob/Margins.java	Wed Jul 05 22:30:23 2017 +0200
@@ -23,12 +23,12 @@
 
 /**
  * @test
- * @bug 6543815 6601097
+ * @bug 6543815 6601097 8160888
  * @summary Image should be sent to printer, no exceptions thrown.
  *    The 3 printouts should have a rectangle which is the minimum
  *    possible margins ie, the margins should be hardware margins
  *    and not java default 1 inch margins.
- * @run main/manual Margins
+ * @run main Margins
  */
 
 import java.awt.print.PrinterJob;
@@ -39,16 +39,36 @@
 import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.Color;
+import java.awt.Robot;
+import java.awt.event.KeyEvent;
 
 public class Margins implements Printable {
 
-    public static void main(String args[]) {
+    public static void main(String args[]) throws Exception {
+        Robot robot = new Robot();
+        Thread t = new Thread (() -> {
+            robot.waitForIdle();
+            robot.delay(5000);
+            robot.keyPress(KeyEvent.VK_ENTER);
+            robot.keyRelease(KeyEvent.VK_ENTER);
+            robot.waitForIdle();
+            robot.delay(5000);
+            robot.keyPress(KeyEvent.VK_ENTER);
+            robot.keyRelease(KeyEvent.VK_ENTER);
+            robot.waitForIdle();
+            robot.delay(5000);
+            robot.keyPress(KeyEvent.VK_ENTER);
+            robot.keyRelease(KeyEvent.VK_ENTER);
+        });
+
         PrinterJob job = PrinterJob.getPrinterJob();
         PageFormat pageFormat = job.defaultPage();
         Paper paper = pageFormat.getPaper();
         double wid = paper.getWidth();
         double hgt = paper.getHeight();
         paper.setImageableArea(0, -10, wid, hgt);
+        t.start();
+
         pageFormat = job.pageDialog(pageFormat);
         pageFormat.setPaper(paper);
         job.setPrintable(new Margins(), pageFormat);
@@ -57,7 +77,7 @@
         } catch (PrinterException e) {
         }
 
-        paper.setImageableArea(0, 0, wid, hgt+72);
+        paper.setImageableArea(0, 0, wid, hgt + 72);
         pageFormat = job.pageDialog(pageFormat);
         pageFormat.setPaper(paper);
 
@@ -100,12 +120,13 @@
 
 
        Paper paper = pf.getPaper();
-       double wid = paper.getWidth();
-       double hgt = paper.getHeight();
-
-       /* If imageable width/height is -ve, then print was done with 1" margin
-        * ie ix=72 iy=72 iw=451 ih=697 and wid=595
-        * but with fix, we get print with hardware margin ie
+       int wid = (int)paper.getWidth();
+       int hgt = (int)paper.getHeight();
+       System.out.println("wid="+wid+" hgt="+hgt);
+       /*
+        * If imageable width/height is -ve, then print was done with 1" margin
+        * e.g. ix=72 iy=72 iw=451 ih=697 and paper wid=595
+        * but with fix, we get print with hardware margin e.g.
         * ix=12, iy=12, iw=571, ih=817
         */
        if ((wid - iw > 72) || (hgt - ih > 72)) {
@@ -115,6 +136,12 @@
            throw new RuntimeException("Printable width or height "
                    + "exceeds paper width or height.");
        }
+       // runtime checking to see if the margins/printable area
+       // correspond to the entire size of the paper, for now, make it pass
+       // as for linux, the hwmargin is not taken into account - bug6574279
+       if (ix == 0 && iy == 0 && (ix+iw == wid) && (iy+ih == hgt)) {
+           return PAGE_EXISTS;
+       }
 
        Graphics2D g2d = (Graphics2D)g;
        g2d.translate(ix, iy);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/TexturePaintPrintingTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8040635
+ * @summary  Verifies if TexturePaint is printed in osx
+ * @run main/manual TexturePaintPrintingTest
+ */
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.TexturePaint;
+import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import static java.awt.print.Printable.NO_SUCH_PAGE;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+
+public class TexturePaintPrintingTest extends Component implements Printable {
+    private static void printTexture() {
+        f = new JFrame("Texture Printing Test");
+        f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+        final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
+        Container c = f.getContentPane();
+        c.add(BorderLayout.CENTER, gpt);
+
+        final JButton print = new JButton("Print");
+        print.addActionListener(new AbstractAction() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                PrinterJob job = PrinterJob.getPrinterJob();
+                job.setPrintable(gpt);
+                final boolean doPrint = job.printDialog();
+                if (doPrint) {
+                    try {
+                        job.print();
+                    } catch (PrinterException ex) {
+                        throw new RuntimeException(ex);
+                    }
+                }
+            }
+        });
+        c.add(print, BorderLayout.SOUTH);
+
+        f.pack();
+        f.setVisible(true);
+    }
+
+    public Dimension getPreferredSize() {
+        return new Dimension(500,500);
+    }
+
+    public void paint(Graphics g) {
+        doPaint((Graphics2D)g);
+    }
+
+    public int print( Graphics graphics, PageFormat format, int index ) {
+        Graphics2D g2d = (Graphics2D)graphics;
+        g2d.translate(format.getImageableX(), format.getImageableY());
+        doPaint(g2d);
+        return index == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
+    }
+
+    static final float DIM = 100;
+    public void doPaint(Graphics2D g2d) {
+        BufferedImage patternImage = new BufferedImage(2,2,BufferedImage.TYPE_INT_ARGB);
+        Graphics gImage = patternImage.getGraphics();
+        gImage.setColor(Color.WHITE);
+        gImage.drawLine(0,1,1,0);
+        gImage.setColor(Color.BLACK);
+        gImage.drawLine(0,0,1,1);
+        gImage.dispose();
+
+        Rectangle2D.Double shape = new Rectangle2D.Double(0,0,DIM*6/5, DIM*8/5);
+        g2d.setPaint(new TexturePaint(patternImage, new Rectangle2D.Double(0,0,
+                     DIM*6/50, DIM*8/50)));
+        g2d.fill(shape);
+        g2d.setPaint(Color.BLACK);
+        g2d.draw(shape);
+    }
+
+    public static synchronized void pass() {
+        testPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public static synchronized void fail() {
+        testPassed = false;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    private static Thread mainThread;
+    private static boolean testPassed;
+    private static boolean testGeneratedInterrupt;
+    private static JFrame f = null;
+
+    public static void main(String[] args) {
+        SwingUtilities.invokeLater(new Runnable() {
+            @Override
+            public void run() {
+                //createUI();
+                doTest(TexturePaintPrintingTest::printTexture);
+            }
+        });
+        mainThread = Thread.currentThread();
+        try {
+            Thread.sleep(120000);
+        } catch (InterruptedException e) {
+            if (!testPassed && testGeneratedInterrupt) {
+                throw new RuntimeException("TexturePaint did not print");
+            }
+        }
+        if (!testGeneratedInterrupt) {
+            throw new RuntimeException("user has not executed the test");
+        }
+    }
+
+    private static void doTest(Runnable action) {
+        String description
+                = " A TexturePaint graphics will be shown on console.\n"
+                + " The same graphics is sent to printer.\n"
+                + " Please verify if TexturePaint shading is printed.\n"
+                + " If none is printed, press FAIL else press PASS";
+
+        final JDialog dialog = new JDialog();
+        dialog.setTitle("printSelectionTest");
+        JTextArea textArea = new JTextArea(description);
+        textArea.setEditable(false);
+        final JButton testButton = new JButton("Start Test");
+        final JButton passButton = new JButton("PASS");
+        passButton.setEnabled(false);
+        passButton.addActionListener((e) -> {
+            f.dispose();
+            dialog.dispose();
+            pass();
+        });
+        final JButton failButton = new JButton("FAIL");
+        failButton.setEnabled(false);
+        failButton.addActionListener((e) -> {
+            f.dispose();
+            dialog.dispose();
+            fail();
+        });
+        testButton.addActionListener((e) -> {
+            testButton.setEnabled(false);
+            action.run();
+            passButton.setEnabled(true);
+            failButton.setEnabled(true);
+        });
+        JPanel mainPanel = new JPanel(new BorderLayout());
+        mainPanel.add(textArea, BorderLayout.CENTER);
+        JPanel buttonPanel = new JPanel(new FlowLayout());
+        buttonPanel.add(testButton);
+        buttonPanel.add(passButton);
+        buttonPanel.add(failButton);
+        mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+        dialog.add(mainPanel);
+
+        dialog.pack();
+        dialog.setVisible(true);
+        dialog.addWindowListener(new WindowAdapter() {
+           @Override
+            public void windowClosing(WindowEvent e) {
+                System.out.println("main dialog closing");
+                testGeneratedInterrupt = false;
+                mainThread.interrupt();
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ClassLoader/GetResourceNullArg.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Paths;
+import java.util.Enumeration;
+import java.util.stream.Stream;
+import org.testng.annotations.*;
+
+/*
+ * @test
+ * @bug 8136831
+ * @summary Test null argument to ClassLoader.getResourceXXXX()
+ * @run testng GetResourceNullArg
+ */
+
+public class GetResourceNullArg {
+    private static class MyClassLoader extends ClassLoader {
+        public MyClassLoader() {
+            super(null);
+        }
+        @Override
+        public Class findClass(String name) throws ClassNotFoundException {
+            throw new ClassNotFoundException("Why are you using this?");
+        }
+    }
+
+    @DataProvider
+    public static ClassLoader[][] provider() {
+        try {
+            return new ClassLoader[][] {
+                { ClassLoader.getSystemClassLoader() },
+                { new MyClassLoader() },
+                { new URLClassLoader(new URL[]{ Paths.get(".").toUri().toURL() },
+                                     ClassLoader.getSystemClassLoader()) }
+            };
+        } catch (MalformedURLException e) { throw new RuntimeException(e); }
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void classGetResource() {
+        this.getClass().getResource(null);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void classGetResourceAsStream() {
+        this.getClass().getResourceAsStream(null);
+    }
+
+    @Test(dataProvider = "provider",
+          expectedExceptions = NullPointerException.class)
+    public void loaderGetResource(ClassLoader cl) {
+        cl.getResource(null);
+    }
+
+    @Test(dataProvider = "provider",
+          expectedExceptions = NullPointerException.class)
+    public static void loaderGetResources(ClassLoader cl) throws IOException {
+        Enumeration<URL> retVal = cl.getResources(null);
+    }
+
+    @Test(dataProvider = "provider",
+          expectedExceptions = NullPointerException.class)
+    public static void loaderResources(ClassLoader cl) throws IOException {
+        Stream<URL> retVal = cl.resources(null);
+    }
+
+    @Test(dataProvider = "provider",
+          expectedExceptions = NullPointerException.class)
+    public void loaderGetResourceAsStream(ClassLoader cl) {
+        cl.getResourceAsStream(null);
+    }
+}
--- a/jdk/test/java/lang/ClassLoader/IsParallelCapable.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/lang/ClassLoader/IsParallelCapable.java	Wed Jul 05 22:30:23 2017 +0200
@@ -23,8 +23,8 @@
 
 /*
  * @test
- * @bug 8165793
- * @summary Test ClassLoader.isParallelCapable() method
+ * @bug 8165793 8169435
+ * @summary Test ClassLoader.isRegisteredAsParallelCapable() method
  * @run main IsParallelCapable
  */
 
@@ -85,7 +85,7 @@
     }
 
     public static void main(String[] args) throws Exception {
-        if (!ClassLoader.getSystemClassLoader().isParallelCapable()) {
+        if (!ClassLoader.getSystemClassLoader().isRegisteredAsParallelCapable()) {
             throw new RuntimeException("System classloader not parallel capable!?");
         }
 
@@ -100,10 +100,10 @@
     private static void testClassLoaderClass(Class<? extends TestCL> klazz) {
         try {
             TestCL cl = (TestCL)klazz.newInstance();
-            if (cl.expectCapable() != cl.isParallelCapable()) {
+            if (cl.expectCapable() != cl.isRegisteredAsParallelCapable()) {
                 throw new RuntimeException(klazz + " expectCapable: " +
-                        cl.expectCapable() + ", isParallelCapable: " +
-                        cl.isParallelCapable());
+                        cl.expectCapable() + ", isRegisteredAsParallelCapable: " +
+                        cl.isRegisteredAsParallelCapable());
             } else {
                 System.out.println(klazz + " passed");
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/modules/AppendToClassPathModuleTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8169909
+ * @library src /lib/testlibrary
+ * @build test/*
+ * @run shell AppendToClassPathModuleTest.sh
+ * @run main AppendToClassPathModuleTest
+ */
+
+import java.util.Map;
+import static jdk.testlibrary.ProcessTools.*;
+
+/**
+ * Launch a modular test with no class path and no CLASSPATH set.
+ * The java agent appends to the "hidden" directory to the class path
+ * at runtime.
+ */
+public class AppendToClassPathModuleTest {
+    public static void main(String... args) throws Throwable {
+        String modulepath = System.getProperty("test.module.path");
+        ProcessBuilder pb =
+            createJavaProcessBuilder("-javaagent:Agent.jar",
+                                     "--module-path", modulepath,
+                                     "-m", "test/jdk.test.Main");
+
+        // remove CLASSPATH environment variable
+        Map<String,String> env = pb.environment();
+        String value = env.remove("CLASSPATH");
+
+        int exitCode = executeCommand(pb).getExitValue();
+        if (exitCode != 0) {
+            throw new RuntimeException("Test failed: " + exitCode);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/modules/AppendToClassPathModuleTest.sh	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+if [ "${TESTSRC}" = "" ]
+then
+  echo "TESTSRC not set.  Test cannot execute.  Failed."
+  exit 1
+fi
+echo "TESTSRC=${TESTSRC}"
+
+if [ "${TESTJAVA}" = "" ]
+then
+  echo "TESTJAVA not set.  Test cannot execute.  Failed."
+  exit 1
+fi
+echo "TESTJAVA=${TESTJAVA}"
+
+if [ "${COMPILEJAVA}" = "" ]
+then
+  COMPILEJAVA="${TESTJAVA}"
+fi
+echo "COMPILEJAVA=${COMPILEJAVA}"
+
+if [ "${TESTCLASSES}" = "" ]
+then
+  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
+  exit 1
+fi
+
+echo "TESTCLASSES=${TESTCLASSES}"
+
+mkdir -p hidden
+${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
+    -d hidden ${TESTSRC}/../ExampleForClassPath.java
+
+mkdir -p classes
+${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
+    -d classes ${TESTSRC}/../InstrumentationHandoff.java
+
+echo "Manifest-Version: 1.0" > Agent.mf
+echo "Class-Path: hidden/" >> Agent.mf
+echo "Premain-Class: InstrumentationHandoff" >> Agent.mf
+
+${TESTJAVA}/bin/jar ${TESTTOOLVMOPTS} cvfm Agent.jar \
+    Agent.mf -C classes InstrumentationHandoff.class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/modules/src/test/jdk/test/Main.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test;
+
+/**
+ * Launched by AppendToClassPathModuleTest.
+ */
+public class Main {
+    public static void main(String... args) throws Exception {
+        // "java.class.path" system property is expected to be empty.
+        String value = System.getProperty("java.class.path");
+        if (!value.isEmpty()) {
+            throw new RuntimeException("Non-empty java.class.path=" + value);
+        }
+
+        // load the "hidden" class that should be loaded by the system loader
+        Class<?> c = Class.forName("ExampleForClassPath");
+        if (c.getClassLoader() != ClassLoader.getSystemClassLoader()) {
+            throw new RuntimeException(c + " loaderd by " + c.getClassLoader());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/modules/src/test/module-info.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module test {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/Authenticator/GetAuthenticatorTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.lang.ref.Reference;
+import java.net.Authenticator;
+import java.net.NetPermission;
+import java.net.PasswordAuthentication;
+import java.security.AccessControlException;
+
+/**
+ * @test
+ * @bug 8169068
+ * @summary  Basic test for Authenticator.getDefault()
+ * @run main/othervm GetAuthenticatorTest
+ */
+public class GetAuthenticatorTest {
+
+    static final class MyAuthenticator extends Authenticator {
+
+        MyAuthenticator () {
+            super ();
+        }
+
+        @Override
+        public PasswordAuthentication getPasswordAuthentication () {
+            System.out.println ("Auth called");
+            return (new PasswordAuthentication ("user",
+                        "passwordNotCheckedAnyway".toCharArray()));
+        }
+
+    }
+
+    public static void main (String args[]) throws Exception {
+        Authenticator defaultAuth = Authenticator.getDefault();
+        if (defaultAuth != null) {
+            throw new RuntimeException("Unexpected authenticator: null expected");
+        }
+        MyAuthenticator auth = new MyAuthenticator();
+        Authenticator.setDefault(auth);
+        defaultAuth = Authenticator.getDefault();
+        if (defaultAuth != auth) {
+            throw new RuntimeException("Unexpected authenticator: auth expected");
+        }
+        System.setSecurityManager(new SecurityManager());
+        try {
+            defaultAuth = Authenticator.getDefault();
+            throw new RuntimeException("Expected security exception not raised");
+        } catch (AccessControlException s) {
+            System.out.println("Got expected exception: " + s);
+            if (!s.getPermission().equals(new NetPermission("requestPasswordAuthentication"))) {
+                throw new RuntimeException("Unexpected permission check: " + s.getPermission());
+            }
+        }
+        System.out.println("Test passed with default authenticator "
+                           + defaultAuth);
+    }
+}
--- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java	Wed Jul 05 22:30:23 2017 +0200
@@ -219,7 +219,8 @@
                 throw new RuntimeException("ExecutionException expected");
             } catch (ExecutionException x) {
                 if (!(x.getCause() instanceof ClosedChannelException))
-                    throw new RuntimeException("Cause of ClosedChannelException expected");
+                    throw new RuntimeException("Cause of ClosedChannelException expected",
+                            x.getCause());
             }
             final AtomicReference<Throwable> connectException = new AtomicReference<>();
             ch.connect(server.address(), (Void)null, new CompletionHandler<Void,Void>() {
@@ -233,7 +234,8 @@
                 Thread.sleep(100);
             }
             if (!(connectException.get() instanceof ClosedChannelException))
-                throw new RuntimeException("ClosedChannelException expected");
+                throw new RuntimeException("ClosedChannelException expected",
+                        connectException.get());
         }
 
         // test that failure to connect closes the channel
@@ -353,7 +355,8 @@
                 Thread.sleep(100);
             }
             if (!(writeException.get() instanceof AsynchronousCloseException))
-                throw new RuntimeException("AsynchronousCloseException expected");
+                throw new RuntimeException("AsynchronousCloseException expected",
+                        writeException.get());
         }
     }
 
@@ -460,7 +463,8 @@
                 throw new RuntimeException("ExecutionException expected");
             } catch (ExecutionException x) {
                 if (!(x.getCause() instanceof ClosedChannelException))
-                    throw new RuntimeException("Cause of ClosedChannelException expected");
+                    throw new RuntimeException("Cause of ClosedChannelException expected",
+                            x.getCause());
             }
         }
     }
@@ -630,7 +634,8 @@
                 throw new RuntimeException("ExecutionException expected");
             } catch (ExecutionException x) {
                 if (!(x.getCause() instanceof ClosedChannelException))
-                    throw new RuntimeException("Cause of ClosedChannelException expected");
+                    throw new RuntimeException("Cause of ClosedChannelException expected",
+                            x.getCause());
             }
         }
     }
@@ -738,7 +743,8 @@
                     throw new RuntimeException("ClosedChannelException expected");
                 } catch (ExecutionException x) {
                     if (!(x.getCause() instanceof ClosedChannelException))
-                        throw new RuntimeException("ClosedChannelException expected");
+                        throw new RuntimeException("ClosedChannelException expected",
+                                x.getCause());
                 }
             }
         }
@@ -776,7 +782,8 @@
                     Thread.sleep(100);
                 }
                 if (!(readException.get() instanceof InterruptedByTimeoutException))
-                    throw new RuntimeException("InterruptedByTimeoutException expected");
+                    throw new RuntimeException("InterruptedByTimeoutException expected",
+                            readException.get());
 
                 // after a timeout then further reading should throw unspecified runtime exception
                 boolean exceptionThrown = false;
@@ -813,7 +820,8 @@
                     Thread.sleep(100);
                 }
                 if (!(writeException.get() instanceof InterruptedByTimeoutException))
-                    throw new RuntimeException("InterruptedByTimeoutException expected");
+                    throw new RuntimeException("InterruptedByTimeoutException expected",
+                            writeException.get());
 
                 // after a timeout then further writing should throw unspecified runtime exception
                 boolean exceptionThrown = false;
--- a/jdk/test/java/rmi/activation/Activatable/checkActivateRef/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/checkActivateRef/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -4,4 +4,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.rmi.server.useDynamicProxies=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/checkAnnotations/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/checkAnnotations/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,7 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
 };
--- a/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -4,4 +4,6 @@
 
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,7 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
 };
--- a/jdk/test/java/rmi/activation/Activatable/inactiveGroup/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/inactiveGroup/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -1,4 +1,6 @@
 grant {
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/nestedActivate/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/nestedActivate/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/restartCrashedService/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/restartCrashedService/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,7 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
 };
--- a/jdk/test/java/rmi/activation/Activatable/restartLatecomer/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/restartLatecomer/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/restartService/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/restartService/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,7 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
 };
--- a/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -4,4 +4,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Ddummyname=dummyvalue";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/Activatable/unregisterInactive/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/Activatable/unregisterInactive/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,6 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission java.lang.RuntimePermission "selectorProvider";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
 };
--- a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,8 +33,9 @@
  *          java.rmi/sun.rmi.server
  *          java.rmi/sun.rmi.transport
  *          java.rmi/sun.rmi.transport.tcp
+ *          java.base/sun.nio.ch
  * @build TestLibrary RMID ActivationLibrary
- *     ActivateMe ModifyDescriptor_Stub
+ *     ActivateMe ModifyDescriptor_Stub RMIDSelectorProvider
  * @run main/othervm/policy=security.policy/timeout=240 ModifyDescriptor
  */
 
--- a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/rmid.security.policy	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/rmid.security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -3,4 +3,9 @@
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
     permission com.sun.rmi.rmid.ExecOptionPermission "-Dtest.message=hello";
     permission com.sun.rmi.rmid.ExecOptionPermission "-Dtest.message=hello, again";
+    permission java.lang.RuntimePermission "selectorProvider";
+    permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
 };
--- a/jdk/test/java/rmi/testlibrary/RMID.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/testlibrary/RMID.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 import java.rmi.*;
 import java.rmi.activation.*;
 import java.rmi.registry.*;
+import java.time.LocalTime;
 import java.util.concurrent.TimeoutException;
 
 /**
@@ -44,6 +45,15 @@
     private static final long STARTTIME_MS        = 15_000L;
     private static final long POLLTIME_MS         = 100L;
 
+    // when restart rmid, it may take more time than usual because of
+    // "port in use" by a possible interloper (check JDK-8168975),
+    // so need to set a longer timeout for restart.
+    private static long restartTimeout;
+    // Same reason to inheritedChannel in RMIDSelectorProvider.
+    // Put it here rather than in RMIDSelectorProvider to adjust
+    // both timeout values together.
+    private static long inheritedChannelTimeout;
+
     private static final String SYSTEM_NAME = ActivationSystem.class.getName();
         // "java.rmi.activation.ActivationSystem"
 
@@ -73,7 +83,8 @@
     }
 
     /** make test options and arguments */
-    private static String makeOptions(int port, boolean debugExec) {
+    private static String makeOptions(int port, boolean debugExec,
+                                      boolean enableSelectorProvider) {
 
         String options = " -Dsun.rmi.server.activation.debugExec=" +
             debugExec;
@@ -98,12 +109,24 @@
         // to avoid spurious timeouts on slow machines.
         options += " -Dsun.rmi.activation.execTimeout=60000";
 
-        if (port == 0) {
+        // It's important to set handshakeTimeout to small value, for example
+        // 5 sec (default is 60 sec) to avoid wasting too much time when
+        // calling lookupSystem(port) in restart(), because
+        //   1. If use default value of this option, it will take about 2 minutes
+        //     to finish lookupSystem(port) in 2 loops in restart();
+        //   2. If set this option as 5 sec then lookupSystem(port) will return
+        //     very quickly.
+        options += " -Dsun.rmi.transport.tcp.handshakeTimeout=5000";
+
+        if (port == 0 || enableSelectorProvider) {
             // Ephemeral port, so have the rmid child process create the
             // server socket channel and report its port number, over stdin.
             options += " -classpath " + TestParams.testClassPath;
             options += " --add-exports=java.base/sun.nio.ch=ALL-UNNAMED";
             options += " -Djava.nio.channels.spi.SelectorProvider=RMIDSelectorProvider";
+            options += " -Dtest.java.rmi.testlibrary.RMIDSelectorProvider.port=" + port;
+            options += " -Dtest.java.rmi.testlibrary.RMIDSelectorProvider.timeout="
+                        + inheritedChannelTimeout;
 
             // Disable redirection of System.err to /tmp
             options += " -Dsun.rmi.server.activation.disableErrRedirect=true";
@@ -112,6 +135,10 @@
         return options;
     }
 
+    private static String makeArgs() {
+        return makeArgs(false, 0);
+    }
+
     private static String makeArgs(boolean includePortArg, int port) {
         String propagateManager = null;
 
@@ -183,7 +210,7 @@
                                   boolean debugExec, boolean includePortArg,
                                   int port)
     {
-        String options = makeOptions(port, debugExec);
+        String options = makeOptions(port, debugExec, false);
         String args = makeArgs(includePortArg, port);
         RMID rmid = new RMID("sun.rmi.server.Activation", options, args,
                              out, err, port);
@@ -193,14 +220,14 @@
     }
 
     public static RMID createRMIDOnEphemeralPort() {
-        return createRMID(System.out, System.err, true, true, 0);
+        return createRMID(System.out, System.err, true, false, 0);
     }
 
     public static RMID createRMIDOnEphemeralPort(OutputStream out,
                                                  OutputStream err,
                                                  boolean debugExec)
     {
-        return createRMID(out, err, debugExec, true, 0);
+        return createRMID(out, err, debugExec, false, 0);
     }
 
 
@@ -213,6 +240,9 @@
     {
         super(classname, options, args, out, err);
         this.port = port;
+        long waitTime = (long)(240_000 * TestLibrary.getTimeoutFactor());
+        restartTimeout = (long)(waitTime * 0.9);
+        inheritedChannelTimeout = (long)(waitTime * 0.8);
     }
 
     /**
@@ -280,11 +310,11 @@
         // if rmid is already running, then the test will fail with
         // a well recognized exception (port already in use...).
 
-        mesg("Starting rmid on port " + port + ".");
+        mesg("Starting rmid on port " + port + ", at " + LocalTime.now());
         int p = super.startAndGetPort();
         if (p != -1)
             port = p;
-        mesg("Started rmid on port " + port + ".");
+        mesg("Started rmid on port " + port + ", at " + LocalTime.now());
 
         // int slopFactor = 1;
         // try {
@@ -318,6 +348,7 @@
             // The rmid process is alive; check to see whether
             // it responds to a remote call.
 
+            mesg("looking up activation system, at " + LocalTime.now());
             if (lookupSystem(port) != null) {
                 /*
                  * We need to set the java.rmi.activation.port value as the
@@ -328,10 +359,11 @@
                  */
                 System.setProperty("java.rmi.activation.port", Integer.toString(port));
                 mesg("Started successfully after " +
-                    (System.currentTimeMillis() - startTime) + "ms.");
+                    (System.currentTimeMillis() - startTime) + "ms, at " + LocalTime.now());
                 return;
             }
 
+            mesg("after fail to looking up activation system, at " + LocalTime.now());
             if (System.currentTimeMillis() > deadline) {
                 TestLibrary.bomb("Failed to start rmid, giving up after " +
                     (System.currentTimeMillis() - startTime) + "ms.", null);
@@ -347,9 +379,10 @@
      */
     public void restart() throws IOException {
         destroy();
-        options = makeOptions(port, true);
-        args = makeArgs(true, port);
-        start();
+        options = makeOptions(port, true, true);
+        args = makeArgs();
+
+        start(restartTimeout);
     }
 
     /**
--- a/jdk/test/java/rmi/testlibrary/RMIDSelectorProvider.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/testlibrary/RMIDSelectorProvider.java	Wed Jul 05 22:30:23 2017 +0200
@@ -22,6 +22,7 @@
  */
 
 import java.io.*;
+import java.net.BindException;
 import java.net.InetSocketAddress;
 import java.net.ProtocolFamily;
 import java.nio.channels.Channel;
@@ -31,6 +32,7 @@
 import java.nio.channels.SocketChannel;
 import java.nio.channels.spi.AbstractSelector;
 import java.nio.channels.spi.SelectorProvider;
+import java.time.LocalTime;
 import static java.net.StandardSocketOptions.SO_REUSEADDR;
 import static java.net.StandardSocketOptions.SO_REUSEPORT;
 
@@ -98,7 +100,37 @@
                 channel.setOption(SO_REUSEPORT, true);
             }
 
-            channel.bind(new InetSocketAddress(0));
+            // when it comes here, these properties should have been set with
+            // a valid value, but assign a default value anyway.
+            long timeout = Long.getLong(
+                    "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout",
+                    200_000);
+            long deadline = System.currentTimeMillis() + timeout;
+            int port = Integer.getInteger(
+                    "test.java.rmi.testlibrary.RMIDSelectorProvider.port", 0);
+            while (true) {
+                try {
+                    channel.bind(new InetSocketAddress(port));
+                    break;
+                } catch (BindException ex) {
+                    System.out.format("RMIDSelectorProvider: "
+                            + "failed to bind to port %d due to \"%s\", at %s%n",
+                            port, ex.getMessage(), LocalTime.now());
+                }
+                if (System.currentTimeMillis() > deadline) {
+                    System.out.format("RMIDSelectorProvider: "
+                            + "fail to bind to port %d after trying for "
+                            + "%d seconds, exiting rmid process, at %s%n",
+                            port, timeout/1000, LocalTime.now());
+                    channel.close();
+                    // can not start rmid on specific port,
+                    // there is no need to continue run rmid.
+                    System.exit(1);
+                }
+                try {
+                    Thread.sleep(1000);
+                } catch(InterruptedException ignore) { }
+            }
 
             System.out.println(RMID.EPHEMERAL_MSG + channel.socket().getLocalPort());
         }
--- a/jdk/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
 
 public class ReuseDefaultPort implements Remote {
 
-    private static final int PORT = TestLibrary.getUnusedRandomPort();
+    private static int rmiPort = 0;
 
     private ReuseDefaultPort() { }
 
@@ -64,7 +64,7 @@
         Remote stub = UnicastRemoteObject.exportObject(impl, 0);
         System.err.println("- exported object: " + stub);
         try {
-            Registry registry = LocateRegistry.createRegistry(PORT);
+            Registry registry = LocateRegistry.createRegistry(rmiPort);
             System.err.println("- exported registry: " + registry);
             System.err.println("TEST PASSED");
         } finally {
@@ -77,13 +77,15 @@
             RMISocketFactory.getDefaultSocketFactory();
         SF() { }
         public Socket createSocket(String host, int port) throws IOException {
+            System.err.format("in SF::createSocket: %s, %d%n", host, port);
             return defaultFactory.createSocket(host, port);
         }
         public ServerSocket createServerSocket(int port) throws IOException {
-            if (port == 0) {
-                port = PORT;
-            }
-            return defaultFactory.createServerSocket(port);
+            System.err.format("in SF::createServerSocket: %d%n", port);
+            ServerSocket server = defaultFactory.createServerSocket(port);
+            rmiPort = server.getLocalPort();
+            System.err.println("rmiPort: " + rmiPort);
+            return server;
         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/ProtectionDomain/NullGetActions.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8043252
+ * @summary Debug of access control is obfuscated - NullPointerException in
+ *          ProtectionDomain
+ * @run main/othervm/java.security.policy=NullGetActions.policy NullGetActions
+ */
+
+import java.net.*;
+import java.security.*;
+
+public class NullGetActions {
+
+    public static void main(String[] args) throws Exception {
+        Permissions permset = new Permissions();
+        permset.add(new EvilPermission("java.let.me.do.stuff"));
+
+        Policy.getPolicy();
+        ProtectionDomain protDom = new ProtectionDomain(
+                new CodeSource(new URL("http://bar"),
+                        (java.security.cert.Certificate[])null), permset,
+                        null, null);
+
+        System.out.println("Protection Domain:\n" + protDom);
+    }
+
+    public static class EvilPermission extends Permission {
+        public EvilPermission(String name) {
+            super(name);
+        }
+
+        @Override
+        public String getActions() {
+            return null;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            return (obj == this);
+        }
+
+        @Override
+        public int hashCode() {
+            return 42;
+        }
+
+        @Override
+        public boolean implies(Permission permission) {
+            return false;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/ProtectionDomain/NullGetActions.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,3 @@
+grant {
+    permission java.security.SecurityPermission "getPolicy";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/SecureRandom/NoSync.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/*
+ * @test
+ * @bug 7004967
+ * @run main/othervm NoSync
+ * @summary SecureRandom should be more explicit about threading
+ */
+public class NoSync {
+    public static void main(String[] args) throws Exception {
+        for (Provider p : Security.getProviders()) {
+            for (Provider.Service s : p.getServices()) {
+                if (s.getType().equals("SecureRandom") &&
+                        !s.getAlgorithm().contains("Block")) {
+                    test(SecureRandom.getInstance(s.getAlgorithm(), p));
+                }
+            }
+        }
+        Security.setProperty("securerandom.drbg.config", "HMAC_DRBG");
+        test(SecureRandom.getInstance("DRBG"));
+        Security.setProperty("securerandom.drbg.config", "CTR_DRBG");
+        test(SecureRandom.getInstance("DRBG"));
+    }
+
+    static void test(SecureRandom sr) throws Exception {
+        test(sr, 20, 3000);
+        // All out-of-box impl should have the ThreadSafe attribute
+        String attr = sr.getProvider().getProperty("SecureRandom."
+                + sr.getAlgorithm() + " ThreadSafe");
+        if (!"true".equals(attr)) {
+            throw new Exception("Not ThreadSafe: " + attr);
+        }
+    }
+
+    public static void test(SecureRandom sr, int tnum, int rnum)
+            throws Exception {
+
+        System.out.println(sr);
+        System.out.println(sr.getAlgorithm() + " " + sr.getProvider().getName());
+
+        System.out.println(new Date());
+        boolean reseed = sr.getParameters() != null;
+        Thread[] threads = new Thread[tnum];
+        AtomicBoolean failed = new AtomicBoolean(false);
+        Thread.UncaughtExceptionHandler h = (t, e) -> {
+            failed.set(true);
+            e.printStackTrace();
+        };
+        for (int i = 0; i < threads.length; i++) {
+            threads[i] = new Thread() {
+                @Override
+                public void run() {
+                    for (int j = 0; j < rnum; j++) {
+                        sr.nextBytes(new byte[j%100+100]);
+                        sr.setSeed((long)j);
+                        if (reseed) {
+                            sr.reseed();
+                        }
+                    }
+                }
+            };
+            threads[i].setUncaughtExceptionHandler(h);
+            threads[i].start();
+        }
+        for (int i = 0; i < threads.length; i++) {
+            threads[i].join();
+        }
+        System.out.println(new Date());
+        System.out.println();
+        if (failed.get()) {
+            throw new RuntimeException("Failed");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/SecureRandom/ThreadSafe.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.SecureRandomSpi;
+import java.util.Map;
+
+/*
+ * @test
+ * @bug 7004967
+ * @summary SecureRandom should be more explicit about threading
+ */
+public class ThreadSafe {
+    public static void main(String[] args) throws Exception {
+        Provider p = new P();
+        NoSync.test(SecureRandom.getInstance("S1", p), 5, 5);
+        try {
+            NoSync.test(SecureRandom.getInstance("S2", p), 5, 5);
+            throw new Exception("Failed");
+        } catch (RuntimeException re) {
+            // Good
+        }
+        NoSync.test(SecureRandom.getInstance("S3", p), 5, 5);
+        try {
+            NoSync.test(SecureRandom.getInstance("S4", p), 5, 5);
+            throw new Exception("Failed");
+        } catch (RuntimeException re) {
+            // Good
+        }
+    }
+
+    public static class P extends Provider {
+        public P() {
+
+            super("P", 1.0d, "Haha");
+
+            // Good. No attribute.
+            put("SecureRandom.S1", S.class.getName());
+
+            // Bad. Boasting ThreadSafe but isn't
+            put("SecureRandom.S2", S.class.getName());
+            put("SecureRandom.S2 ThreadSafe", "true");
+
+            // Good. No attribute.
+            putService(new Service(this, "SecureRandom", "S3",
+                    S.class.getName(), null, null));
+
+            // Bad. Boasting ThreadSafe but isn't
+            putService(new Service(this, "SecureRandom", "S4",
+                    S.class.getName(), null, Map.of("ThreadSafe", "true")));
+        }
+    }
+
+    // This implementation is not itself thread safe.
+    public static class S extends SecureRandomSpi {
+        @java.lang.Override
+        protected void engineSetSeed(byte[] seed) {
+            return;
+        }
+
+        private volatile boolean inCall = false;
+        @Override
+        protected void engineNextBytes(byte[] bytes) {
+            if (inCall) {
+                throw new RuntimeException("IN CALL");
+            }
+            inCall = true;
+            try {
+                Thread.sleep(100);
+            } catch (Exception e) {
+                // OK
+            }
+            inCall = false;
+        }
+
+        @Override
+        protected byte[] engineGenerateSeed(int numBytes) {
+            return new byte[numBytes];
+        }
+    }
+}
--- a/jdk/test/java/text/testlib/IntlTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/text/testlib/IntlTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -89,6 +89,9 @@
             case "-nothrow":
                 nothrow = true;
                 break;
+            case "-exitcode":
+                exitCode = true;
+                break;
             default:
                 Method m = testMethods.get(arg);
                 if (m == null) {
@@ -138,7 +141,12 @@
             }
         }
         if (nothrow) {
-            System.exit(errorCount);
+            if (exitCode) {
+                System.exit(errorCount);
+            }
+            if (errorCount > 0) {
+                throw new IllegalArgumentException("encountered " + errorCount + " errors");
+            }
         }
     }
 
@@ -243,7 +251,7 @@
      */
     void usage() {
         System.out.println(getClass().getName() +
-                            ": [-verbose] [-nothrow] [-prompt] [test names]");
+                            ": [-verbose] [-nothrow] [-exitcode] [-prompt] [test names]");
 
         System.out.println("  Available test names:");
         for (String methodName : testMethods.keySet()) {
@@ -254,7 +262,7 @@
     private boolean     prompt;
     private boolean     nothrow;
     protected boolean   verbose;
-
+    private boolean     exitCode;
     private PrintWriter log;
     private int         indentLevel;
     private boolean     needLineFeed;
--- a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java	Wed Jul 05 22:30:23 2017 +0200
@@ -594,7 +594,7 @@
     @Test(dataProvider = "formatGenericTimeZonePatterns")
     public void test_appendZoneText_formatGenericTimeZonePatterns(String pattern, String input, String expected) {
         ZonedDateTime zdt = ZonedDateTime.of(LocalDateTime.now(), ZoneId.of(input));
-        DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern);
+        DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern, Locale.US);
         assertEquals(zdt.format(df), expected);
     }
 
@@ -641,7 +641,7 @@
     @Test(dataProvider = "formatNonGenericTimeZonePatterns_1")
     public void test_appendZoneText_parseNonGenricTimeZonePatterns_1(String pattern, LocalDateTime ldt, String expected) {
         ZoneId  zId = ZoneId.of("America/Los_Angeles");
-        DateTimeFormatter df = new DateTimeFormatterBuilder().appendPattern(pattern).toFormatter();
+        DateTimeFormatter df = new DateTimeFormatterBuilder().appendPattern(pattern).toFormatter(Locale.US);
         ZonedDateTime zdt = ZonedDateTime.of(ldt, zId);
         String actual = df.format(zdt);
         assertEquals(actual, expected);
@@ -668,7 +668,7 @@
     @Test(dataProvider = "formatNonGenericTimeZonePatterns_2")
     public void test_appendZoneText_parseNonGenricTimeZonePatterns_2(String pattern, LocalDateTime ldt, String expected) {
         ZoneId  zId = ZoneId.of("America/Los_Angeles");
-        DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern).withZone(zId);
+        DateTimeFormatter df = DateTimeFormatter.ofPattern(pattern, Locale.US).withZone(zId);
         String actual = df.format(ldt);
         assertEquals(actual, expected);
     }
--- a/jdk/test/java/time/tck/java/time/zone/TCKZoneRulesProvider.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/time/tck/java/time/zone/TCKZoneRulesProvider.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -91,10 +91,11 @@
     public void test_getAvailableGroupIds() {
         Set<String> zoneIds = ZoneRulesProvider.getAvailableZoneIds();
         assertEquals(zoneIds.contains("Europe/London"), true);
-        zoneIds.clear();
-        assertEquals(zoneIds.size(), 0);
-        Set<String> zoneIds2 = ZoneRulesProvider.getAvailableZoneIds();
-        assertEquals(zoneIds2.contains("Europe/London"), true);
+    }
+
+    @Test(expectedExceptions=UnsupportedOperationException.class)
+    public void test_getAvailableGroupIds_modifyZoneId() {
+        ZoneRulesProvider.getAvailableZoneIds().clear();
     }
 
     //-----------------------------------------------------------------------
--- a/jdk/test/java/util/BitSet/BitSetStreamTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/BitSet/BitSetStreamTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,25 +60,6 @@
         public int getAsInt() { int s = n1; n1 = n2; n2 = s + n1; return s; }
     }
 
-    private static final Object[][] testcases = new Object[][] {
-        { "none", IntStream.empty() },
-        { "index 0", IntStream.of(0) },
-        { "index 255", IntStream.of(255) },
-        { "every bit", IntStream.range(0, 255) },
-        { "step 2", IntStream.range(0, 255).map(f -> f * 2) },
-        { "step 3", IntStream.range(0, 255).map(f -> f * 3) },
-        { "step 5", IntStream.range(0, 255).map(f -> f * 5) },
-        { "step 7", IntStream.range(0, 255).map(f -> f * 7) },
-        { "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000) },
-        { "max int", IntStream.of(Integer.MAX_VALUE) },
-        { "25 fibs", IntStream.generate(new Fibs()).limit(25) }
-    };
-
-    @DataProvider(name = "cases")
-    public static Object[][] produceCases() {
-        return testcases;
-    }
-
     @Test
     public void testFibs() {
         Fibs f = new Fibs();
@@ -93,22 +74,46 @@
         assertEquals(987, Fibs.fibs(16));
     }
 
+
+    @DataProvider(name = "cases")
+    public static Object[][] produceCases() {
+        return new Object[][] {
+                { "none", IntStream.empty() },
+                { "index 0", IntStream.of(0) },
+                { "index 255", IntStream.of(255) },
+                { "index 0 and 255", IntStream.of(0, 255) },
+                { "index Integer.MAX_VALUE", IntStream.of(Integer.MAX_VALUE) },
+                { "index Integer.MAX_VALUE - 1", IntStream.of(Integer.MAX_VALUE - 1) },
+                { "index 0 and Integer.MAX_VALUE", IntStream.of(0, Integer.MAX_VALUE) },
+                { "every bit", IntStream.range(0, 255) },
+                { "step 2", IntStream.range(0, 255).map(f -> f * 2) },
+                { "step 3", IntStream.range(0, 255).map(f -> f * 3) },
+                { "step 5", IntStream.range(0, 255).map(f -> f * 5) },
+                { "step 7", IntStream.range(0, 255).map(f -> f * 7) },
+                { "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000) },
+                { "25 fibs", IntStream.generate(new Fibs()).limit(25) }
+        };
+    }
+
     @Test(dataProvider = "cases")
     public void testBitsetStream(String name, IntStream data) {
-        BitSet bs = new BitSet();
-        long setBits = data.distinct()
-                           .peek(i -> bs.set(i))
-                           .count();
+        BitSet bs = data.collect(BitSet::new, BitSet::set, BitSet::or);
+
+        assertEquals(bs.cardinality(), bs.stream().count());
 
-        assertEquals(bs.cardinality(), setBits);
-        assertEquals(bs.cardinality(), bs.stream().reduce(0, (s, i) -> s+1));
+        int[] indexHolder = new int[] { -1 };
+        bs.stream().forEach(i -> {
+            int ei = indexHolder[0];
+            indexHolder[0] = bs.nextSetBit(ei + 1);
+            assertEquals(i, indexHolder[0]);
+        });
 
         PrimitiveIterator.OfInt it = bs.stream().iterator();
-        for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) {
+        for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
             assertTrue(it.hasNext());
             assertEquals(it.nextInt(), i);
             if (i == Integer.MAX_VALUE)
-                break; // or (i+1) would overflow
+                break; // or (i + 1) would overflow
         }
         assertFalse(it.hasNext());
     }
@@ -123,16 +128,20 @@
         for (int seed : seeds) {
             final Random random = new Random(seed);
             random.nextBytes(bytes);
-            final BitSet bitSet = BitSet.valueOf(bytes);
-            final int cardinality = bitSet.cardinality();
-            final IntStream stream = bitSet.stream();
-            final int[] array = stream.toArray();
-            assertEquals(array.length, cardinality);
-            int nextSetBit = -1;
-            for (int i=0; i < cardinality; i++) {
-                nextSetBit = bitSet.nextSetBit(nextSetBit + 1);
-                assertEquals(array[i], nextSetBit);
-            }
+
+            BitSet bitSet = BitSet.valueOf(bytes);
+            testBitSetContents(bitSet, bitSet.stream().toArray());
+            testBitSetContents(bitSet, bitSet.stream().parallel().toArray());
+        }
+    }
+
+    void testBitSetContents(BitSet bitSet, int[] array) {
+        int cardinality = bitSet.cardinality();
+        assertEquals(array.length, cardinality);
+        int nextSetBit = -1;
+        for (int i = 0; i < cardinality; i++) {
+            nextSetBit = bitSet.nextSetBit(nextSetBit + 1);
+            assertEquals(array[i], nextSetBit);
         }
     }
 }
--- a/jdk/test/java/util/Calendar/Bug4766302.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/Bug4766302.java	Wed Jul 05 22:30:23 2017 +0200
@@ -29,9 +29,11 @@
 
 import java.util.GregorianCalendar;
 
+@SuppressWarnings("serial")
 public class Bug4766302 {
 
     static class MyCalendar extends GregorianCalendar {
+
         boolean isTimeStillSet() {
             return isTimeSet;
         }
--- a/jdk/test/java/util/Calendar/Bug4958050.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/Bug4958050.java	Wed Jul 05 22:30:23 2017 +0200
@@ -29,9 +29,11 @@
 
 import java.util.Locale;
 import java.util.TimeZone;
+
 import static java.util.Calendar.*;
 
 public class Bug4958050 {
+
     static int errorCount = 0;
 
     public static void main(String[] args) {
@@ -41,87 +43,87 @@
         System.out.println("Time zone = " + cal.getTimeZone().getID());
 
         // Test the week fields
-        int[] weekFields = { WEEK_OF_YEAR, WEEK_OF_MONTH, DAY_OF_WEEK_IN_MONTH };
+        int[] weekFields = {WEEK_OF_YEAR, WEEK_OF_MONTH, DAY_OF_WEEK_IN_MONTH};
         for (int i = 0; i < weekFields.length; i++) {
             int field = weekFields[i];
             // add()
             cal.clear();
-            cal.set(1919, DECEMBER, 14-7, 23, 50, 00);
+            cal.set(1919, DECEMBER, 14 - 7, 23, 50, 00);
             cal.add(weekFields[i], +1);
             if (!cal.checkDate(1919, DECEMBER, 14)) {
-                error("1919/12/07: add("+cal.getFieldName(weekFields[i])+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1919/12/07: add(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
-            cal.set(1930, JUNE, 21-7);
+            cal.set(1930, JUNE, 21 - 7);
             cal.add(weekFields[i], +1);
             if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
-                error("1930/6/14: add("+cal.getFieldName(weekFields[i])+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1930/6/14: add(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
 
             // roll()
             cal.clear();
-            cal.set(1919, DECEMBER, 14-7, 23, 50, 00);
+            cal.set(1919, DECEMBER, 14 - 7, 23, 50, 00);
             cal.roll(weekFields[i], +1);
             if (!cal.checkDate(1919, DECEMBER, 14)) {
-                error("1919/12/07: roll("+cal.getFieldName(weekFields[i])+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1919/12/07: roll(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
-            cal.set(1930, JUNE, 21-7);
+            cal.set(1930, JUNE, 21 - 7);
             cal.roll(weekFields[i], +1);
             if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
-                error("1930/6/14: roll("+cal.getFieldName(weekFields[i])+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1930/6/14: roll(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
         }
 
         // Test the day fields
-        int[] dayFields = { DAY_OF_MONTH, DAY_OF_YEAR, DAY_OF_WEEK };
+        int[] dayFields = {DAY_OF_MONTH, DAY_OF_YEAR, DAY_OF_WEEK};
         for (int i = 0; i < dayFields.length; i++) {
             int field = dayFields[i];
             // add()
             cal.clear();
-            cal.set(1919, DECEMBER, 14-1, 23, 50, 00);
+            cal.set(1919, DECEMBER, 14 - 1, 23, 50, 00);
             cal.add(field, +1);
             if (!cal.checkDate(1919, DECEMBER, 14)) {
-                error("1919/12/13: add("+cal.getFieldName(field)+", +1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1919/12/13: add(" + Koyomi.getFieldName(field) + ", +1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
             cal.set(1919, DECEMBER, 14, 00, 00, 00);
             cal.add(field, -1);
             if (!cal.checkDate(1919, DECEMBER, 13)) {
-                error("1919/12/14: add("+cal.getFieldName(field)+", -1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1919/12/14: add(" + Koyomi.getFieldName(field) + ", -1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
-            cal.set(1930, JUNE, 21-1);
+            cal.set(1930, JUNE, 21 - 1);
             cal.add(field, +1);
             if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
-                error("1930/6/20: add("+cal.getFieldName(field)+", +1)\n"
-                      + cal.getMessage() + cal.toDateTimeString());
+                error("1930/6/20: add(" + Koyomi.getFieldName(field) + ", +1)\n"
+                        + cal.getMessage() + cal.toDateTimeString());
             }
             cal.clear();
             cal.set(1930, JUNE, 21, 01, 00, 00);
             cal.add(field, -1);
             if (!cal.checkDateTime(1930, JUNE, 20, 01, 00, 00, 000)) {
-                error("1930/6/21: add("+cal.getFieldName(field)+", -1)\n"
-                      + cal.getMessage()+" " + cal.toDateTimeString());
+                error("1930/6/21: add(" + Koyomi.getFieldName(field) + ", -1)\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
 
             // roll()
             cal.clear();
-            cal.set(1930, JUNE, 21-1);
+            cal.set(1930, JUNE, 21 - 1);
             int amount = +1;
             if (field == DAY_OF_WEEK) {
                 amount += 700;
             }
             cal.roll(field, amount);
             if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
-                error("1930/6/20: roll("+cal.getFieldName(field)+", +"+amount+")\n"
-                      + cal.getMessage() + " " + cal.toDateTimeString());
+                error("1930/6/20: roll(" + Koyomi.getFieldName(field) + ", +" + amount + ")\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
             cal.clear();
             cal.set(1930, JUNE, 21, 01, 00, 00);
@@ -131,93 +133,93 @@
             }
             cal.roll(field, amount);
             if (!cal.checkDateTime(1930, JUNE, 20, 01, 00, 00, 000)) {
-                error("1930/6/21: roll("+cal.getFieldName(field)+", "+amount+")\n"
-                      + cal.getMessage()+" "+cal.toDateTimeString());
+                error("1930/6/21: roll(" + Koyomi.getFieldName(field) + ", " + amount + ")\n"
+                        + cal.getMessage() + " " + cal.toDateTimeString());
             }
         }
 
         // Test the AM_PM field
         // add()
         cal.clear();
-        cal.set(1919, DECEMBER, 14-1, 23, 50, 00);
+        cal.set(1919, DECEMBER, 14 - 1, 23, 50, 00);
         cal.add(AM_PM, +1);
         if (!cal.checkDate(1919, DECEMBER, 14)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1919/12/13: add(AM_PM, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
-        cal.set(1930, JUNE, 21-1, 12, 00, 00);
+        cal.set(1930, JUNE, 21 - 1, 12, 00, 00);
         cal.add(AM_PM, +1);
         if (!cal.checkDate(1930, JUNE, 21)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1930/6/20: add(AM_PM, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
-        cal.set(1930, JUNE, 21-2, 12, 00, 00);
+        cal.set(1930, JUNE, 21 - 2, 12, 00, 00);
         cal.add(AM_PM, +3);
         if (!cal.checkDate(1930, JUNE, 21)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1930/6/10: add(AM_PM, +3)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
         cal.set(1919, DECEMBER, 14, 11, 50, 00);
         cal.add(AM_PM, -1);
-        if (!cal.checkDateTime(1919, DECEMBER, 14-1, 23, 50, 00, 000)
-            || !cal.checkFieldValue(AM_PM, PM)) {
+        if (!cal.checkDateTime(1919, DECEMBER, 14 - 1, 23, 50, 00, 000)
+                || !cal.checkFieldValue(AM_PM, PM)) {
             error("1919/12/14 11:50:00: add(AM_PM, -1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
         cal.set(1930, JUNE, 21, 01, 00, 00);
         cal.add(AM_PM, -1);
-        if (!cal.checkDateTime(1930, JUNE, 21-1, 01+12, 00, 00, 000)
-            || !cal.checkFieldValue(AM_PM, PM)) {
+        if (!cal.checkDateTime(1930, JUNE, 21 - 1, 01 + 12, 00, 00, 000)
+                || !cal.checkFieldValue(AM_PM, PM)) {
             error("1930/6/20: add(AM_PM, -1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
         cal.set(1930, JUNE, 21, 01, 00, 00);
         cal.add(AM_PM, -3);
-        if (!cal.checkDateTime(1930, JUNE, 21-2, 01+12, 00, 00, 000)
-            || !cal.checkFieldValue(AM_PM, PM)) {
+        if (!cal.checkDateTime(1930, JUNE, 21 - 2, 01 + 12, 00, 00, 000)
+                || !cal.checkFieldValue(AM_PM, PM)) {
             error("1930/6/10: add(AM_PM, -3)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         // roll() (should NOT change the date)
         cal.clear();
-        cal.set(1919, DECEMBER, 14-1, 23, 50, 00);
+        cal.set(1919, DECEMBER, 14 - 1, 23, 50, 00);
         cal.roll(AM_PM, +1);
-        if (!cal.checkDateTime(1919, DECEMBER, 14-1, 23-12, 50, 00, 000)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+        if (!cal.checkDateTime(1919, DECEMBER, 14 - 1, 23 - 12, 50, 00, 000)
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1919/12/13: roll(AM_PM, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
-        cal.set(1930, JUNE, 21-1, 12, 00, 00);
+        cal.set(1930, JUNE, 21 - 1, 12, 00, 00);
         cal.roll(AM_PM, +1);
-        if (!cal.checkDateTime(1930, JUNE, 21-1, 12-12, 00, 00, 000)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+        if (!cal.checkDateTime(1930, JUNE, 21 - 1, 12 - 12, 00, 00, 000)
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1930/6/20: roll(AM_PM, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         cal.clear();
-        cal.set(1930, JUNE, 21-2, 12, 00, 00);
+        cal.set(1930, JUNE, 21 - 2, 12, 00, 00);
         cal.roll(AM_PM, +3);
-        if (!cal.checkDateTime(1930, JUNE, 21-2, 12-12, 00, 00, 000)
-            || !cal.checkFieldValue(AM_PM, AM)) {
+        if (!cal.checkDateTime(1930, JUNE, 21 - 2, 12 - 12, 00, 00, 000)
+                || !cal.checkFieldValue(AM_PM, AM)) {
             error("1930/6/10: roll(AM_PM, +3)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         // Test the HOUR_OF_DAY field
@@ -227,7 +229,7 @@
         cal.add(HOUR_OF_DAY, +1);
         if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
             error("1930/6/20 23:00:00: add(HOUR_OF_DAY, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         // roll() (should NOT change the date)
@@ -236,7 +238,7 @@
         cal.roll(HOUR_OF_DAY, +1);
         if (!cal.checkDateTime(1930, JUNE, 20, 00, 00, 00, 000)) {
             error("1930/6/20 23:00:00: roll(HOUR_OF_DAY, +1)\n"
-                  + cal.getMessage()+" "+cal.toDateTimeString());
+                    + cal.getMessage() + " " + cal.toDateTimeString());
         }
 
         checkErrors();
--- a/jdk/test/java/util/Calendar/CalendarRegression.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/CalendarRegression.java	Wed Jul 05 22:30:23 2017 +0200
@@ -34,11 +34,24 @@
  * @library /java/text/testlib
  * @run main CalendarRegression
  */
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.SimpleTimeZone;
+import java.util.TimeZone;
 
-import java.lang.reflect.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
+import static java.util.Calendar.*;
 
 public class CalendarRegression extends IntlTest {
 
@@ -47,99 +60,101 @@
     }
 
     /*
-      Synopsis: java.sql.Timestamp constructor works wrong on Windows 95
+    Synopsis: java.sql.Timestamp constructor works wrong on Windows 95
 
-      ==== Here is the test ====
-      public static void main (String args[]) {
-        java.sql.Timestamp t= new java.sql.Timestamp(0,15,5,5,8,13,123456700);
-        logln("expected=1901-04-05 05:08:13.1234567");
-        logln(" result="+t);
-      }
+    ==== Here is the test ====
+    public static void main (String args[]) {
+    java.sql.Timestamp t= new java.sql.Timestamp(0,15,5,5,8,13,123456700);
+    logln("expected=1901-04-05 05:08:13.1234567");
+    logln(" result="+t);
+    }
 
-      ==== Here is the output of the test on Solaris or NT ====
-      expected=1901-04-05 05:08:13.1234567
-      result=1901-04-05 05:08:13.1234567
+    ==== Here is the output of the test on Solaris or NT ====
+    expected=1901-04-05 05:08:13.1234567
+    result=1901-04-05 05:08:13.1234567
 
-      ==== Here is the output of the test on Windows95 ====
-      expected=1901-04-05 05:08:13.1234567
-      result=1901-04-05 06:08:13.1234567
-      */
-
+    ==== Here is the output of the test on Windows95 ====
+    expected=1901-04-05 05:08:13.1234567
+    result=1901-04-05 06:08:13.1234567
+     */
     public void Test4031502() {
         // This bug actually occurs on Windows NT as well, and doesn't
         // require the host zone to be set; it can be set in Java.
         String[] ids = TimeZone.getAvailableIDs();
         boolean bad = false;
-        for (int i=0; i<ids.length; ++i) {
+        for (int i = 0; i < ids.length; ++i) {
             TimeZone zone = TimeZone.getTimeZone(ids[i]);
             GregorianCalendar cal = new GregorianCalendar(zone);
             cal.clear();
             cal.set(1900, 15, 5, 5, 8, 13);
-            if (cal.get(Calendar.HOUR) != 5) {
-                logln(zone.getID() + " " +
-                                   //zone.useDaylightTime() + " " +
-                                   cal.get(Calendar.DST_OFFSET) / (60*60*1000) + " " +
-                                   zone.getRawOffset() / (60*60*1000) +
-                                   ": HOUR = " + cal.get(Calendar.HOUR));
+            if (cal.get(HOUR) != 5) {
+                logln(zone.getID() + " "
+                        + //zone.useDaylightTime() + " "
+                        + cal.get(DST_OFFSET) / (60 * 60 * 1000) + " "
+                        + zone.getRawOffset() / (60 * 60 * 1000)
+                        + ": HOUR = " + cal.get(HOUR));
                 bad = true;
             }
         }
-        if (bad) errln("TimeZone problems with GC");
+        if (bad) {
+            errln("TimeZone problems with GC");
+        }
     }
 
     public void Test4035301() {
         GregorianCalendar c = new GregorianCalendar(98, 8, 7);
         GregorianCalendar d = new GregorianCalendar(98, 8, 7);
-        if (c.after(d) ||
-            c.after(c) ||
-            c.before(d) ||
-            c.before(c) ||
-            !c.equals(c) ||
-            !c.equals(d))
+        if (c.after(d)
+                || c.after(c)
+                || c.before(d)
+                || c.before(c)
+                || !c.equals(c)
+                || !c.equals(d)) {
             errln("Fail");
+        }
     }
 
     public void Test4040996() {
         String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
         SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
-        pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
-        pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
+        pdt.setStartRule(APRIL, 1, SUNDAY, 2 * 60 * 60 * 1000);
+        pdt.setEndRule(OCTOBER, -1, SUNDAY, 2 * 60 * 60 * 1000);
         Calendar calendar = new GregorianCalendar(pdt);
 
-        calendar.set(Calendar.MONTH,3);
-        calendar.set(Calendar.DAY_OF_MONTH,18);
-        calendar.set(Calendar.SECOND, 30);
+        calendar.set(MONTH, 3);
+        calendar.set(DAY_OF_MONTH, 18);
+        calendar.set(SECOND, 30);
 
-        logln("MONTH: " + calendar.get(Calendar.MONTH));
-        logln("DAY_OF_MONTH: " +
-                           calendar.get(Calendar.DAY_OF_MONTH));
-        logln("MINUTE: " + calendar.get(Calendar.MINUTE));
-        logln("SECOND: " + calendar.get(Calendar.SECOND));
+        logln("MONTH: " + calendar.get(MONTH));
+        logln("DAY_OF_MONTH: "
+                + calendar.get(DAY_OF_MONTH));
+        logln("MINUTE: " + calendar.get(MINUTE));
+        logln("SECOND: " + calendar.get(SECOND));
 
-        calendar.add(Calendar.SECOND,6);
+        calendar.add(SECOND, 6);
         //This will print out todays date for MONTH and DAY_OF_MONTH
         //instead of the date it was set to.
         //This happens when adding MILLISECOND or MINUTE also
-        logln("MONTH: " + calendar.get(Calendar.MONTH));
-        logln("DAY_OF_MONTH: " +
-                           calendar.get(Calendar.DAY_OF_MONTH));
-        logln("MINUTE: " + calendar.get(Calendar.MINUTE));
-        logln("SECOND: " + calendar.get(Calendar.SECOND));
-        if (calendar.get(Calendar.MONTH) != 3 ||
-            calendar.get(Calendar.DAY_OF_MONTH) != 18 ||
-            calendar.get(Calendar.SECOND) != 36)
+        logln("MONTH: " + calendar.get(MONTH));
+        logln("DAY_OF_MONTH: "
+                + calendar.get(DAY_OF_MONTH));
+        logln("MINUTE: " + calendar.get(MINUTE));
+        logln("SECOND: " + calendar.get(SECOND));
+        if (calendar.get(MONTH) != 3
+                || calendar.get(DAY_OF_MONTH) != 18
+                || calendar.get(SECOND) != 36) {
             errln("Fail: Calendar.add misbehaves");
+        }
     }
 
     public void Test4051765() {
         Calendar cal = Calendar.getInstance();
         cal.setLenient(false);
-        cal.set(Calendar.DAY_OF_WEEK, 0);
+        cal.set(DAY_OF_WEEK, 0);
         try {
             cal.getTime();
             errln("Fail: DAY_OF_WEEK 0 should be disallowed");
-        }
-        catch (IllegalArgumentException e) {
+        } catch (IllegalArgumentException e) {
             return;
         }
     }
@@ -200,51 +215,54 @@
         logln("DST_OFFSET: "
                            + (calendar.get(calendar.DST_OFFSET)/(60*60*1000))); // in hours
     }
-    */
-
+     */
     public void Test4059654() {
         GregorianCalendar gc = new GregorianCalendar();
 
         gc.set(1997, 3, 1, 15, 16, 17); // April 1, 1997
 
-        gc.set(Calendar.HOUR, 0);
-        gc.set(Calendar.AM_PM, Calendar.AM);
-        gc.set(Calendar.MINUTE, 0);
-        gc.set(Calendar.SECOND, 0);
-        gc.set(Calendar.MILLISECOND, 0);
+        gc.set(HOUR, 0);
+        gc.set(AM_PM, AM);
+        gc.set(MINUTE, 0);
+        gc.set(SECOND, 0);
+        gc.set(MILLISECOND, 0);
 
         Date cd = gc.getTime();
+        @SuppressWarnings("deprecation")
         Date exp = new Date(97, 3, 1, 0, 0, 0);
-        if (!cd.equals(exp))
+        if (!cd.equals(exp)) {
             errln("Fail: Calendar.set broken. Got " + cd + " Want " + exp);
+        }
     }
 
     public void Test4061476() {
         SimpleDateFormat fmt = new SimpleDateFormat("ddMMMyy", Locale.UK);
         Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"),
-                                                     Locale.UK);
+                Locale.UK);
         fmt.setCalendar(cal);
-        try
-            {
-                Date date = fmt.parse("29MAY97");
-                cal.setTime(date);
-            }
-        catch (Exception e) {;}
-        cal.set(Calendar.HOUR_OF_DAY, 13);
-        logln("Hour: "+cal.get(Calendar.HOUR_OF_DAY));
-        cal.add(Calendar.HOUR_OF_DAY, 6);
-        logln("Hour: "+cal.get(Calendar.HOUR_OF_DAY));
-        if (cal.get(Calendar.HOUR_OF_DAY) != 19)
-            errln("Fail: Want 19 Got " + cal.get(Calendar.HOUR_OF_DAY));
+        try {
+            Date date = fmt.parse("29MAY97");
+            cal.setTime(date);
+        } catch (Exception e) {
+        }
+        cal.set(HOUR_OF_DAY, 13);
+        logln("Hour: " + cal.get(HOUR_OF_DAY));
+        cal.add(HOUR_OF_DAY, 6);
+        logln("Hour: " + cal.get(HOUR_OF_DAY));
+        if (cal.get(HOUR_OF_DAY) != 19) {
+            errln("Fail: Want 19 Got " + cal.get(HOUR_OF_DAY));
+        }
     }
 
     public void Test4070502() {
+        @SuppressWarnings("deprecation")
         Date d = getAssociatedDate(new Date(98, 0, 30));
         Calendar cal = new GregorianCalendar();
         cal.setTime(d);
-        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY ||
-            cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
+        if (cal.get(DAY_OF_WEEK) == SATURDAY
+                || cal.get(DAY_OF_WEEK) == SUNDAY) {
             errln("Fail: Want weekday Got " + d);
+        }
     }
 
     /**
@@ -260,13 +278,13 @@
         //cal.add(field, amount); //<-- PROBLEM SEEN WITH field = DATE,MONTH
         // cal.getTime();  // <--- REMOVE THIS TO SEE BUG
         while (true) {
-            int wd = cal.get(Calendar.DAY_OF_WEEK);
-            if (wd == Calendar.SATURDAY || wd == Calendar.SUNDAY) {
-                cal.add(Calendar.DATE, 1);
+            int wd = cal.get(DAY_OF_WEEK);
+            if (wd == SATURDAY || wd == SUNDAY) {
+                cal.add(DATE, 1);
                 // cal.getTime();
+            } else {
+                break;
             }
-            else
-                break;
         }
         return cal.getTime();
     }
@@ -278,41 +296,47 @@
 
     void dowTest(boolean lenient) {
         GregorianCalendar cal = new GregorianCalendar();
-        cal.set(1997, Calendar.AUGUST, 12); // Wednesday
+        cal.set(1997, AUGUST, 12); // Wednesday
         // cal.getTime(); // Force update
         cal.setLenient(lenient);
-        cal.set(1996, Calendar.DECEMBER, 1); // Set the date to be December 1, 1996
-        int dow = cal.get(Calendar.DAY_OF_WEEK);
-        int min = cal.getMinimum(Calendar.DAY_OF_WEEK);
-        int max = cal.getMaximum(Calendar.DAY_OF_WEEK);
+        cal.set(1996, DECEMBER, 1); // Set the date to be December 1, 1996
+        int dow = cal.get(DAY_OF_WEEK);
+        int min = cal.getMinimum(DAY_OF_WEEK);
+        int max = cal.getMaximum(DAY_OF_WEEK);
         logln(cal.getTime().toString());
-        if (min != Calendar.SUNDAY || max != Calendar.SATURDAY)
+        if (min != SUNDAY || max != SATURDAY) {
             errln("FAIL: Min/max bad");
-        if (dow < min || dow > max)
+        }
+        if (dow < min || dow > max) {
             errln("FAIL: Day of week " + dow + " out of range");
-        if (dow != Calendar.SUNDAY)
+        }
+        if (dow != SUNDAY) {
             errln("FAIL: Day of week should be SUNDAY Got " + dow);
+        }
     }
 
+    @SuppressWarnings("deprecation")
     public void Test4071385() {
         Calendar cal = Calendar.getInstance();
-        cal.setTime(new Date(98, Calendar.JUNE, 24));
-        cal.set(Calendar.MONTH, Calendar.NOVEMBER); // change a field
+        cal.setTime(new Date(98, JUNE, 24));
+        cal.set(MONTH, NOVEMBER); // change a field
         logln(cal.getTime().toString());
-        if (!cal.getTime().equals(new Date(98, Calendar.NOVEMBER, 24)))
+        if (!cal.getTime().equals(new Date(98, NOVEMBER, 24))) {
             errln("Fail");
+        }
     }
 
     public void Test4073929() {
         GregorianCalendar foo1 = new GregorianCalendar(1997, 8, 27);
-        foo1.add(Calendar.DAY_OF_MONTH, +1);
-        int testyear = foo1.get(Calendar.YEAR);
-        int testmonth = foo1.get(Calendar.MONTH);
-        int testday = foo1.get(Calendar.DAY_OF_MONTH);
-        if (testyear != 1997 ||
-            testmonth != 8 ||
-            testday != 28)
+        foo1.add(DAY_OF_MONTH, +1);
+        int testyear = foo1.get(YEAR);
+        int testmonth = foo1.get(MONTH);
+        int testday = foo1.get(DAY_OF_MONTH);
+        if (testyear != 1997
+                || testmonth != 8
+                || testday != 28) {
             errln("Fail: Calendar not initialized");
+        }
     }
 
     public void Test4083167() {
@@ -322,27 +346,26 @@
             Date firstDate = new Date();
             Calendar cal = new GregorianCalendar();
             cal.setTime(firstDate);
-            long firstMillisInDay = cal.get(Calendar.HOUR_OF_DAY) * 3600000L +
-                                    cal.get(Calendar.MINUTE) * 60000L +
-                                    cal.get(Calendar.SECOND) * 1000L +
-                                    cal.get(Calendar.MILLISECOND);
+            long firstMillisInDay = cal.get(HOUR_OF_DAY) * 3600000L
+                    + cal.get(MINUTE) * 60000L
+                    + cal.get(SECOND) * 1000L
+                    + cal.get(MILLISECOND);
 
             logln("Current time: " + firstDate.toString());
 
-            for (int validity=0; validity<30; validity++) {
-                Date lastDate = new Date(firstDate.getTime() +
-                                         (long)validity*1000*24*60*60);
+            for (int validity = 0; validity < 30; validity++) {
+                Date lastDate = new Date(firstDate.getTime()
+                        + (long) validity * 1000 * 24 * 60 * 60);
                 cal.setTime(lastDate);
-                long millisInDay = cal.get(Calendar.HOUR_OF_DAY) * 3600000L +
-                                   cal.get(Calendar.MINUTE) * 60000L +
-                                   cal.get(Calendar.SECOND) * 1000L +
-                                   cal.get(Calendar.MILLISECOND);
+                long millisInDay = cal.get(HOUR_OF_DAY) * 3600000L
+                        + cal.get(MINUTE) * 60000L
+                        + cal.get(SECOND) * 1000L
+                        + cal.get(MILLISECOND);
                 if (firstMillisInDay != millisInDay) {
                     errln("Day has shifted " + lastDate);
                 }
             }
-        }
-        finally {
+        } finally {
             TimeZone.setDefault(saveZone);
         }
     }
@@ -359,61 +382,60 @@
             TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
             date = new SimpleDateFormat("zzzz");
 
-            Calendar cal=Calendar.getInstance();
-            cal.set(1997,Calendar.SEPTEMBER,30);
-            Date now=cal.getTime();
+            Calendar cal = Calendar.getInstance();
+            cal.set(1997, SEPTEMBER, 30);
+            Date now = cal.getTime();
             String formattedDate = date.format(now);
             if (!formattedDate.equals(summerTime)) {
                 errln("Wrong display name \"" + formattedDate
-                      + "\" for <" + now + ">");
+                        + "\" for <" + now + ">");
             }
-            int weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
+            int weekOfYear = cal.get(WEEK_OF_YEAR);
             if (weekOfYear != 40) {
                 errln("Wrong week-of-year " + weekOfYear
-                      + " for <" + now + ">");
+                        + " for <" + now + ">");
             }
 
-            cal.set(1996,Calendar.DECEMBER,31);
-            now=cal.getTime();
+            cal.set(1996, DECEMBER, 31);
+            now = cal.getTime();
             formattedDate = date.format(now);
             if (!formattedDate.equals(standardTime)) {
                 errln("Wrong display name \"" + formattedDate
-                      + "\" for <" + now + ">");
+                        + "\" for <" + now + ">");
             }
-            weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
+            weekOfYear = cal.get(WEEK_OF_YEAR);
             if (weekOfYear != 1) {
                 errln("Wrong week-of-year " + weekOfYear
-                      + " for <" + now + ">");
+                        + " for <" + now + ">");
             }
 
-            cal.set(1997,Calendar.JANUARY,1);
-            now=cal.getTime();
+            cal.set(1997, JANUARY, 1);
+            now = cal.getTime();
             formattedDate = date.format(now);
             if (!formattedDate.equals(standardTime)) {
                 errln("Wrong display name \"" + formattedDate
-                      + "\" for <" + now + ">");
+                        + "\" for <" + now + ">");
             }
-            weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
+            weekOfYear = cal.get(WEEK_OF_YEAR);
             if (weekOfYear != 1) {
                 errln("Wrong week-of-year " + weekOfYear
-                      + " for <" + now + ">");
+                        + " for <" + now + ">");
             }
 
-            cal.set(1997,Calendar.JANUARY,8);
-            now=cal.getTime();
+            cal.set(1997, JANUARY, 8);
+            now = cal.getTime();
             formattedDate = date.format(now);
             if (!formattedDate.equals(standardTime)) {
                 errln("Wrong display name \"" + formattedDate
-                      + "\" for <" + now + ">");
+                        + "\" for <" + now + ">");
             }
-            weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
+            weekOfYear = cal.get(WEEK_OF_YEAR);
             if (weekOfYear != 2) {
                 errln("Wrong week-of-year " + weekOfYear
-                      + " for <" + now + ">");
+                        + " for <" + now + ">");
             }
 
-        }
-        finally {
+        } finally {
             Locale.setDefault(saveLocale);
             TimeZone.setDefault(saveZone);
         }
@@ -428,9 +450,9 @@
         cal1.set( Calendar.MINUTE, 20 );
         cal1.set( Calendar.SECOND, 40 ); */
 
-        logln( " Cal1 = " + cal1.getTime().getTime() );
-        logln( " Cal1 time in ms = " + cal1.get(Calendar.MILLISECOND) );
-        for( int k = 0; k < 100 ; k++ );
+        logln(" Cal1 = " + cal1.getTime().getTime());
+        logln(" Cal1 time in ms = " + cal1.get(MILLISECOND));
+        for (int k = 0; k < 100; k++);
 
         GregorianCalendar cal2 = new GregorianCalendar(1997, 10, 11, 10, 20, 40);
         /*cal2.set( Calendar.YEAR, 1997 );
@@ -440,17 +462,19 @@
         cal2.set( Calendar.MINUTE, 20 );
         cal2.set( Calendar.SECOND, 40 ); */
 
-        logln( " Cal2 = " + cal2.getTime().getTime() );
-        logln( " Cal2 time in ms = " + cal2.get(Calendar.MILLISECOND) );
-        if( !cal1.equals( cal2 ) )
+        logln(" Cal2 = " + cal2.getTime().getTime());
+        logln(" Cal2 time in ms = " + cal2.get(MILLISECOND));
+        if (!cal1.equals(cal2)) {
             errln("Fail: Milliseconds randomized");
+        }
     }
 
     public void Test4095407() {
-        GregorianCalendar a = new GregorianCalendar(1997,Calendar.NOVEMBER, 13);
-        int dow = a.get(Calendar.DAY_OF_WEEK);
-        if (dow != Calendar.THURSDAY)
+        GregorianCalendar a = new GregorianCalendar(1997, NOVEMBER, 13);
+        int dow = a.get(DAY_OF_WEEK);
+        if (dow != THURSDAY) {
             errln("Fail: Want THURSDAY Got " + dow);
+        }
     }
 
     public void Test4096231() {
@@ -461,72 +485,74 @@
         Calendar cal1 = new GregorianCalendar(PST);
         cal1.setTime(new Date(880698639000L));
         int p;
-        logln("PST 1 is: " + (p=cal1.get(cal1.HOUR_OF_DAY)));
+        logln("PST 1 is: " + (p = cal1.get(HOUR_OF_DAY)));
         cal1.setTimeZone(GMT);
         // Issue 1: Changing the timezone doesn't change the
         //          represented time.
-        int h1,h2;
-        logln("GMT 1 is: " + (h1=cal1.get(cal1.HOUR_OF_DAY)));
+        int h1, h2;
+        logln("GMT 1 is: " + (h1 = cal1.get(HOUR_OF_DAY)));
         cal1.setTime(new Date(880698639000L));
-        logln("GMT 2 is: " + (h2=cal1.get(cal1.HOUR_OF_DAY)));
+        logln("GMT 2 is: " + (h2 = cal1.get(HOUR_OF_DAY)));
         // Note: This test had a bug in it.  It wanted h1!=h2, when
         // what was meant was h1!=p.  Fixed this concurrent with fix
         // to 4177484.
-        if (p == h1 || h1 != h2)
+        if (p == h1 || h1 != h2) {
             errln("Fail: Hour same in different zones");
+        }
 
         Calendar cal2 = new GregorianCalendar(GMT);
         Calendar cal3 = new GregorianCalendar(PST);
-        cal2.set(Calendar.MILLISECOND, 0);
-        cal3.set(Calendar.MILLISECOND, 0);
+        cal2.set(MILLISECOND, 0);
+        cal3.set(MILLISECOND, 0);
 
-        cal2.set(cal1.get(cal1.YEAR),
-                 cal1.get(cal1.MONTH),
-                 cal1.get(cal1.DAY_OF_MONTH),
-                 cal1.get(cal1.HOUR_OF_DAY),
-                 cal1.get(cal1.MINUTE),
-                 cal1.get(cal1.SECOND));
+        cal2.set(cal1.get(YEAR),
+                cal1.get(MONTH),
+                cal1.get(DAY_OF_MONTH),
+                cal1.get(HOUR_OF_DAY),
+                cal1.get(MINUTE),
+                cal1.get(SECOND));
 
-        long t1,t2,t3,t4;
-        logln("RGMT 1 is: " + (t1=cal2.getTime().getTime()));
+        long t1, t2, t3, t4;
+        logln("RGMT 1 is: " + (t1 = cal2.getTime().getTime()));
         cal3.set(year, month, day, hr, min, sec);
-        logln("RPST 1 is: " + (t2=cal3.getTime().getTime()));
+        logln("RPST 1 is: " + (t2 = cal3.getTime().getTime()));
         cal3.setTimeZone(GMT);
-        logln("RGMT 2 is: " + (t3=cal3.getTime().getTime()));
-        cal3.set(cal1.get(cal1.YEAR),
-                 cal1.get(cal1.MONTH),
-                 cal1.get(cal1.DAY_OF_MONTH),
-                 cal1.get(cal1.HOUR_OF_DAY),
-                 cal1.get(cal1.MINUTE),
-                 cal1.get(cal1.SECOND));
+        logln("RGMT 2 is: " + (t3 = cal3.getTime().getTime()));
+        cal3.set(cal1.get(YEAR),
+                cal1.get(MONTH),
+                cal1.get(DAY_OF_MONTH),
+                cal1.get(HOUR_OF_DAY),
+                cal1.get(MINUTE),
+                cal1.get(SECOND));
         // Issue 2: Calendar continues to use the timezone in its
         //          constructor for set() conversions, regardless
         //          of calls to setTimeZone()
-        logln("RGMT 3 is: " + (t4=cal3.getTime().getTime()));
-        if (t1 == t2 ||
-            t1 != t4 ||
-            t2 != t3)
+        logln("RGMT 3 is: " + (t4 = cal3.getTime().getTime()));
+        if (t1 == t2
+                || t1 != t4
+                || t2 != t3) {
             errln("Fail: Calendar zone behavior faulty");
+        }
     }
 
     public void Test4096539() {
-        int[] y = {31,28,31,30,31,30,31,31,30,31,30,31};
+        int[] y = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
+        for (int x = 0; x < 12; x++) {
+            GregorianCalendar gc = new GregorianCalendar(1997, x, y[x]);
+            int m1, m2;
+            log((m1 = gc.get(MONTH) + 1) + "/"
+                    + gc.get(DATE) + "/" + gc.get(YEAR)
+                    + " + 1mo = ");
 
-        for (int x=0;x<12;x++) {
-            GregorianCalendar gc = new
-                GregorianCalendar(1997,x,y[x]);
-            int m1,m2;
-            log((m1=gc.get(Calendar.MONTH)+1)+"/"+
-                             gc.get(Calendar.DATE)+"/"+gc.get(Calendar.YEAR)+
-                             " + 1mo = ");
-
-            gc.add(Calendar.MONTH, 1);
-            logln((m2=gc.get(Calendar.MONTH)+1)+"/"+
-                               gc.get(Calendar.DATE)+"/"+gc.get(Calendar.YEAR)
-                               );
+            gc.add(MONTH, 1);
+            logln((m2 = gc.get(MONTH) + 1) + "/"
+                    + gc.get(DATE) + "/" + gc.get(YEAR)
+            );
             int m = (m1 % 12) + 1;
-            if (m2 != m)
+            if (m2 != m) {
                 errln("Fail: Want " + m + " Got " + m2);
+            }
         }
 
     }
@@ -538,13 +564,14 @@
             return;
         }
 
-        GregorianCalendar cal = (GregorianCalendar)Calendar.getInstance();
-        cal.set(Calendar.YEAR, 1997);
-        cal.set(Calendar.DAY_OF_YEAR, 1);
+        GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
+        cal.set(YEAR, 1997);
+        cal.set(DAY_OF_YEAR, 1);
         Date d = cal.getTime();             // Should be Jan 1
         logln(d.toString());
-        if (cal.get(Calendar.DAY_OF_YEAR) != 1)
+        if (cal.get(DAY_OF_YEAR) != 1) {
             errln("Fail: DAY_OF_YEAR not set");
+        }
     }
 
     public void Test4103271() {
@@ -555,28 +582,28 @@
         }
 
         SimpleDateFormat sdf = new SimpleDateFormat();
-        int numYears=40, startYear=1997, numDays=15;
+        int numYears = 40, startYear = 1997, numDays = 15;
         String output, testDesc;
-        GregorianCalendar testCal = (GregorianCalendar)Calendar.getInstance();
+        GregorianCalendar testCal = (GregorianCalendar) Calendar.getInstance();
         testCal.clear();
         sdf.setCalendar(testCal);
         sdf.applyPattern("d MMM yyyy");
         boolean fail = false;
-        for (int firstDay=1; firstDay<=2; firstDay++) {
-            for (int minDays=1; minDays<=7; minDays++) {
+        for (int firstDay = 1; firstDay <= 2; firstDay++) {
+            for (int minDays = 1; minDays <= 7; minDays++) {
                 testCal.setMinimalDaysInFirstWeek(minDays);
                 testCal.setFirstDayOfWeek(firstDay);
                 testDesc = ("Test" + String.valueOf(firstDay) + String.valueOf(minDays));
-                logln(testDesc + " => 1st day of week=" +
-                                   String.valueOf(firstDay) +
-                                   ", minimum days in first week=" +
-                                   String.valueOf(minDays));
-                for (int j=startYear; j<=startYear+numYears; j++) {
-                    testCal.set(j,11,25);
-                    for(int i=0; i<numDays; i++) {
-                        testCal.add(Calendar.DATE,1);
+                logln(testDesc + " => 1st day of week="
+                        + String.valueOf(firstDay)
+                        + ", minimum days in first week="
+                        + String.valueOf(minDays));
+                for (int j = startYear; j <= startYear + numYears; j++) {
+                    testCal.set(j, 11, 25);
+                    for (int i = 0; i < numDays; i++) {
+                        testCal.add(DATE, 1);
                         String calWOY;
-                        int actWOY = testCal.get(Calendar.WEEK_OF_YEAR);
+                        int actWOY = testCal.get(WEEK_OF_YEAR);
                         if (actWOY < 1 || actWOY > 53) {
                             Date d = testCal.getTime();
                             calWOY = String.valueOf(actWOY);
@@ -592,20 +619,19 @@
 
         int[] DATA = {
             3, 52, 52, 52, 52, 52, 52, 52,
-                1,  1,  1,  1,  1,  1,  1,
-                2,  2,  2,  2,  2,  2,  2,
+            1, 1, 1, 1, 1, 1, 1,
+            2, 2, 2, 2, 2, 2, 2,
             4, 52, 52, 52, 52, 52, 52, 52,
-               53, 53, 53, 53, 53, 53, 53,
-                1,  1,  1,  1,  1,  1,  1,
-        };
-        testCal.setFirstDayOfWeek(Calendar.SUNDAY);
-        for (int j=0; j<DATA.length; j+=22) {
-            logln("Minimal days in first week = " + DATA[j] +
-                               "  Week starts on Sunday");
+            53, 53, 53, 53, 53, 53, 53,
+            1, 1, 1, 1, 1, 1, 1};
+        testCal.setFirstDayOfWeek(SUNDAY);
+        for (int j = 0; j < DATA.length; j += 22) {
+            logln("Minimal days in first week = " + DATA[j]
+                    + "  Week starts on Sunday");
             testCal.setMinimalDaysInFirstWeek(DATA[j]);
-            testCal.set(1997, Calendar.DECEMBER, 21);
-            for (int i=0; i<21; ++i) {
-                int woy = testCal.get(Calendar.WEEK_OF_YEAR);
+            testCal.set(1997, DECEMBER, 21);
+            for (int i = 0; i < 21; ++i) {
+                int woy = testCal.get(WEEK_OF_YEAR);
                 log("\t" + testCal.getTime() + " " + woy);
                 if (woy != DATA[j + 1 + i]) {
                     log(" ERROR");
@@ -618,47 +644,47 @@
                 // get the same answer back.  This is a round-trip test.
                 Date save = testCal.getTime();
                 testCal.clear();
-                testCal.set(Calendar.YEAR, DATA[j+1+i] < 25 ? 1998 : 1997);
-                testCal.set(Calendar.WEEK_OF_YEAR, DATA[j+1+i]);
-                testCal.set(Calendar.DAY_OF_WEEK, (i%7) + Calendar.SUNDAY);
+                testCal.set(YEAR, DATA[j + 1 + i] < 25 ? 1998 : 1997);
+                testCal.set(WEEK_OF_YEAR, DATA[j + 1 + i]);
+                testCal.set(DAY_OF_WEEK, (i % 7) + SUNDAY);
                 if (!testCal.getTime().equals(save)) {
                     logln("  Parse failed: " + testCal.getTime());
-                    fail= true;
+                    fail = true;
                 } else {
                     logln("  Passed");
                 }
 
                 testCal.setTime(save);
-                testCal.add(Calendar.DAY_OF_MONTH, 1);
+                testCal.add(DAY_OF_MONTH, 1);
             }
         }
 
         // Test field disambiguation with a few special hard-coded cases.
         // This shouldn't fail if the above cases aren't failing.
+        @SuppressWarnings("deprecation")
         Object[] DISAM = {
-            new Integer(1998), new Integer(1), new Integer(Calendar.SUNDAY),
-                new Date(97, Calendar.DECEMBER, 28),
-            new Integer(1998), new Integer(2), new Integer(Calendar.SATURDAY),
-                new Date(98, Calendar.JANUARY, 10),
-            new Integer(1998), new Integer(53), new Integer(Calendar.THURSDAY),
-                new Date(98, Calendar.DECEMBER, 31),
-            new Integer(1998), new Integer(53), new Integer(Calendar.FRIDAY),
-                new Date(99, Calendar.JANUARY, 1),
-        };
+            1998, 1, SUNDAY,
+            new Date(97, DECEMBER, 28),
+            1998, 2, SATURDAY,
+            new Date(98, JANUARY, 10),
+            1998, 53, THURSDAY,
+            new Date(98, DECEMBER, 31),
+            1998, 53, FRIDAY,
+            new Date(99, JANUARY, 1)};
         testCal.setMinimalDaysInFirstWeek(3);
-        testCal.setFirstDayOfWeek(Calendar.SUNDAY);
-        for (int i=0; i<DISAM.length; i+=4) {
-            int y = ((Integer)DISAM[i]).intValue();
-            int woy = ((Integer)DISAM[i+1]).intValue();
-            int dow = ((Integer)DISAM[i+2]).intValue();
-            Date exp = (Date)DISAM[i+3];
+        testCal.setFirstDayOfWeek(SUNDAY);
+        for (int i = 0; i < DISAM.length; i += 4) {
+            int y = (Integer) DISAM[i];
+            int woy = (Integer) DISAM[i + 1];
+            int dow = (Integer) DISAM[i + 2];
+            Date exp = (Date) DISAM[i + 3];
             testCal.clear();
-            testCal.set(Calendar.YEAR, y);
-            testCal.set(Calendar.WEEK_OF_YEAR, woy);
-            testCal.set(Calendar.DAY_OF_WEEK, dow);
+            testCal.set(YEAR, y);
+            testCal.set(WEEK_OF_YEAR, woy);
+            testCal.set(DAY_OF_WEEK, dow);
             log(y + "-W" + woy + "-DOW" + dow);
             if (!testCal.getTime().equals(exp)) {
-                logln("  FAILED expect: " + exp + "\n            got: " +testCal.getTime());
+                logln("  FAILED expect: " + exp + "\n            got: " + testCal.getTime());
                 fail = true;
             } else {
                 logln("  OK");
@@ -668,47 +694,51 @@
         // Now try adding and rolling
         Object ADD = new Object();
         Object ROLL = new Object();
+        @SuppressWarnings("deprecation")
         Object[] ADDROLL = {
-            ADD, new Integer(1), new Date(98, Calendar.DECEMBER, 25), new Date(99, Calendar.JANUARY, 1),
-            ADD, new Integer(1), new Date(97, Calendar.DECEMBER, 28), new Date(98, Calendar.JANUARY, 4),
-            ROLL, new Integer(1), new Date(98, Calendar.DECEMBER, 27), new Date(98, Calendar.JANUARY, 4),
-            ROLL, new Integer(1), new Date(99, Calendar.DECEMBER, 24), new Date(99, Calendar.DECEMBER, 31),
-            ROLL, new Integer(1), new Date(99, Calendar.DECEMBER, 25), new Date(99, Calendar.JANUARY, 9),
-        };
+            ADD, 1, new Date(98, DECEMBER, 25), new Date(99, JANUARY, 1),
+            ADD, 1, new Date(97, DECEMBER, 28), new Date(98, JANUARY, 4),
+            ROLL, 1, new Date(98, DECEMBER, 27), new Date(98, JANUARY, 4),
+            ROLL, 1, new Date(99, DECEMBER, 24), new Date(99, DECEMBER, 31),
+            ROLL, 1, new Date(99, DECEMBER, 25), new Date(99, JANUARY, 9)};
         testCal.setMinimalDaysInFirstWeek(3);
-        testCal.setFirstDayOfWeek(Calendar.SUNDAY);
-        for (int i=0; i<ADDROLL.length; i+=4) {
-            int amount = ((Integer)ADDROLL[i+1]).intValue();
-            Date before = (Date)ADDROLL[i+2];
-            Date after = (Date)ADDROLL[i+3];
+        testCal.setFirstDayOfWeek(SUNDAY);
+        for (int i = 0; i < ADDROLL.length; i += 4) {
+            int amount = (Integer) ADDROLL[i + 1];
+            Date before = (Date) ADDROLL[i + 2];
+            Date after = (Date) ADDROLL[i + 3];
 
             testCal.setTime(before);
-            if (ADDROLL[i] == ADD)
-                testCal.add(Calendar.WEEK_OF_YEAR, amount);
-            else
-                testCal.roll(Calendar.WEEK_OF_YEAR, amount);
-            log((ADDROLL[i]==ADD ? "add(WOY," : "roll(WOY,") +
-                amount + ")\t     " + before +
-                "\n\t\t  => " + testCal.getTime());
+            if (ADDROLL[i] == ADD) {
+                testCal.add(WEEK_OF_YEAR, amount);
+            } else {
+                testCal.roll(WEEK_OF_YEAR, amount);
+            }
+            log((ADDROLL[i] == ADD ? "add(WOY," : "roll(WOY,")
+                    + amount + ")\t     " + before
+                    + "\n\t\t  => " + testCal.getTime());
             if (!after.equals(testCal.getTime())) {
                 logln("\tFAIL\n\t\texp: " + after);
                 fail = true;
-            } else
+            } else {
                 logln("  OK");
+            }
 
             testCal.setTime(after);
-            if (ADDROLL[i] == ADD)
-                testCal.add(Calendar.WEEK_OF_YEAR, -amount);
-            else
-                testCal.roll(Calendar.WEEK_OF_YEAR, -amount);
-            log((ADDROLL[i]==ADD ? "add(WOY," : "roll(WOY,") +
-                (-amount) + ")     " + after +
-                "\n\t\t  => " + testCal.getTime());
+            if (ADDROLL[i] == ADD) {
+                testCal.add(WEEK_OF_YEAR, -amount);
+            } else {
+                testCal.roll(WEEK_OF_YEAR, -amount);
+            }
+            log((ADDROLL[i] == ADD ? "add(WOY," : "roll(WOY,")
+                    + (-amount) + ")     " + after
+                    + "\n\t\t  => " + testCal.getTime());
             if (!before.equals(testCal.getTime())) {
                 logln("\tFAIL\n\t\texp: " + before);
                 fail = true;
+            } else {
+                logln("\tOK");
             }
-            else logln("\tOK");
         }
 
         if (fail) {
@@ -719,63 +749,68 @@
     public void Test4106136() {
         Locale saveLocale = Locale.getDefault();
         try {
-            Locale[] locales = { Locale.CHINESE, Locale.CHINA };
-            for (int i=0; i<locales.length; ++i) {
+            Locale[] locales = {Locale.CHINESE, Locale.CHINA};
+            for (int i = 0; i < locales.length; ++i) {
                 Locale.setDefault(locales[i]);
                 int[] n = {
-                    Calendar.getAvailableLocales().length,
+                    getAvailableLocales().length,
                     DateFormat.getAvailableLocales().length,
-                    NumberFormat.getAvailableLocales().length
-                };
-                for (int j=0; j<n.length; ++j) {
+                    NumberFormat.getAvailableLocales().length};
+                for (int j = 0; j < n.length; ++j) {
                     if (n[j] == 0) {
                         errln("Fail: No locales for " + locales[i]);
                     }
                 }
             }
-        }
-        finally {
+        } finally {
             Locale.setDefault(saveLocale);
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void Test4108764() {
-        Date d00 = new Date(97, Calendar.MARCH, 15, 12, 00, 00);
-        Date d01 = new Date(97, Calendar.MARCH, 15, 12, 00, 56);
-        Date d10 = new Date(97, Calendar.MARCH, 15, 12, 34, 00);
-        Date d11 = new Date(97, Calendar.MARCH, 15, 12, 34, 56);
-        Date epoch = new Date(70, Calendar.JANUARY, 1);
+        Date d00 = new Date(97, MARCH, 15, 12, 00, 00);
+        Date d01 = new Date(97, MARCH, 15, 12, 00, 56);
+        Date d10 = new Date(97, MARCH, 15, 12, 34, 00);
+        Date d11 = new Date(97, MARCH, 15, 12, 34, 56);
+        Date epoch = new Date(70, JANUARY, 1);
 
         Calendar cal = Calendar.getInstance();
         cal.setTime(d11);
 
-        cal.clear( Calendar.MINUTE );
+        cal.clear(MINUTE);
         logln(cal.getTime().toString());
-        if (!cal.getTime().equals(d01))
+        if (!cal.getTime().equals(d01)) {
             errln("Fail: clear(MINUTE) broken");
+        }
 
-        cal.set( Calendar.SECOND, 0 );
+        cal.set(SECOND, 0);
         logln(cal.getTime().toString());
-        if (!cal.getTime().equals(d00))
+        if (!cal.getTime().equals(d00)) {
             errln("Fail: set(SECOND, 0) broken");
+        }
 
         cal.setTime(d11);
-        cal.set( Calendar.SECOND, 0 );
+        cal.set(SECOND, 0);
         logln(cal.getTime().toString());
-        if (!cal.getTime().equals(d10))
+        if (!cal.getTime().equals(d10)) {
             errln("Fail: set(SECOND, 0) broken #2");
+        }
 
-        cal.clear( Calendar.MINUTE );
+        cal.clear(MINUTE);
         logln(cal.getTime().toString());
-        if (!cal.getTime().equals(d00))
+        if (!cal.getTime().equals(d00)) {
             errln("Fail: clear(MINUTE) broken #2");
+        }
 
         cal.clear();
         logln(cal.getTime().toString());
-        if (!cal.getTime().equals(epoch))
+        if (!cal.getTime().equals(epoch)) {
             errln("Fail: clear() broken Want " + epoch);
+        }
     }
 
+    @SuppressWarnings("deprecation")
     public void Test4114578() {
         Locale locale = Locale.getDefault();
         if (!TestUtils.usesGregorianCalendar(locale)) {
@@ -783,14 +818,14 @@
             return;
         }
 
-        int ONE_HOUR = 60*60*1000;
+        int ONE_HOUR = 60 * 60 * 1000;
         TimeZone saveZone = TimeZone.getDefault();
         boolean fail = false;
         try {
             TimeZone.setDefault(TimeZone.getTimeZone("PST"));
             Calendar cal = Calendar.getInstance();
-            long onset = new Date(98, Calendar.APRIL, 5, 1, 0).getTime() + ONE_HOUR;
-            long cease = new Date(98, Calendar.OCTOBER, 25, 0, 0).getTime() + 2*ONE_HOUR;
+            long onset = new Date(98, APRIL, 5, 1, 0).getTime() + ONE_HOUR;
+            long cease = new Date(98, OCTOBER, 25, 0, 0).getTime() + 2 * ONE_HOUR;
 
             final int ADD = 1;
             final int ROLL = 2;
@@ -807,26 +842,25 @@
                 // time value may jump 2 hours by skipping non-existent wall-clock time.
                 // Note that JDK-4114578 was a problem of add(), not roll().
                 cease - ONE_HOUR,   ROLL,     1,     ONE_HOUR * 2,
-                cease,              ROLL,    -1,    -ONE_HOUR * 2,
-            };
+                cease,              ROLL,    -1,    -ONE_HOUR * 2};
 
-            for (int i=0; i<DATA.length; i+=4) {
+            for (int i = 0; i < DATA.length; i += 4) {
                 Date date = new Date(DATA[i]);
-                int amt = (int) DATA[i+2];
-                long expectedChange = DATA[i+3];
+                int amt = (int) DATA[i + 2];
+                long expectedChange = DATA[i + 3];
 
                 log(date.toString());
                 cal.setTime(date);
 
-                switch ((int) DATA[i+1]) {
-                case ADD:
-                    log(" add (HOUR," + (amt<0?"":"+")+amt + ")= ");
-                    cal.add(Calendar.HOUR, amt);
-                    break;
-                case ROLL:
-                    log(" roll(HOUR," + (amt<0?"":"+")+amt + ")= ");
-                    cal.roll(Calendar.HOUR, amt);
-                    break;
+                switch ((int) DATA[i + 1]) {
+                    case ADD:
+                        log(" add (HOUR," + (amt < 0 ? "" : "+") + amt + ")= ");
+                        cal.add(HOUR, amt);
+                        break;
+                    case ROLL:
+                        log(" roll(HOUR," + (amt < 0 ? "" : "+") + amt + ")= ");
+                        cal.roll(HOUR, amt);
+                        break;
                 }
 
                 log(cal.getTime().toString());
@@ -835,8 +869,9 @@
                 if (change != expectedChange) {
                     fail = true;
                     logln(" FAIL");
+                } else {
+                    logln(" OK");
                 }
-                else logln(" OK");
             }
         } finally {
             TimeZone.setDefault(saveZone);
@@ -852,10 +887,11 @@
      */
     public void Test4118384() {
         Calendar cal = Calendar.getInstance();
-        if (cal.getMaximum(Calendar.HOUR) != 11 ||
-            cal.getLeastMaximum(Calendar.HOUR) != 11 ||
-            cal.getActualMaximum(Calendar.HOUR) != 11)
+        if (cal.getMaximum(HOUR) != 11
+                || cal.getLeastMaximum(HOUR) != 11
+                || cal.getActualMaximum(HOUR) != 11) {
             errln("Fail: maximum of HOUR field should be 11");
+        }
     }
 
     /**
@@ -871,13 +907,14 @@
         GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
         DateFormat fmt = new SimpleDateFormat("MMMM d, yyyy G");
         cal.clear();
-        for (int y=-20; y<=10; ++y) {
-            cal.set(Calendar.ERA, y < 1 ? GregorianCalendar.BC : GregorianCalendar.AD);
-            cal.set(Calendar.YEAR, y < 1 ? 1 - y : y);
-            logln(y + " = " + fmt.format(cal.getTime()) + " " +
-                               cal.isLeapYear(y));
-            if (cal.isLeapYear(y) != ((y+40)%4 == 0))
+        for (int y = -20; y <= 10; ++y) {
+            cal.set(ERA, y < 1 ? GregorianCalendar.BC : GregorianCalendar.AD);
+            cal.set(YEAR, y < 1 ? 1 - y : y);
+            logln(y + " = " + fmt.format(cal.getTime()) + " "
+                    + cal.isLeapYear(y));
+            if (cal.isLeapYear(y) != ((y + 40) % 4 == 0)) {
                 errln("Leap years broken");
+            }
         }
     }
 
@@ -895,14 +932,15 @@
         GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
         DateFormat fmt = new SimpleDateFormat("MMMM d, yyyy G");
         cal.clear();
-        cal.set(Calendar.ERA, GregorianCalendar.BC);
-        cal.set(Calendar.YEAR, 81); // 81 BC is a leap year (proleptically)
-        cal.set(Calendar.MONTH, Calendar.FEBRUARY);
-        cal.set(Calendar.DATE, 28);
-        cal.add(Calendar.DATE, 1);
-        if (cal.get(Calendar.DATE) != 29 ||
-            !cal.isLeapYear(-80)) // -80 == 81 BC
+        cal.set(ERA, GregorianCalendar.BC);
+        cal.set(YEAR, 81); // 81 BC is a leap year (proleptically)
+        cal.set(MONTH, FEBRUARY);
+        cal.set(DATE, 28);
+        cal.add(DATE, 1);
+        if (cal.get(DATE) != 29
+                || !cal.isLeapYear(-80)) { // -80 == 81 BC
             errln("Calendar not proleptic");
+        }
     }
 
     /**
@@ -912,16 +950,16 @@
      */
     public void Test4136399() {
         /* Note: This test is actually more strict than it has to be.
-         * Technically, there is no requirement that unequal objects have
-         * unequal hashes.  We only require equal objects to have equal hashes.
-         * It is desirable for unequal objects to have distributed hashes, but
-         * there is no hard requirement here.
-         *
-         * In this test we make assumptions about certain attributes of calendar
-         * objects getting represented in the hash, which need not always be the
-         * case (although it does work currently with the given test). */
+        * Technically, there is no requirement that unequal objects have
+        * unequal hashes.  We only require equal objects to have equal hashes.
+        * It is desirable for unequal objects to have distributed hashes, but
+        * there is no hard requirement here.
+        *
+        * In this test we make assumptions about certain attributes of calendar
+        * objects getting represented in the hash, which need not always be the
+        * case (although it does work currently with the given test). */
         Calendar a = Calendar.getInstance();
-        Calendar b = (Calendar)a.clone();
+        Calendar b = (Calendar) a.clone();
         if (a.hashCode() != b.hashCode()) {
             errln("Calendar hash code unequal for cloned objects");
         }
@@ -946,19 +984,19 @@
 
         // Assume getTimeZone() returns a reference, not a clone
         // of a reference -- this is true as of this writing
-        b.getTimeZone().setRawOffset(a.getTimeZone().getRawOffset() + 60*60*1000);
+        b.getTimeZone().setRawOffset(a.getTimeZone().getRawOffset() + 60 * 60 * 1000);
         if (a.hashCode() == b.hashCode()) {
             errln("Calendar hash code ignores zone");
         }
         b.getTimeZone().setRawOffset(a.getTimeZone().getRawOffset());
 
         GregorianCalendar c = new GregorianCalendar();
-        GregorianCalendar d = (GregorianCalendar)c.clone();
+        GregorianCalendar d = (GregorianCalendar) c.clone();
         if (c.hashCode() != d.hashCode()) {
             errln("GregorianCalendar hash code unequal for clones objects");
         }
         Date cutover = c.getGregorianChange();
-        d.setGregorianChange(new Date(cutover.getTime() + 24*60*60*1000));
+        d.setGregorianChange(new Date(cutover.getTime() + 24 * 60 * 60 * 1000));
         if (c.hashCode() == d.hashCode()) {
             errln("GregorianCalendar hash code ignores cutover");
         }
@@ -969,9 +1007,9 @@
      */
     public void Test4141665() {
         GregorianCalendar cal = new GregorianCalendar();
-        GregorianCalendar cal2 = (GregorianCalendar)cal.clone();
+        GregorianCalendar cal2 = (GregorianCalendar) cal.clone();
         Date cut = cal.getGregorianChange();
-        Date cut2 = new Date(cut.getTime() + 100*24*60*60*1000L); // 100 days later
+        Date cut2 = new Date(cut.getTime() + 100 * 24 * 60 * 60 * 1000L); // 100 days later
         if (!cal.equals(cal2)) {
             errln("Cloned GregorianCalendars not equal");
         }
@@ -990,12 +1028,10 @@
         try {
             calendar.roll(-1, true);
             errln("Test failed, no exception trown");
-        }
-        catch (IllegalArgumentException e) {
+        } catch (IllegalArgumentException e) {
             // OK: Do nothing
             // logln("Test passed");
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             errln("Test failed. Unexpected exception is thrown: " + e);
             e.printStackTrace();
         }
@@ -1014,12 +1050,12 @@
         calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
 
         calendar.setTime(new Date(Long.MIN_VALUE));
-        int year1 = calendar.get(Calendar.YEAR);
-        int era1 = calendar.get(Calendar.ERA);
+        int year1 = calendar.get(YEAR);
+        int era1 = calendar.get(ERA);
 
         calendar.setTime(new Date(Long.MAX_VALUE));
-        int year2 = calendar.get(Calendar.YEAR);
-        int era2 = calendar.get(Calendar.ERA);
+        int year2 = calendar.get(YEAR);
+        int era2 = calendar.get(ERA);
 
         if (year1 == year2 && era1 == era2) {
             errln("Fail: Long.MIN_VALUE or Long.MAX_VALUE wrapping around");
@@ -1032,14 +1068,14 @@
     public void Test4145983() {
         GregorianCalendar calendar = new GregorianCalendar();
         calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
-        Date[] DATES = { new Date(Long.MAX_VALUE), new Date(Long.MIN_VALUE) };
-        for (int i=0; i<DATES.length; ++i) {
+        Date[] DATES = {new Date(Long.MAX_VALUE), new Date(Long.MIN_VALUE)};
+        for (int i = 0; i < DATES.length; ++i) {
             calendar.setTime(DATES[i]);
-            int year = calendar.get(Calendar.YEAR);
-            int maxYear = calendar.getMaximum(Calendar.YEAR);
+            int year = calendar.get(YEAR);
+            int maxYear = calendar.getMaximum(YEAR);
             if (year > maxYear) {
-                errln("Failed for "+DATES[i].getTime()+" ms: year=" +
-                      year + ", maxYear=" + maxYear);
+                errln("Failed for " + DATES[i].getTime() + " ms: year="
+                        + year + ", maxYear=" + maxYear);
             }
         }
     }
@@ -1068,28 +1104,29 @@
             "SECOND",
             "MILLISECOND",
             "ZONE_OFFSET",
-            "DST_OFFSET"
-        };
+            "DST_OFFSET"};
         GregorianCalendar calendar = new GregorianCalendar();
         calendar.setLenient(false);
-        Date date = new Date(1996-1900, Calendar.JANUARY, 3); // Arbitrary date
-        for (int field = 0; field < Calendar.FIELD_COUNT; field++) {
+        @SuppressWarnings("deprecation")
+        Date date = new Date(1996 - 1900, JANUARY, 3); // Arbitrary date
+        for (int field = 0; field < FIELD_COUNT; field++) {
             calendar.setTime(date);
             // Note: In the bug report, getActualMaximum() was called instead
             // of getMaximum() -- this was an error.  The validation code doesn't
             // use getActualMaximum(), since that's too costly.
             int max = calendar.getMaximum(field);
-            int value = max+1;
+            int value = max + 1;
             calendar.set(field, value);
             try {
                 calendar.getTime(); // Force time computation
                 // We expect an exception to be thrown. If we fall through
                 // to the next line, then we have a bug.
-                errln("Test failed with field " + fieldName[field] +
-                      ", date before: " + date +
-                      ", date after: " + calendar.getTime() +
-                      ", value: " + value + " (max = " + max +")");
-            } catch (IllegalArgumentException e) {}
+                errln("Test failed with field " + fieldName[field]
+                        + ", date before: " + date
+                        + ", date after: " + calendar.getTime()
+                        + ", value: " + value + " (max = " + max + ")");
+            } catch (IllegalArgumentException e) {
+            }
         }
     }
 
@@ -1099,19 +1136,19 @@
      * CANNOT REPRODUCE THIS BUG
      */
     public void Test4149677() {
-        TimeZone[] zones = { TimeZone.getTimeZone("GMT"),
-                             TimeZone.getTimeZone("PST"),
-                             TimeZone.getTimeZone("EAT") };
-        for (int i=0; i<zones.length; ++i) {
+        TimeZone[] zones = {TimeZone.getTimeZone("GMT"),
+            TimeZone.getTimeZone("PST"),
+            TimeZone.getTimeZone("EAT")};
+        for (int i = 0; i < zones.length; ++i) {
             GregorianCalendar calendar = new GregorianCalendar(zones[i]);
 
             // Make sure extreme values don't wrap around
             calendar.setTime(new Date(Long.MIN_VALUE));
-            if (calendar.get(Calendar.ERA) != GregorianCalendar.BC) {
+            if (calendar.get(ERA) != GregorianCalendar.BC) {
                 errln("Fail: Date(Long.MIN_VALUE) has an AD year in " + zones[i]);
             }
             calendar.setTime(new Date(Long.MAX_VALUE));
-            if (calendar.get(Calendar.ERA) != GregorianCalendar.AD) {
+            if (calendar.get(ERA) != GregorianCalendar.AD) {
                 errln("Fail: Date(Long.MAX_VALUE) has a BC year in " + zones[i]);
             }
 
@@ -1139,23 +1176,25 @@
         Date d;
 
         try {
-            for (int i=0; i<5; ++i) {
-                if (i>0) logln("---");
+            for (int i = 0; i < 5; ++i) {
+                if (i > 0) {
+                    logln("---");
+                }
 
                 cal.clear();
-                cal.set(1998, Calendar.APRIL, 5, i, 0);
+                cal.set(1998, APRIL, 5, i, 0);
                 d = cal.getTime();
                 String s0 = d.toString();
                 logln("0 " + i + ": " + s0);
 
                 cal.clear();
-                cal.set(1998, Calendar.APRIL, 4, i+24, 0);
+                cal.set(1998, APRIL, 4, i + 24, 0);
                 d = cal.getTime();
                 String sPlus = d.toString();
                 logln("+ " + i + ": " + sPlus);
 
                 cal.clear();
-                cal.set(1998, Calendar.APRIL, 6, i-24, 0);
+                cal.set(1998, APRIL, 6, i - 24, 0);
                 d = cal.getTime();
                 String sMinus = d.toString();
                 logln("- " + i + ": " + sMinus);
@@ -1164,8 +1203,7 @@
                     errln("Fail: All three lines must match");
                 }
             }
-        }
-        finally {
+        } finally {
             TimeZone.setDefault(savedTz);
         }
     }
@@ -1174,14 +1212,14 @@
      * Adding 12 months behaves differently from adding 1 year
      */
     public void Test4165343() {
-        GregorianCalendar calendar = new GregorianCalendar(1996, Calendar.FEBRUARY, 29);
+        GregorianCalendar calendar = new GregorianCalendar(1996, FEBRUARY, 29);
         Date start = calendar.getTime();
         logln("init date: " + start);
-        calendar.add(Calendar.MONTH, 12);
+        calendar.add(MONTH, 12);
         Date date1 = calendar.getTime();
         logln("after adding 12 months: " + date1);
         calendar.setTime(start);
-        calendar.add(Calendar.YEAR, 1);
+        calendar.add(YEAR, 1);
         Date date2 = calendar.getTime();
         logln("after adding one year : " + date2);
         if (date1.equals(date2)) {
@@ -1196,34 +1234,34 @@
      */
     public void Test4166109() {
         /* Test month:
-         *
-         *      March 1998
-         * Su Mo Tu We Th Fr Sa
-         *  1  2  3  4  5  6  7
-         *  8  9 10 11 12 13 14
-         * 15 16 17 18 19 20 21
-         * 22 23 24 25 26 27 28
-         * 29 30 31
+        *
+        *      March 1998
+        * Su Mo Tu We Th Fr Sa
+        *  1  2  3  4  5  6  7
+        *  8  9 10 11 12 13 14
+        * 15 16 17 18 19 20 21
+        * 22 23 24 25 26 27 28
+        * 29 30 31
          */
         boolean passed = true;
-        int field = Calendar.WEEK_OF_MONTH;
+        int field = WEEK_OF_MONTH;
 
         GregorianCalendar calendar = new GregorianCalendar(Locale.US);
-        calendar.set(1998, Calendar.MARCH, 1);
+        calendar.set(1998, MARCH, 1);
         calendar.setMinimalDaysInFirstWeek(1);
         logln("Date:  " + calendar.getTime());
 
-        int firstInMonth = calendar.get(Calendar.DAY_OF_MONTH);
+        int firstInMonth = calendar.get(DAY_OF_MONTH);
 
-        for (int firstInWeek = Calendar.SUNDAY; firstInWeek <= Calendar.SATURDAY; firstInWeek++) {
+        for (int firstInWeek = SUNDAY; firstInWeek <= SATURDAY; firstInWeek++) {
             calendar.setFirstDayOfWeek(firstInWeek);
             int returned = calendar.getActualMaximum(field);
-            int expected = (31 + ((firstInMonth - firstInWeek + 7)% 7) + 6) / 7;
+            int expected = (31 + ((firstInMonth - firstInWeek + 7) % 7) + 6) / 7;
 
-            logln("First day of week = " + firstInWeek +
-                  "  getActualMaximum(WEEK_OF_MONTH) = " + returned +
-                  "  expected = " + expected +
-                  ((returned == expected) ? "  ok" : "  FAIL"));
+            logln("First day of week = " + firstInWeek
+                    + "  getActualMaximum(WEEK_OF_MONTH) = " + returned
+                    + "  expected = " + expected
+                    + ((returned == expected) ? "  ok" : "  FAIL"));
 
             if (returned != expected) {
                 passed = false;
@@ -1242,19 +1280,19 @@
      * changed. See 4928615.
      */
     public void Test4167060() {
-        int field = Calendar.YEAR;
+        int field = YEAR;
         DateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy G",
-                                                 Locale.US);
+                Locale.US);
 
         int[][] dates = {
             // year, month, day of month
-            { 100, Calendar.NOVEMBER, 1 },
-            { -99 /*100BC*/, Calendar.JANUARY, 1 },
-            { 1996, Calendar.FEBRUARY, 29 }};
+            {100, NOVEMBER, 1},
+            {-99 /*100BC*/, JANUARY, 1},
+            {1996, FEBRUARY, 29}};
 
-        String[] id = { "Hybrid", "Gregorian", "Julian" };
+        String[] id = {"Hybrid", "Gregorian", "Julian"};
 
-        for (int k=0; k<3; ++k) {
+        for (int k = 0; k < 3; ++k) {
             logln("--- " + id[k] + " ---");
 
             for (int j = 0; j < dates.length; ++j) {
@@ -1265,7 +1303,7 @@
                     calendar.setGregorianChange(new Date(Long.MAX_VALUE));
                 }
                 calendar.set(dates[j][0], dates[j][1], dates[j][2]);
-                format.setCalendar((Calendar)calendar.clone());
+                format.setCalendar((Calendar) calendar.clone());
 
                 Date dateBefore = calendar.getTime();
 
@@ -1273,7 +1311,7 @@
                 logln("maxYear: " + maxYear + " for " + format.format(calendar.getTime()));
                 logln("date before: " + format.format(dateBefore));
 
-                int years[] = {2000, maxYear-1, maxYear, maxYear+1};
+                int[] years = {2000, maxYear - 1, maxYear, maxYear + 1};
 
                 for (int i = 0; i < years.length; i++) {
                     boolean valid = years[i] <= maxYear;
@@ -1282,8 +1320,8 @@
                     int newYear = calendar.get(field);
                     calendar.setTime(dateBefore); // restore calendar for next use
 
-                    logln(" Year " + years[i] + (valid? " ok " : " bad") +
-                          " => " + format.format(dateAfter));
+                    logln(" Year " + years[i] + (valid ? " ok " : " bad")
+                            + " => " + format.format(dateAfter));
                     if (valid && newYear != years[i]) {
                         errln("  FAIL: " + newYear + " should be valid; date, month and time shouldn't change");
                     } else if (!valid && newYear == years[i]) {
@@ -1305,18 +1343,16 @@
             return;
         }
 
-        int fieldsList[][] = {
-            { 1997, Calendar.FEBRUARY,  1, 10, 45, 15, 900 },
-            { 1999, Calendar.DECEMBER, 22, 23, 59, 59, 999 },
+        int[][] fieldsList = {
+            {1997, FEBRUARY, 1, 10, 45, 15, 900},
+            {1999, DECEMBER, 22, 23, 59, 59, 999},
             // test case for 4960642 with default cutover
-            { 1582, Calendar.OCTOBER,   4, 23, 59, 59, 999 },
-        };
+            {1582, OCTOBER, 4, 23, 59, 59, 999}};
         String[] fieldNames = {
             "ERA", "YEAR", "MONTH", "WEEK_OF_YEAR", "WEEK_OF_MONTH",
             "DAY_OF_MONTH", "DAY_OF_YEAR", "DAY_OF_WEEK", "DAY_OF_WEEK_IN_MONTH",
             "AM_PM", "HOUR", "HOUR_OF_DAY", "MINUTE", "SECOND", "MILLISECOND",
-            "ZONE_OFFSET", "DST_OFFSET"
-        };
+            "ZONE_OFFSET", "DST_OFFSET"};
 
         Locale savedLocale = Locale.getDefault();
         Locale.setDefault(Locale.US);
@@ -1326,25 +1362,25 @@
             GregorianCalendar cal = new GregorianCalendar();
 
             cal.setTime(new Date(0));
-            cal.roll(Calendar.HOUR,  0x7F000000);
-            cal.roll(Calendar.HOUR, -0x7F000000);
+            cal.roll(HOUR, 0x7F000000);
+            cal.roll(HOUR, -0x7F000000);
             if (cal.getTime().getTime() != 0) {
-                errln("Hour rolling broken. expected 0, got "+cal.getTime().getTime());
+                errln("Hour rolling broken. expected 0, got " + cal.getTime().getTime());
             }
 
-            for (int op=0; op<2; ++op) {
-                logln("Testing GregorianCalendar " + (op==0 ? "add" : "roll"));
+            for (int op = 0; op < 2; ++op) {
+                logln("Testing GregorianCalendar " + (op == 0 ? "add" : "roll"));
 
-                for (int field=0; field < Calendar.FIELD_COUNT; ++field) {
-                    if (field != Calendar.ZONE_OFFSET &&
-                        field != Calendar.DST_OFFSET) {
-                        for (int j=0; j<fieldsList.length; ++j) {
-                            int fields[] = fieldsList[j];
+                for (int field = 0; field < FIELD_COUNT; ++field) {
+                    if (field != ZONE_OFFSET
+                            && field != DST_OFFSET) {
+                        for (int j = 0; j < fieldsList.length; ++j) {
+                            int[] fields = fieldsList[j];
                             cal.clear();
                             cal.set(fields[0], fields[1], fields[2],
                                     fields[3], fields[4], fields[5]);
-                            cal.set(Calendar.MILLISECOND, fields[6]);
-                            for (int i = 0; i < 2*limit; i++) {
+                            cal.set(MILLISECOND, fields[6]);
+                            for (int i = 0; i < 2 * limit; i++) {
                                 if (op == 0) {
                                     cal.add(field, i < limit ? 1 : -1);
                                 } else {
@@ -1352,45 +1388,45 @@
                                 }
                             }
 
-                            if (cal.get(Calendar.YEAR) != fields[0] ||
-                                cal.get(Calendar.MONTH) != fields[1] ||
-                                cal.get(Calendar.DATE) != fields[2] ||
-                                cal.get(Calendar.HOUR_OF_DAY) != fields[3] ||
-                                cal.get(Calendar.MINUTE) != fields[4] ||
-                                cal.get(Calendar.SECOND) != fields[5] ||
-                                cal.get(Calendar.MILLISECOND) != fields[6]) {
-                                errln("Field " + field +
-                                      " (" + fieldNames[field] +
-                                      ") FAIL, expected " +
-                                      fields[0] +
-                                      "/" + (fields[1] + 1) +
-                                      "/" + fields[2] +
-                                      " " + fields[3] +
-                                      ":" + fields[4] +
-                                      ":" + fields[5] +
-                                      "." + fields[6] +
-                                      ", got " + cal.get(Calendar.YEAR) +
-                                      "/" + (cal.get(Calendar.MONTH) + 1) +
-                                      "/" + cal.get(Calendar.DATE) +
-                                      " " + cal.get(Calendar.HOUR_OF_DAY) +
-                                      ":" + cal.get(Calendar.MINUTE) +
-                                      ":" + cal.get(Calendar.SECOND) +
-                                      "." + cal.get(Calendar.MILLISECOND));
+                            if (cal.get(YEAR) != fields[0]
+                                    || cal.get(MONTH) != fields[1]
+                                    || cal.get(DATE) != fields[2]
+                                    || cal.get(HOUR_OF_DAY) != fields[3]
+                                    || cal.get(MINUTE) != fields[4]
+                                    || cal.get(SECOND) != fields[5]
+                                    || cal.get(MILLISECOND) != fields[6]) {
+                                errln("Field " + field
+                                        + " (" + fieldNames[field]
+                                        + ") FAIL, expected "
+                                        + fields[0]
+                                        + "/" + (fields[1] + 1)
+                                        + "/" + fields[2]
+                                        + " " + fields[3]
+                                        + ":" + fields[4]
+                                        + ":" + fields[5]
+                                        + "." + fields[6]
+                                        + ", got " + cal.get(YEAR)
+                                        + "/" + (cal.get(MONTH) + 1)
+                                        + "/" + cal.get(DATE)
+                                        + " " + cal.get(HOUR_OF_DAY)
+                                        + ":" + cal.get(MINUTE)
+                                        + ":" + cal.get(SECOND)
+                                        + "." + cal.get(MILLISECOND));
 
                                 cal.clear();
                                 cal.set(fields[0], fields[1], fields[2],
                                         fields[3], fields[4], fields[5]);
-                                cal.set(Calendar.MILLISECOND, fields[6]);
-                                errln(cal.get(Calendar.YEAR) +
-                                      "/" + (cal.get(Calendar.MONTH) + 1) +
-                                      "/" + cal.get(Calendar.DATE) +
-                                      " " + cal.get(Calendar.HOUR_OF_DAY) +
-                                      ":" + cal.get(Calendar.MINUTE) +
-                                      ":" + cal.get(Calendar.SECOND) +
-                                      "." + cal.get(Calendar.MILLISECOND));
+                                cal.set(MILLISECOND, fields[6]);
+                                errln(cal.get(YEAR)
+                                        + "/" + (cal.get(MONTH) + 1)
+                                        + "/" + cal.get(DATE)
+                                        + " " + cal.get(HOUR_OF_DAY)
+                                        + ":" + cal.get(MINUTE)
+                                        + ":" + cal.get(SECOND)
+                                        + "." + cal.get(MILLISECOND));
 
                                 long prev = cal.getTime().getTime();
-                                for (int i = 0; i < 2*limit; i++) {
+                                for (int i = 0; i < 2 * limit; i++) {
                                     if (op == 0) {
                                         cal.add(field, i < limit ? 1 : -1);
                                     } else {
@@ -1399,25 +1435,24 @@
                                     long t = cal.getTime().getTime();
                                     long delta = t - prev;
                                     prev = t;
-                                    errln((op == 0 ? "add(" : "roll(") +
-                                          fieldNames[field] + ", " +
-                                          (i < limit ? "+" : "-") + "1) => " +
-                                          cal.get(Calendar.YEAR) +
-                                          "/" + (cal.get(Calendar.MONTH) + 1) +
-                                          "/" + cal.get(Calendar.DATE) +
-                                          " " + cal.get(Calendar.HOUR_OF_DAY) +
-                                          ":" + cal.get(Calendar.MINUTE) +
-                                          ":" + cal.get(Calendar.SECOND) +
-                                          "." + cal.get(Calendar.MILLISECOND) +
-                                          " d=" + delta);
+                                    errln((op == 0 ? "add(" : "roll(")
+                                            + fieldNames[field] + ", "
+                                            + (i < limit ? "+" : "-") + "1) => "
+                                            + cal.get(YEAR)
+                                            + "/" + (cal.get(MONTH) + 1)
+                                            + "/" + cal.get(DATE)
+                                            + " " + cal.get(HOUR_OF_DAY)
+                                            + ":" + cal.get(MINUTE)
+                                            + ":" + cal.get(SECOND)
+                                            + "." + cal.get(MILLISECOND)
+                                            + " d=" + delta);
                                 }
                             }
                         }
                     }
                 }
             }
-        }
-        finally {
+        } finally {
             Locale.setDefault(savedLocale);
         }
     }
@@ -1425,14 +1460,14 @@
     public void Test4174361() {
         GregorianCalendar calendar = new GregorianCalendar(1996, 1, 29);
 
-        calendar.add(Calendar.MONTH, 10);
+        calendar.add(MONTH, 10);
         Date date1 = calendar.getTime();
-        int d1 = calendar.get(Calendar.DAY_OF_MONTH);
+        int d1 = calendar.get(DAY_OF_MONTH);
 
         calendar = new GregorianCalendar(1996, 1, 29);
-        calendar.add(Calendar.MONTH, 11);
+        calendar.add(MONTH, 11);
         Date date2 = calendar.getTime();
-        int d2 = calendar.get(Calendar.DAY_OF_MONTH);
+        int d2 = calendar.get(DAY_OF_MONTH);
 
         if (d1 != d2) {
             errln("adding months to Feb 29 broken");
@@ -1449,9 +1484,9 @@
         Calendar cal = Calendar.getInstance(PST, Locale.US);
         cal.clear();
         cal.set(1999, 3, 21, 15, 5, 0); // Arbitrary
-        int h1 = cal.get(Calendar.HOUR_OF_DAY);
+        int h1 = cal.get(HOUR_OF_DAY);
         cal.setTimeZone(EST);
-        int h2 = cal.get(Calendar.HOUR_OF_DAY);
+        int h2 = cal.get(HOUR_OF_DAY);
         if (h1 == h2) {
             errln("FAIL: Fields not updated after setTimeZone");
         }
@@ -1460,7 +1495,7 @@
         // getTime() returns zone-independent time in ms.
         cal.clear();
         cal.setTimeZone(PST);
-        cal.set(Calendar.HOUR_OF_DAY, 10);
+        cal.set(HOUR_OF_DAY, 10);
         Date pst10 = cal.getTime();
         cal.setTimeZone(EST);
         Date est10 = cal.getTime();
@@ -1474,28 +1509,27 @@
      */
     public void Test4197699() {
         GregorianCalendar cal = new GregorianCalendar();
-        cal.setFirstDayOfWeek(Calendar.MONDAY);
+        cal.setFirstDayOfWeek(MONDAY);
         cal.setMinimalDaysInFirstWeek(4);
         DateFormat fmt = new SimpleDateFormat("E dd MMM yyyy  'DOY='D 'WOY='w");
         fmt.setCalendar(cal);
 
         int[] DATA = {
-            2000,  Calendar.JANUARY,   1,   52,
-            2001,  Calendar.DECEMBER,  31,  1,
-        };
+            2000, JANUARY, 1, 52,
+            2001, DECEMBER, 31, 1};
 
-        for (int i=0; i<DATA.length; ) {
+        for (int i = 0; i < DATA.length;) {
             cal.set(DATA[i++], DATA[i++], DATA[i++]);
             int expWOY = DATA[i++];
-            int actWOY = cal.get(Calendar.WEEK_OF_YEAR);
+            int actWOY = cal.get(WEEK_OF_YEAR);
             if (expWOY == actWOY) {
                 logln("Ok: " + fmt.format(cal.getTime()));
             } else {
                 errln("FAIL: " + fmt.format(cal.getTime())
-                      + ", expected WOY=" + expWOY);
-                cal.add(Calendar.DATE, -8);
-                for (int j=0; j<14; ++j) {
-                    cal.add(Calendar.DATE, 1);
+                        + ", expected WOY=" + expWOY);
+                cal.add(DATE, -8);
+                for (int j = 0; j < 14; ++j) {
+                    cal.add(DATE, 1);
                     logln(fmt.format(cal.getTime()));
                 }
             }
@@ -1514,6 +1548,7 @@
      *   DAY_OF_YEAR
      *   WEEK_OF_YEAR + DAY_OF_WEEK
      */
+    @SuppressWarnings("deprecation")
     public void Test4209071() {
         Calendar cal = Calendar.getInstance(Locale.US);
 
@@ -1524,106 +1559,104 @@
             // Add new test cases as needed.
 
             // 0
-            new int[] {}, new Date(Y, Calendar.JANUARY, 1),
+            new int[]{}, new Date(Y, JANUARY, 1),
             // 1
-            new int[] { Calendar.MONTH, Calendar.MARCH },
-            new Date(Y, Calendar.MARCH, 1),
+            new int[]{MONTH, MARCH},
+            new Date(Y, MARCH, 1),
             // 2
-            new int[] { Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY },
-            new Date(Y, Calendar.JANUARY, 4),
+            new int[]{DAY_OF_WEEK, WEDNESDAY},
+            new Date(Y, JANUARY, 4),
             // 3
-            new int[] { Calendar.DAY_OF_WEEK, Calendar.THURSDAY,
-                        Calendar.DAY_OF_MONTH, 18, },
-            new Date(Y, Calendar.JANUARY, 18),
+            new int[]{DAY_OF_WEEK, THURSDAY,
+                DAY_OF_MONTH, 18,},
+            new Date(Y, JANUARY, 18),
             // 4
-            new int[] { Calendar.DAY_OF_MONTH, 18,
-                        Calendar.DAY_OF_WEEK, Calendar.THURSDAY, },
-            new Date(Y, Calendar.JANUARY, 18),
+            new int[]{DAY_OF_MONTH, 18,
+                DAY_OF_WEEK, THURSDAY,},
+            new Date(Y, JANUARY, 18),
             // 5  (WOM -1 is in previous month)
-            new int[] { Calendar.DAY_OF_MONTH, 18,
-                        Calendar.WEEK_OF_MONTH, -1,
-                        Calendar.DAY_OF_WEEK, Calendar.THURSDAY, },
-            new Date(Y-1, Calendar.DECEMBER, 22),
+            new int[]{DAY_OF_MONTH, 18,
+                WEEK_OF_MONTH, -1,
+                DAY_OF_WEEK, THURSDAY,},
+            new Date(Y - 1, DECEMBER, 22),
             // 6
-            new int[] { Calendar.DAY_OF_MONTH, 18,
-                        Calendar.WEEK_OF_MONTH, 4,
-                        Calendar.DAY_OF_WEEK, Calendar.THURSDAY, },
-            new Date(Y, Calendar.JANUARY, 26),
+            new int[]{DAY_OF_MONTH, 18,
+                WEEK_OF_MONTH, 4,
+                DAY_OF_WEEK, THURSDAY,},
+            new Date(Y, JANUARY, 26),
             // 7  (DIM -1 is in same month)
-            new int[] { Calendar.DAY_OF_MONTH, 18,
-                        Calendar.DAY_OF_WEEK_IN_MONTH, -1,
-                        Calendar.DAY_OF_WEEK, Calendar.THURSDAY, },
-            new Date(Y, Calendar.JANUARY, 26),
+            new int[]{DAY_OF_MONTH, 18,
+                DAY_OF_WEEK_IN_MONTH, -1,
+                DAY_OF_WEEK, THURSDAY,},
+            new Date(Y, JANUARY, 26),
             // 8
-            new int[] { Calendar.WEEK_OF_YEAR, 9,
-                        Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY, },
-            new Date(Y, Calendar.MARCH, 1),
+            new int[]{WEEK_OF_YEAR, 9,
+                DAY_OF_WEEK, WEDNESDAY,},
+            new Date(Y, MARCH, 1),
             // 9
-            new int[] { Calendar.MONTH, Calendar.OCTOBER,
-                        Calendar.DAY_OF_WEEK_IN_MONTH, 1,
-                        Calendar.DAY_OF_WEEK, Calendar.FRIDAY, },
-            new Date(Y, Calendar.OCTOBER, 6),
+            new int[]{MONTH, OCTOBER,
+                DAY_OF_WEEK_IN_MONTH, 1,
+                DAY_OF_WEEK, FRIDAY,},
+            new Date(Y, OCTOBER, 6),
             // 10
-            new int[] { Calendar.MONTH, Calendar.OCTOBER,
-                        Calendar.WEEK_OF_MONTH, 2,
-                        Calendar.DAY_OF_WEEK, Calendar.FRIDAY, },
-            new Date(Y, Calendar.OCTOBER, 13),
+            new int[]{MONTH, OCTOBER,
+                WEEK_OF_MONTH, 2,
+                DAY_OF_WEEK, FRIDAY,},
+            new Date(Y, OCTOBER, 13),
             // 11
-            new int[] { Calendar.MONTH, Calendar.OCTOBER,
-                        Calendar.DAY_OF_MONTH, 15,
-                        Calendar.DAY_OF_YEAR, 222, },
-            new Date(Y, Calendar.AUGUST, 10),
+            new int[]{MONTH, OCTOBER,
+                DAY_OF_MONTH, 15,
+                DAY_OF_YEAR, 222,},
+            new Date(Y, AUGUST, 10),
             // 12
-            new int[] { Calendar.DAY_OF_WEEK, Calendar.THURSDAY,
-                        Calendar.MONTH, Calendar.DECEMBER, },
-            new Date(Y, Calendar.DECEMBER, 7),
-        };
+            new int[]{DAY_OF_WEEK, THURSDAY,
+                MONTH, DECEMBER,},
+            new Date(Y, DECEMBER, 7)};
 
-        for (int i=0; i<FIELD_DATA.length; i+=2) {
+        for (int i = 0; i < FIELD_DATA.length; i += 2) {
             int[] fields = (int[]) FIELD_DATA[i];
-            Date exp = (Date) FIELD_DATA[i+1];
+            Date exp = (Date) FIELD_DATA[i + 1];
 
             cal.clear();
-            cal.set(Calendar.YEAR, Y + 1900);
-            for (int j=0; j<fields.length; j+=2) {
-                cal.set(fields[j], fields[j+1]);
+            cal.set(YEAR, Y + 1900);
+            for (int j = 0; j < fields.length; j += 2) {
+                cal.set(fields[j], fields[j + 1]);
             }
 
             Date act = cal.getTime();
             if (!act.equals(exp)) {
-                errln("FAIL: Test " + (i/2) + " got " + act +
-                      ", want " + exp +
-                      " (see test/java/util/Calendar/CalendarRegression.java");
+                errln("FAIL: Test " + (i / 2) + " got " + act
+                        + ", want " + exp
+                        + " (see test/java/util/Calendar/CalendarRegression.java");
             }
         }
 
         // Test specific failure reported in bug
+        @SuppressWarnings("deprecation")
         Object[] DATA = {
-            new Integer(1), new Date(1997-1900, Calendar.JANUARY, 5),
-            new Integer(4), new Date(1997-1900, Calendar.JANUARY, 26),
-            new Integer(8), new Date(1997-1900, Calendar.FEBRUARY, 23),
-            new Integer(-1), new Date(1997-1900, Calendar.JANUARY, 26),
-            new Integer(-4), new Date(1997-1900, Calendar.JANUARY, 5),
-            new Integer(-8), new Date(1996-1900, Calendar.DECEMBER, 8),
-        };
-        for (int i=0; i<DATA.length; i+=2) {
+            1, new Date(1997 - 1900, JANUARY, 5),
+            4, new Date(1997 - 1900, JANUARY, 26),
+            8, new Date(1997 - 1900, FEBRUARY, 23),
+            -1, new Date(1997 - 1900, JANUARY, 26),
+            -4, new Date(1997 - 1900, JANUARY, 5),
+            -8, new Date(1996 - 1900, DECEMBER, 8)};
+        for (int i = 0; i < DATA.length; i += 2) {
             cal.clear();
-            cal.set(Calendar.DAY_OF_WEEK_IN_MONTH,
+            cal.set(DAY_OF_WEEK_IN_MONTH,
                     ((Number) DATA[i]).intValue());
-            cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
-            cal.set(Calendar.MONTH, Calendar.JANUARY);
-            cal.set(Calendar.YEAR, 1997);
+            cal.set(DAY_OF_WEEK, SUNDAY);
+            cal.set(MONTH, JANUARY);
+            cal.set(YEAR, 1997);
             Date actual = cal.getTime();
-            if (!actual.equals(DATA[i+1])) {
-                errln("FAIL: Sunday " + DATA[i] +
-                      " of Jan 1997 -> " + actual +
-                      ", want " + DATA[i+1]);
+            if (!actual.equals(DATA[i + 1])) {
+                errln("FAIL: Sunday " + DATA[i]
+                        + " of Jan 1997 -> " + actual
+                        + ", want " + DATA[i + 1]);
             }
         }
     }
 
-    public void Test4288792() throws Exception
-    {
+    public void Test4288792() throws Exception {
         TimeZone savedTZ = TimeZone.getDefault();
         TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
         GregorianCalendar cal = new GregorianCalendar();
@@ -1631,45 +1664,44 @@
             for (int i = 1900; i < 2100; i++) {
                 for (int j1 = 1; j1 <= 7; j1++) {
                     // Loop for MinimalDaysInFirstWeek: 1..7
-                    for (int j = Calendar.SUNDAY; j <= Calendar.SATURDAY; j++) {
+                    for (int j = SUNDAY; j <= SATURDAY; j++) {
                         // Loop for FirstDayOfWeek: SUNDAY..SATURDAY
                         cal.clear();
                         cal.setMinimalDaysInFirstWeek(j1);
                         cal.setFirstDayOfWeek(j);
-                        cal.set(Calendar.YEAR, i);
-                        int maxWeek = cal.getActualMaximum(Calendar.WEEK_OF_YEAR);
-                        cal.set(Calendar.WEEK_OF_YEAR, maxWeek);
-                        cal.set(Calendar.DAY_OF_WEEK, j);
+                        cal.set(YEAR, i);
+                        int maxWeek = cal.getActualMaximum(WEEK_OF_YEAR);
+                        cal.set(WEEK_OF_YEAR, maxWeek);
+                        cal.set(DAY_OF_WEEK, j);
 
                         for (int k = 1; k < 7; k++) {
-                            cal.add(Calendar.DATE, 1);
-                            int WOY = cal.get(Calendar.WEEK_OF_YEAR);
+                            cal.add(DATE, 1);
+                            int WOY = cal.get(WEEK_OF_YEAR);
                             if (WOY != maxWeek) {
                                 errln(cal.getTime() + ",got=" + WOY
-                                      + ",expected=" + maxWeek
-                                      + ",min=" + j1 + ",first=" + j);
+                                        + ",expected=" + maxWeek
+                                        + ",min=" + j1 + ",first=" + j);
                             }
                         }
 
-                        cal.add(Calendar.DATE, 1);
-                        int WOY = cal.get(Calendar.WEEK_OF_YEAR);
+                        cal.add(DATE, 1);
+                        int WOY = cal.get(WEEK_OF_YEAR);
                         if (WOY != 1) {
                             errln(cal.getTime() + ",got=" + WOY
-                                  + ",expected=1,min=" + j1 + ",first" + j);
+                                    + ",expected=1,min=" + j1 + ",first" + j);
                         }
                     }
                 }
             }
-        }
-        finally {
+        } finally {
             TimeZone.setDefault(savedTZ);
         }
     }
 
     public void Test4328747() throws Exception {
-        Calendar c = (Calendar)Calendar.getInstance(Locale.US);
+        Calendar c = Calendar.getInstance(Locale.US);
         c.clear();
-        c.set(1966,0,1); // 1 jan 1966
+        c.set(1966, 0, 1); // 1 jan 1966
 
         // serialize
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -1679,16 +1711,16 @@
 
         // deserialize
         ObjectInputStream t = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()));
-        Calendar result = (Calendar)t.readObject();
+        Calendar result = (Calendar) t.readObject();
 
         // let recalculate fields with the same UTC time
         result.setTime(result.getTime());
         // Bug gives 1965 11 19
-        if ((result.get(c.YEAR) != 1966) || (result.get(c.MONTH) != 0)
-            || (result.get(c.DATE) != 1)) {
+        if ((result.get(YEAR) != 1966) || (result.get(MONTH) != 0)
+                || (result.get(DATE) != 1)) {
             errln("deserialized Calendar returned wrong date field(s): "
-                  + result.get(c.YEAR) + "/" + result.get(c.MONTH) + "/" + result.get(c.DATE)
-                  + ", expected 1966/0/1");
+                    + result.get(YEAR) + "/" + result.get(MONTH) + "/" + result.get(DATE)
+                    + ", expected 1966/0/1");
         }
     }
 
@@ -1700,13 +1732,13 @@
         TimeZone savedTimeZone = TimeZone.getDefault();
         try {
             boolean pass = true;
-            String[] IDs = new String[] {"Undefined", "PST", "US/Pacific",
-                                         "GMT+3:00", "GMT-01:30"};
+            String[] IDs = new String[]{"Undefined", "PST", "US/Pacific",
+                "GMT+3:00", "GMT-01:30"};
             for (int i = 0; i < IDs.length; i++) {
                 TimeZone tz = TimeZone.getTimeZone(IDs[i]);
                 TimeZone.setDefault(tz);
 
-                Calendar c = (Calendar)Calendar.getInstance();
+                Calendar c = Calendar.getInstance();
 
                 // serialize
                 ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -1719,26 +1751,20 @@
 
                 if (!c.equals(t.readObject())) {
                     pass = false;
-                    logln("Calendar instance which uses TimeZone <" +
-                          IDs[i] + "> is incorrectly serialized/deserialized.");
+                    logln("Calendar instance which uses TimeZone <"
+                            + IDs[i] + "> is incorrectly serialized/deserialized.");
                 } else {
-                    logln("Calendar instance which uses TimeZone <" +
-                          IDs[i] + "> is correctly serialized/deserialized.");
+                    logln("Calendar instance which uses TimeZone <"
+                            + IDs[i] + "> is correctly serialized/deserialized.");
                 }
             }
             if (!pass) {
                 errln("Fail: Calendar serialization/equality bug");
             }
-        }
-        catch (IOException e) {
+        } catch (IOException | ClassNotFoundException e) {
             errln("Fail: " + e);
             e.printStackTrace();
-        }
-        catch (ClassNotFoundException e) {
-            errln("Fail: " + e);
-            e.printStackTrace();
-        }
-        finally {
+        } finally {
             TimeZone.setDefault(savedTimeZone);
         }
     }
@@ -1747,12 +1773,12 @@
      * 4546637: Incorrect WEEK_OF_MONTH after changing First Day Of Week
      */
     public void Test4546637() {
-        GregorianCalendar day = new GregorianCalendar (2001, Calendar.NOVEMBER, 04);
+        GregorianCalendar day = new GregorianCalendar(2001, NOVEMBER, 04);
         day.setMinimalDaysInFirstWeek(1);
-        int wom = day.get(Calendar.WEEK_OF_MONTH);
+        int wom = day.get(WEEK_OF_MONTH);
 
-        day.setFirstDayOfWeek(Calendar.MONDAY);
-        if (day.get(Calendar.WEEK_OF_MONTH) != 1) {
+        day.setFirstDayOfWeek(MONDAY);
+        if (day.get(WEEK_OF_MONTH) != 1) {
             errln("Fail: 2001/11/4 must be the first week of the month.");
         }
     }
@@ -1761,14 +1787,14 @@
      * 4623997: GregorianCalendar returns bad WEEK_OF_YEAR
      */
     public void Test4623997() {
-        GregorianCalendar cal = new GregorianCalendar(2000, GregorianCalendar.JANUARY, 1);
+        GregorianCalendar cal = new GregorianCalendar(2000, JANUARY, 1);
 
-        int dow = cal.get(GregorianCalendar.DAY_OF_WEEK);
+        int dow = cal.get(DAY_OF_WEEK);
 
-        cal.setFirstDayOfWeek(GregorianCalendar.MONDAY);
+        cal.setFirstDayOfWeek(MONDAY);
         cal.setMinimalDaysInFirstWeek(4);
 
-        if (cal.get(GregorianCalendar.WEEK_OF_YEAR) != 52) {
+        if (cal.get(WEEK_OF_YEAR) != 52) {
             errln("Fail: 2000/1/1 must be the 52nd week of the year.");
         }
     }
@@ -1800,9 +1826,9 @@
         }
 
         t = calendar.getTime();
-        calendar.set(Calendar.DAY_OF_MONTH, 33);
+        calendar.set(DAY_OF_MONTH, 33);
         t = calendar.getTime();
-        calendar.set(Calendar.DAY_OF_MONTH, 0);
+        calendar.set(DAY_OF_MONTH, 0);
         s = df.format(calendar.getTime());
         if (!expected.equals(s)) {
             errln("DAY_OF_MONTH w/o ZONE_OFFSET: expected: " + expected + ", got: " + s);
@@ -1815,10 +1841,10 @@
             throw new RuntimeException("Unexpected parse exception", e);
         }
         t = calendar.getTime();
-        calendar.set(calendar.ZONE_OFFSET, calendar.get(calendar.ZONE_OFFSET));
-        calendar.set(Calendar.DAY_OF_MONTH, 33);
+        calendar.set(ZONE_OFFSET, calendar.get(ZONE_OFFSET));
+        calendar.set(DAY_OF_MONTH, 33);
         t = calendar.getTime();
-        calendar.set(Calendar.DAY_OF_MONTH, 0);
+        calendar.set(DAY_OF_MONTH, 0);
         s = df.format(calendar.getTime());
         if (!expected.equals(s)) {
             errln("DAY_OF_MONTH: expected: " + expected + ", got: " + s);
@@ -1834,11 +1860,11 @@
             throw new RuntimeException("Unexpected parse exception", e);
         }
         t = calendar.getTime();
-        calendar.set(calendar.ZONE_OFFSET, calendar.get(calendar.ZONE_OFFSET));
+        calendar.set(ZONE_OFFSET, calendar.get(ZONE_OFFSET));
         // jump to the next year
-        calendar.set(Calendar.WEEK_OF_YEAR, 100);
+        calendar.set(WEEK_OF_YEAR, 100);
         t = calendar.getTime();
-        calendar.set(Calendar.WEEK_OF_YEAR, 0);
+        calendar.set(WEEK_OF_YEAR, 0);
         s = df.format(calendar.getTime());
         if (!expected.equals(s)) {
             errln("WEEK_OF_YEAR: expected: " + expected + ", got: " + s);
@@ -1846,11 +1872,11 @@
         // change the state back
         calendar.clear();
         calendar.setTime(initialDate);
-        calendar.set(calendar.ZONE_OFFSET, calendar.get(calendar.ZONE_OFFSET));
+        calendar.set(ZONE_OFFSET, calendar.get(ZONE_OFFSET));
         // jump to next month
-        calendar.set(Calendar.WEEK_OF_MONTH, 7);
+        calendar.set(WEEK_OF_MONTH, 7);
         t = calendar.getTime();
-        calendar.set(Calendar.WEEK_OF_MONTH, 0);
+        calendar.set(WEEK_OF_MONTH, 0);
         s = df.format(calendar.getTime());
         if (!expected.equals(s)) {
             errln("WEEK_OF_MONTH: expected: " + expected + ", got: " + s);
@@ -1870,10 +1896,10 @@
         }
         t = calendar.getTime();
         // time should be 22:59:59.
-        calendar.set(Calendar.MINUTE, 61);
+        calendar.set(MINUTE, 61);
         // time should be 23:01:59.
         t = calendar.getTime();
-        calendar.set(Calendar.MINUTE, -1);
+        calendar.set(MINUTE, -1);
         // time should be back to 22:59:59.
         s = df.format(calendar.getTime());
         if (!expected.equals(s)) {
@@ -1896,15 +1922,15 @@
 
         Calendar cal = Calendar.getInstance();
         cal.setTime(new Date(1029814211523L));
-        cal.set(Calendar.YEAR, 2001);
+        cal.set(YEAR, 2001);
         Date t = cal.getTime();
-        cal.set(Calendar.MONTH, Calendar.JANUARY);
+        cal.set(MONTH, JANUARY);
         t = cal.getTime();
 
-        cal.set(Calendar.DAY_OF_MONTH, 8);
+        cal.set(DAY_OF_MONTH, 8);
         t = cal.getTime();
 
-        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+        cal.set(DAY_OF_WEEK, MONDAY);
         DateFormat df = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
         String expected = "2001/01/08";
         String s = df.format(cal.getTime());
@@ -1923,9 +1949,9 @@
      */
     public void Test4683492() {
         Calendar cal = new GregorianCalendar(2002, 3, 29, 10, 0, 0);
-        cal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
-        cal.set(Calendar.DAY_OF_WEEK_IN_MONTH, -1);
-        cal.set(Calendar.MONTH, 12);
+        cal.set(DAY_OF_WEEK, FRIDAY);
+        cal.set(DAY_OF_WEEK_IN_MONTH, -1);
+        cal.set(MONTH, 12);
         DateFormat df = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
         String expected = "2003/01/31";
         String s = df.format(cal.getTime());
@@ -1940,31 +1966,31 @@
     public void Test4080631() {
         Calendar cal = Calendar.getInstance();
         int h1 = cal.hashCode();
-        cal.add(cal.SECOND, +1);
+        cal.add(SECOND, +1);
         int h2 = cal.hashCode();
         Calendar cal2 = (Calendar) cal.clone();
-        cal.add(cal.MILLISECOND, +1);
+        cal.add(MILLISECOND, +1);
         int h3 = cal.hashCode();
-        logln("hash code: h1="+h1+", h2="+h2+", h3="+h3);
+        logln("hash code: h1=" + h1 + ", h2=" + h2 + ", h3=" + h3);
         if (h1 == h2 || h1 == h3 || h2 == h3) {
-            errln("hash code is poor: hashCode="+h1);
+            errln("hash code is poor: hashCode=" + h1);
         }
         h2 = cal2.hashCode();
-        cal.add(cal.MILLISECOND, -1);
+        cal.add(MILLISECOND, -1);
         int h4 = cal.hashCode();
-        logln("hash code: h2="+h2+", h4="+h4);
+        logln("hash code: h2=" + h2 + ", h4=" + h4);
         if (cal.equals(cal2) && h2 != h4) {
-            errln("broken hash code: h2="+h2+", h4="+h4);
+            errln("broken hash code: h2=" + h2 + ", h4=" + h4);
         }
         int x = cal.getFirstDayOfWeek() + 3;
-        if (x > cal.SATURDAY) {
+        if (x > SATURDAY) {
             x -= 7;
         }
         cal.setFirstDayOfWeek(x);
         int h5 = cal.hashCode();
-        logln("hash code: h4="+h4+", h5="+h5);
+        logln("hash code: h4=" + h4 + ", h5=" + h5);
         if (h4 == h5) {
-            errln("has code is poor with first day of week param: hashCode="+h4);
+            errln("has code is poor with first day of week param: hashCode=" + h4);
         }
     }
 
@@ -1991,8 +2017,7 @@
             errln("Wrong BCE and/or CE values");
         }
     }
-    */
-
+     */
     /**
      * 4167995: GregorianCalendar.setGregorianChange() not to spec
      */
@@ -2000,42 +2025,42 @@
         Koyomi gc = new Koyomi(TimeZone.getTimeZone("GMT"));
         logln("Hybrid: min date");
         gc.setTime(new Date(Long.MIN_VALUE));
-        if (!gc.checkDate(292269055, gc.DECEMBER, 2, gc.SUNDAY)
-            || !gc.checkFieldValue(gc.ERA, gc.BC)) {
+        if (!gc.checkDate(292269055, DECEMBER, 2, SUNDAY)
+                || !gc.checkFieldValue(ERA, GregorianCalendar.BC)) {
             errln(gc.getMessage());
         }
         logln("Hybrid: max date");
         gc.setTime(new Date(Long.MAX_VALUE));
-        if (!gc.checkDate(292278994, gc.AUGUST, 17, gc.SUNDAY)
-            || !gc.checkFieldValue(gc.ERA, gc.AD)) {
+        if (!gc.checkDate(292278994, AUGUST, 17, SUNDAY)
+                || !gc.checkFieldValue(ERA, GregorianCalendar.AD)) {
             errln(gc.getMessage());
         }
 
         gc.setGregorianChange(new Date(Long.MIN_VALUE));
         logln("Gregorian: min date");
         gc.setTime(new Date(Long.MIN_VALUE));
-        if (!gc.checkDate(292275056, gc.MAY, 16, gc.SUNDAY)
-            || !gc.checkFieldValue(gc.ERA, gc.BC)) {
+        if (!gc.checkDate(292275056, MAY, 16, SUNDAY)
+                || !gc.checkFieldValue(ERA, GregorianCalendar.BC)) {
             errln(gc.getMessage());
         }
         logln("Gregorian: max date");
         gc.setTime(new Date(Long.MAX_VALUE));
-        if (!gc.checkDate(292278994, gc.AUGUST, 17, gc.SUNDAY)
-            || !gc.checkFieldValue(gc.ERA, gc.AD)) {
+        if (!gc.checkDate(292278994, AUGUST, 17, SUNDAY)
+                || !gc.checkFieldValue(ERA, GregorianCalendar.AD)) {
             errln(gc.getMessage());
         }
 
         gc.setGregorianChange(new Date(Long.MAX_VALUE));
         logln("Julian: min date");
         gc.setTime(new Date(Long.MIN_VALUE));
-        if (!gc.checkDate(292269055, gc.DECEMBER, 2, gc.SUNDAY)
-            || !gc.checkFieldValue(gc.ERA, gc.BC)) {
+        if (!gc.checkDate(292269055, DECEMBER, 2, SUNDAY)
+                || !gc.checkFieldValue(ERA, GregorianCalendar.BC)) {
             errln(gc.getMessage());
         }
         logln("Julian: max date");
         gc.setTime(new Date(Long.MAX_VALUE));
-        if (!gc.checkDate(292272993, gc.JANUARY, 4, gc.SUNDAY)
-            || !gc.checkFieldValue(gc.ERA, gc.AD)) {
+        if (!gc.checkDate(292272993, JANUARY, 4, SUNDAY)
+                || !gc.checkFieldValue(ERA, GregorianCalendar.AD)) {
             errln(gc.getMessage());
         }
     }
@@ -2046,13 +2071,13 @@
     public void Test4340146() {
         Koyomi cal = new Koyomi();
         cal.clear();
-        cal.set(2003, cal.OCTOBER, 32);
+        cal.set(2003, OCTOBER, 32);
         cal.equals(new Koyomi());
-        if (!cal.checkInternalDate(2003, cal.OCTOBER, 32)) {
+        if (!cal.checkInternalDate(2003, OCTOBER, 32)) {
             errln(cal.getMessage());
         }
         new Koyomi().equals(cal);
-        if (!cal.checkInternalDate(2003, cal.OCTOBER, 32)) {
+        if (!cal.checkInternalDate(2003, OCTOBER, 32)) {
             errln(cal.getMessage());
         }
     }
@@ -2065,10 +2090,10 @@
         // throw IllegalArgumentException.
         Koyomi cal = new Koyomi(TimeZone.getTimeZone("Pacific/Kiritimati"));
         cal.setLenient(false);
-        cal.set(2003, cal.OCTOBER, 10);
+        cal.set(2003, OCTOBER, 10);
         cal.getTime();
         cal.setTimeZone(TimeZone.getTimeZone("Pacific/Tongatapu"));
-        cal.set(2003, cal.OCTOBER, 10);
+        cal.set(2003, OCTOBER, 10);
         cal.getTime();
     }
 
@@ -2077,10 +2102,10 @@
      */
     public void Test4652815() {
         Koyomi cal = new Koyomi(Locale.US);
-        testRoll(cal, 2003, cal.SEPTEMBER, 29);
-        testRoll(cal, 2003, cal.DECEMBER, 24);
-        testRoll(cal, 1582, cal.DECEMBER, 19);
-        testRoll(cal, 1582, cal.DECEMBER, 20);
+        testRoll(cal, 2003, SEPTEMBER, 29);
+        testRoll(cal, 2003, DECEMBER, 24);
+        testRoll(cal, 1582, DECEMBER, 19);
+        testRoll(cal, 1582, DECEMBER, 20);
     }
 
     private void testRoll(Koyomi cal, int year, int month, int dayOfMonth) {
@@ -2089,15 +2114,15 @@
         cal.getTime(); // normalize fields
         logln("Roll backwards from " + cal.toDateString());
         for (int i = 0; i < 1000; i++) {
-            cal.roll(cal.WEEK_OF_YEAR, -i);
-            if (!cal.checkFieldValue(cal.YEAR, year)) {
+            cal.roll(WEEK_OF_YEAR, -i);
+            if (!cal.checkFieldValue(YEAR, year)) {
                 errln(cal.getMessage());
             }
         }
         logln("Roll forewards from " + cal.toDateString());
         for (int i = 0; i < 1000; i++) {
-            cal.roll(cal.WEEK_OF_YEAR, +i);
-            if (!cal.checkFieldValue(cal.YEAR, year)) {
+            cal.roll(WEEK_OF_YEAR, +i);
+            if (!cal.checkFieldValue(YEAR, year)) {
                 errln(cal.getMessage());
             }
         }
@@ -2110,20 +2135,20 @@
         Koyomi cal = new Koyomi(Locale.US);
         cal.clear();
         logln("BCE 9-2-28 (leap year) roll DAY_OF_MONTH++ twice");
-        cal.set(cal.ERA, cal.BC);
-        cal.set(9, cal.FEBRUARY, 28);
-        if (cal.getActualMaximum(cal.DAY_OF_YEAR) != 366) {
+        cal.set(ERA, GregorianCalendar.BC);
+        cal.set(9, FEBRUARY, 28);
+        if (cal.getActualMaximum(DAY_OF_YEAR) != 366) {
             errln("    wrong actual max of DAY_OF_YEAR: got "
-                  + cal.getActualMaximum(cal.DAY_OF_YEAR) + " expected " + 366);
+                    + cal.getActualMaximum(DAY_OF_YEAR) + " expected " + 366);
         }
-        cal.roll(cal.DAY_OF_MONTH, +1);
-        if (!cal.checkFieldValue(cal.ERA, cal.BC)
-            || !cal.checkDate(9, cal.FEBRUARY, 29)) {
+        cal.roll(DAY_OF_MONTH, +1);
+        if (!cal.checkFieldValue(ERA, GregorianCalendar.BC)
+                || !cal.checkDate(9, FEBRUARY, 29)) {
             errln(cal.getMessage());
         }
-        cal.roll(cal.DAY_OF_MONTH, +1);
-        if (!cal.checkFieldValue(cal.ERA, cal.BC)
-            || !cal.checkDate(9, cal.FEBRUARY, 1)) {
+        cal.roll(DAY_OF_MONTH, +1);
+        if (!cal.checkFieldValue(ERA, GregorianCalendar.BC)
+                || !cal.checkDate(9, FEBRUARY, 1)) {
             errln(cal.getMessage());
         }
     }
@@ -2135,11 +2160,11 @@
         logln("1999/(Feb+12)/1 should be normalized to 2000/Feb/1 for getActualMaximum");
         Koyomi cal = new Koyomi(Locale.US);
         cal.clear();
-        cal.set(1999, cal.FEBRUARY + 12, 1);
-        if (!cal.checkActualMaximum(cal.DAY_OF_YEAR, 366)) {
+        cal.set(1999, FEBRUARY + 12, 1);
+        if (!cal.checkActualMaximum(DAY_OF_YEAR, 366)) {
             errln(cal.getMessage());
         }
-        if (!cal.checkActualMaximum(cal.DAY_OF_MONTH, 29)) {
+        if (!cal.checkActualMaximum(DAY_OF_MONTH, 29)) {
             errln(cal.getMessage());
         }
     }
@@ -2150,36 +2175,36 @@
     public void Test4936355() {
         Koyomi cal = new Koyomi(TimeZone.getTimeZone("GMT"));
         cal.clear();
-        cal.set(1970, cal.JANUARY, 1);
-        checkTimeCalculation(cal, cal.HOUR_OF_DAY, Integer.MAX_VALUE,
-                             (long)Integer.MAX_VALUE * 60 * 60 * 1000);
+        cal.set(1970, JANUARY, 1);
+        checkTimeCalculation(cal, HOUR_OF_DAY, Integer.MAX_VALUE,
+                (long) Integer.MAX_VALUE * 60 * 60 * 1000);
 
         cal.clear();
-        cal.set(1970, cal.JANUARY, 1);
-        checkTimeCalculation(cal, cal.HOUR, Integer.MAX_VALUE,
-                             (long)Integer.MAX_VALUE * 60 * 60 * 1000);
+        cal.set(1970, JANUARY, 1);
+        checkTimeCalculation(cal, HOUR, Integer.MAX_VALUE,
+                (long) Integer.MAX_VALUE * 60 * 60 * 1000);
 
         cal.clear();
-        cal.set(1970, cal.JANUARY, 1);
-        checkTimeCalculation(cal, cal.MINUTE, Integer.MAX_VALUE,
-                             (long)Integer.MAX_VALUE * 60 * 1000);
+        cal.set(1970, JANUARY, 1);
+        checkTimeCalculation(cal, MINUTE, Integer.MAX_VALUE,
+                (long) Integer.MAX_VALUE * 60 * 1000);
 
         cal.clear();
         // Make sure to use Gregorian dates (before and after the
         // set() call) for testing
-        cal.set(250000, cal.JANUARY, 1);
-        checkTimeCalculation(cal, cal.HOUR_OF_DAY, Integer.MIN_VALUE,
-                             (long)Integer.MIN_VALUE * 60 * 60 * 1000);
+        cal.set(250000, JANUARY, 1);
+        checkTimeCalculation(cal, HOUR_OF_DAY, Integer.MIN_VALUE,
+                (long) Integer.MIN_VALUE * 60 * 60 * 1000);
 
         cal.clear();
-        cal.set(250000, cal.JANUARY, 1);
-        checkTimeCalculation(cal, cal.HOUR, Integer.MIN_VALUE,
-                             (long)Integer.MIN_VALUE * 60 * 60 * 1000);
+        cal.set(250000, JANUARY, 1);
+        checkTimeCalculation(cal, HOUR, Integer.MIN_VALUE,
+                (long) Integer.MIN_VALUE * 60 * 60 * 1000);
 
         cal.clear();
-        cal.set(250000, cal.JANUARY, 1);
-        checkTimeCalculation(cal, cal.MINUTE, Integer.MIN_VALUE,
-                             (long)Integer.MIN_VALUE * 60 * 1000);
+        cal.set(250000, JANUARY, 1);
+        checkTimeCalculation(cal, MINUTE, Integer.MIN_VALUE,
+                (long) Integer.MIN_VALUE * 60 * 1000);
     }
 
     private void checkTimeCalculation(Koyomi cal, int field, int value, long expectedDelta) {
@@ -2189,7 +2214,7 @@
         if ((time + expectedDelta) != time2) {
             String s = value == Integer.MAX_VALUE ? "Integer.MAX_VALUE" : "Integer.MIN_VALUE";
             errln("set(" + Koyomi.getFieldName(field) + ", " + s + ") failed." + " got " + time2
-                  + ", expected " + (time+expectedDelta));
+                    + ", expected " + (time + expectedDelta));
         }
     }
 
@@ -2204,8 +2229,8 @@
         cal2.clear();
         cal2.setLenient(false);
 
-        cal1.set(2003, Calendar.OCTOBER, 31);
-        cal2.set(2003, Calendar.OCTOBER, 31);
+        cal1.set(2003, OCTOBER, 31);
+        cal2.set(2003, OCTOBER, 31);
         try {
             if (cal1.equals(cal2)) {
                 errln("lenient and non-lenient shouldn't be equal. (2003/10/31)");
@@ -2217,8 +2242,8 @@
             errln("equals threw IllegalArugumentException with non-lenient");
         }
 
-        cal1.set(2003, Calendar.OCTOBER, 32);
-        cal2.set(2003, Calendar.OCTOBER, 32);
+        cal1.set(2003, OCTOBER, 32);
+        cal2.set(2003, OCTOBER, 32);
         try {
             if (cal1.equals(cal2)) {
                 errln("lenient and non-lenient shouldn't be equal. (2003/10/32)");
@@ -2246,17 +2271,17 @@
      * 4738710: API: Calendar comparison methods should be improved
      */
     public void Test4738710() {
-        Calendar cal0 = new GregorianCalendar(2003, Calendar.SEPTEMBER, 30);
-        Comparable<Calendar> cal1 = new GregorianCalendar(2003, Calendar.OCTOBER, 1);
-        Calendar cal2 = new GregorianCalendar(2003, Calendar.OCTOBER, 2);
+        Calendar cal0 = new GregorianCalendar(2003, SEPTEMBER, 30);
+        Comparable<Calendar> cal1 = new GregorianCalendar(2003, OCTOBER, 1);
+        Calendar cal2 = new GregorianCalendar(2003, OCTOBER, 2);
         if (!(cal1.compareTo(cal0) > 0)) {
             errln("!(cal1 > cal0)");
         }
         if (!(cal1.compareTo(cal2) < 0)) {
             errln("!(cal1 < cal2)");
         }
-        if (cal1.compareTo(new GregorianCalendar(2003, Calendar.OCTOBER, 1)) != 0) {
-            errln("cal1 != new GregorianCalendar(2003, Calendar.OCTOBER, 1)");
+        if (cal1.compareTo(new GregorianCalendar(2003, OCTOBER, 1)) != 0) {
+            errln("cal1 != new GregorianCalendar(2003, OCTOBER, 1)");
         }
 
         if (cal0.after(cal2)) {
@@ -2266,10 +2291,10 @@
             errln("cal2 shouldn't be before cal0");
         }
 
-        if (cal0.after(new Integer(0))) {
+        if (cal0.after(0)) {
             errln("cal0.after() returned true with an Integer.");
         }
-        if (cal0.before(new Integer(0))) {
+        if (cal0.before(0)) {
             errln("cal0.before() returned true with an Integer.");
         }
         if (cal0.after(null)) {
@@ -2283,34 +2308,35 @@
     /**
      * 4633646: Setting WEEK_OF_MONTH to 1 results in incorrect date
      */
+    @SuppressWarnings("deprecation")
     public void Test4633646() {
         Koyomi cal = new Koyomi(Locale.US);
-        cal.setTime(new Date(2002-1900, 1-1, 28));
+        cal.setTime(new Date(2002 - 1900, 1 - 1, 28));
         sub4633646(cal);
 
         cal.setLenient(false);
-        cal.setTime(new Date(2002-1900, 1-1, 28));
+        cal.setTime(new Date(2002 - 1900, 1 - 1, 28));
         sub4633646(cal);
 
         cal = new Koyomi(Locale.US);
         cal.clear();
-        cal.set(2002, cal.JANUARY, 28);
+        cal.set(2002, JANUARY, 28);
         sub4633646(cal);
 
         cal.clear();
         cal.setLenient(false);
-        cal.set(2002, cal.JANUARY, 28);
+        cal.set(2002, JANUARY, 28);
         sub4633646(cal);
     }
 
     void sub4633646(Koyomi cal) {
         cal.getTime();
-        cal.set(cal.WEEK_OF_MONTH, 1);
+        cal.set(WEEK_OF_MONTH, 1);
         if (cal.isLenient()) {
-            if (!cal.checkDate(2001, cal.DECEMBER, 31)) {
+            if (!cal.checkDate(2001, DECEMBER, 31)) {
                 errln(cal.getMessage());
             }
-            if (!cal.checkFieldValue(cal.WEEK_OF_MONTH, 6)) {
+            if (!cal.checkFieldValue(WEEK_OF_MONTH, 6)) {
                 errln(cal.getMessage());
             }
         } else {
@@ -2329,29 +2355,29 @@
     public void Test4846659() {
         Koyomi cal = new Koyomi();
         cal.clear();
-        cal.set(2003, cal.OCTOBER, 31, 10, 30, 30);
+        cal.set(2003, OCTOBER, 31, 10, 30, 30);
         cal.getTime();
         // Test roll()
-        cal.roll(cal.AM_PM, +1); // should turn to PM
-        if (!cal.checkFieldValue(cal.HOUR_OF_DAY, 10+12)) {
+        cal.roll(AM_PM, +1); // should turn to PM
+        if (!cal.checkFieldValue(HOUR_OF_DAY, 10 + 12)) {
             errln("roll: AM_PM didn't change to PM");
         }
 
         cal.clear();
-        cal.set(2003, cal.OCTOBER, 31, 10, 30, 30);
+        cal.set(2003, OCTOBER, 31, 10, 30, 30);
         cal.getTime();
         // Test set()
-        cal.set(cal.AM_PM, cal.PM); // should turn to PM
-        if (!cal.checkFieldValue(cal.HOUR_OF_DAY, 10+12)) {
+        cal.set(AM_PM, PM); // should turn to PM
+        if (!cal.checkFieldValue(HOUR_OF_DAY, 10 + 12)) {
             errln("set: AM_PM didn't change to PM");
         }
 
         cal.clear();
-        cal.set(2003, cal.OCTOBER, 31, 10, 30, 30);
+        cal.set(2003, OCTOBER, 31, 10, 30, 30);
         cal.getTime();
-        cal.set(cal.AM_PM, cal.PM);
-        cal.set(cal.HOUR, 9);
-        if (!cal.checkFieldValue(cal.HOUR_OF_DAY, 9+12)) {
+        cal.set(AM_PM, PM);
+        cal.set(HOUR, 9);
+        if (!cal.checkFieldValue(HOUR_OF_DAY, 9 + 12)) {
             errln("set: both AM_PM and HOUT didn't change to PM");
         }
     }
@@ -2370,15 +2396,15 @@
         // 29 30
         cal.clear();
         // 6/1 to 6/7 should be the 1st week of June.
-        cal.set(2003, cal.JUNE, 2);
+        cal.set(2003, JUNE, 2);
         cal.getTime();                  // Let cal calculate time.
-        cal.setFirstDayOfWeek(cal.MONDAY);
+        cal.setFirstDayOfWeek(MONDAY);
         // Now 6/2 to 6/8 should be the 2nd week of June. Sunday of
         // that week is 6/8.
-        logln("1: " +cal.get(cal.WEEK_OF_MONTH)+", "+cal.get(cal.DAY_OF_MONTH));
-        cal.set(cal.DAY_OF_WEEK, cal.SUNDAY);
+        logln("1: " + cal.get(WEEK_OF_MONTH) + ", " + cal.get(DAY_OF_MONTH));
+        cal.set(DAY_OF_WEEK, SUNDAY);
         logln("1st Sunday of June 2003 with FirstDayOfWeek=MONDAY");
-        if (!cal.checkDate(2003, cal.JUNE, 8)) {
+        if (!cal.checkDate(2003, JUNE, 8)) {
             errln(cal.getMessage());
         }
     }
@@ -2387,7 +2413,7 @@
      * 4973919: Inconsistent GregorianCalendar hashCode before and after serialization
      */
     public void Test4966499() throws Exception {
-        GregorianCalendar date1 = new GregorianCalendar(2004, Calendar.JANUARY, 7);
+        GregorianCalendar date1 = new GregorianCalendar(2004, JANUARY, 7);
 
         // Serialize date1
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -2399,15 +2425,15 @@
         // Deserialize it
         ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
         ObjectInputStream ois = new ObjectInputStream(bais);
-        GregorianCalendar date2 = (GregorianCalendar)ois.readObject();
+        GregorianCalendar date2 = (GregorianCalendar) ois.readObject();
 
         if (!date1.equals(date2)) {
             errln("date1.equals(date2) != true");
         }
         if (date1.hashCode() != date2.hashCode()) {
             errln("inconsistent hashCode() value (before=0x"
-                  +Integer.toHexString(date1.hashCode())+
-                  ", after=0x"+Integer.toHexString(date2.hashCode())+")");
+                    + Integer.toHexString(date1.hashCode())
+                    + ", after=0x" + Integer.toHexString(date2.hashCode()) + ")");
         }
     }
 
@@ -2468,29 +2494,26 @@
         TimeZone savedZone = TimeZone.getDefault();
         TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
         try {
-            Map<Date, Boolean> data = new HashMap<Date, Boolean>();
-            data.put(getGregorianDate(999, Calendar.OCTOBER, 1), Boolean.FALSE);
-            data.put(getGregorianDate(1000, Calendar.JANUARY, 1), Boolean.FALSE);
-            data.put(getGregorianDate(1000, Calendar.FEBRUARY, 1), Boolean.FALSE);
-            data.put(getGregorianDate(1000, Calendar.FEBRUARY, 28), Boolean.FALSE);
-            data.put(getGregorianDate(1000, Calendar.MARCH, 1), Boolean.TRUE);
-            data.put(getGregorianDate(1001, Calendar.JANUARY, 1), Boolean.TRUE);
-            data.put(getGregorianDate(1001, Calendar.JANUARY, 6), Boolean.TRUE);
-            data.put(getGregorianDate(1001, Calendar.MARCH, 1), Boolean.TRUE);
+            Map<Date, Boolean> data = new HashMap<>();
+            data.put(getGregorianDate(999, OCTOBER, 1), Boolean.FALSE);
+            data.put(getGregorianDate(1000, JANUARY, 1), Boolean.FALSE);
+            data.put(getGregorianDate(1000, FEBRUARY, 1), Boolean.FALSE);
+            data.put(getGregorianDate(1000, FEBRUARY, 28), Boolean.FALSE);
+            data.put(getGregorianDate(1000, MARCH, 1), Boolean.TRUE);
+            data.put(getGregorianDate(1001, JANUARY, 1), Boolean.TRUE);
+            data.put(getGregorianDate(1001, JANUARY, 6), Boolean.TRUE);
+            data.put(getGregorianDate(1001, MARCH, 1), Boolean.TRUE);
 
-            Iterator<Date> itr = data.keySet().iterator();
-            while (itr.hasNext()) {
-                Date d = itr.next();
-                boolean expected = data.get(d).booleanValue();
+            data.keySet().forEach(d -> {
+                boolean expected = data.get(d);
                 GregorianCalendar cal = new GregorianCalendar();
                 cal.setGregorianChange(d);
                 if (cal.isLeapYear(1000) != expected) {
-                    errln("isLeapYear(1000) returned " + cal.isLeapYear(1000) +
-                          " with cutover date (Julian) " + d);
+                    errln("isLeapYear(1000) returned " + cal.isLeapYear(1000)
+                            + " with cutover date (Julian) " + d);
                 }
-            }
-        }
-        finally {
+            });
+        } finally {
             TimeZone.setDefault(savedZone);
         }
     }
@@ -2511,15 +2534,15 @@
      */
     public void Test5006864() {
         GregorianCalendar cal = new GregorianCalendar();
-        int min = cal.getMinimum(cal.DAY_OF_WEEK_IN_MONTH);
+        int min = cal.getMinimum(DAY_OF_WEEK_IN_MONTH);
         if (min != 1) {
             errln("GregorianCalendar.getMinimum(DAY_OF_WEEK_IN_MONTH) returned "
-                  + min + ", expected 1.");
+                    + min + ", expected 1.");
         }
-        min = cal.getGreatestMinimum(cal.DAY_OF_WEEK_IN_MONTH);
+        min = cal.getGreatestMinimum(DAY_OF_WEEK_IN_MONTH);
         if (min != 1) {
             errln("GregorianCalendar.getGreatestMinimum(DAY_OF_WEEK_IN_MONTH) returned "
-                  + min + ", expected 1.");
+                    + min + ", expected 1.");
         }
     }
 }
--- a/jdk/test/java/util/Calendar/CalendarTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/CalendarTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -30,12 +30,25 @@
  * @key randomness
  */
 
-import java.util.*;
-import java.text.*;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.SimpleTimeZone;
+import java.util.TimeZone;
+
+import static java.util.Calendar.*;
 
 public class CalendarTest extends IntlTest {
-    static final int ONE_DAY = 24*60*60*1000;
+
+    static final int ONE_DAY = 24 * 60 * 60 * 1000;
     static final int EPOCH_JULIAN = 2440588;
 
     public static void main(String argv[]) throws Exception {
@@ -64,32 +77,31 @@
           Changeover +6 days: 1582/10/21 dow=5
           Changeover +7 days: 1582/10/22 dow=6
           */
-        int MON[] = {  9,  9,  9,10,10,10,10, 10, 10, 10, 10, 10, 10, 10, 10 };
-        int DOM[] = { 28, 29, 30, 1, 2, 3, 4, 15, 16, 17, 18, 19, 20, 21, 22 };
-        int DOW[] = {  6,  7,  1, 2, 3, 4, 5,  6,  7,  1,  2,  3,  4,  5,  6 };
+        int[] MON = {  9,  9,  9,10,10,10,10, 10, 10, 10, 10, 10, 10, 10, 10 };
+        int[] DOM = { 28, 29, 30, 1, 2, 3, 4, 15, 16, 17, 18, 19, 20, 21, 22 };
+        int[] DOW = {  6,  7,  1, 2, 3, 4, 5,  6,  7,  1,  2,  3,  4,  5,  6 };
         //                                     ^ <-Changeover Fri Oct 15 1582
-
         try {
             TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
-            Date co = new Date(1582-1900, Calendar.OCTOBER, 15);
+            @SuppressWarnings("deprecation")
+            Date co = new Date(1582 - 1900, OCTOBER, 15);
             GregorianCalendar cal = new GregorianCalendar();
             int j = 0;
             for (int i = -7; i <= 7; ++i, ++j) {
-                Date d = new Date(co.getTime() + i*ONE_DAY);
+                Date d = new Date(co.getTime() + i * ONE_DAY);
                 cal.setTime(d);
-                int y = cal.get(Calendar.YEAR);
-                int mon = cal.get(Calendar.MONTH)+1-Calendar.JANUARY;
-                int dom = cal.get(Calendar.DATE);
-                int dow = cal.get(Calendar.DAY_OF_WEEK);
+                int y = cal.get(YEAR);
+                int mon = cal.get(MONTH) + 1 - JANUARY;
+                int dom = cal.get(DATE);
+                int dow = cal.get(DAY_OF_WEEK);
 
-                logln("Changeover " + (i>=0?"+":"") + i +
-                      " days: " + y + "/" + mon + "/" + dom + " dow=" + dow);
+                logln("Changeover " + (i >= 0 ? "+" : "") + i
+                        + " days: " + y + "/" + mon + "/" + dom + " dow=" + dow);
                 if (y != 1582 || mon != MON[j] || dom != DOM[j] || dow != DOW[j]) {
                     errln(" Fail: Above line is wrong");
                 }
             }
-        }
-        finally {
+        } finally {
             TimeZone.setDefault(savedZone);
         }
     }
@@ -99,22 +111,22 @@
      * of this test, we don't care about timezones and week data
      * (first day of week, minimal days in first week).
      */
+    @SuppressWarnings("deprecation")
     public void TestMapping() {
         TimeZone saveZone = TimeZone.getDefault();
         int[] DATA = {
-            // Julian#   Year  Month               DOM   JULIAN:Year, Month,       DOM
-            2440588,     1970, Calendar.JANUARY,   1,    1969, Calendar.DECEMBER,  19,
-            2415080,     1900, Calendar.MARCH,     1,    1900, Calendar.FEBRUARY,  17,
-            2451604,     2000, Calendar.FEBRUARY,  29,   2000, Calendar.FEBRUARY,  16,
-            2452269,     2001, Calendar.DECEMBER,  25,   2001, Calendar.DECEMBER,  12,
-            2416526,     1904, Calendar.FEBRUARY,  15,   1904, Calendar.FEBRUARY,  2,
-            2416656,     1904, Calendar.JUNE,      24,   1904, Calendar.JUNE,      11,
-            1721426,        1, Calendar.JANUARY,   1,       1, Calendar.JANUARY,   3,
-            2000000,      763, Calendar.SEPTEMBER, 18,    763, Calendar.SEPTEMBER, 14,
-            4000000,     6239, Calendar.JULY,      12,   6239, Calendar.MAY,       28,
-            8000000,    17191, Calendar.FEBRUARY,  26,  17190, Calendar.OCTOBER,   22,
-            10000000,   22666, Calendar.DECEMBER,  20,  22666, Calendar.JULY,      5,
-        };
+            // Julian#   Year      Month    DOM   JULIAN:Year  Month,   DOM
+            2440588,     1970,    JANUARY,   1,    1969,     DECEMBER,  19,
+            2415080,     1900,      MARCH,   1,    1900,     FEBRUARY,  17,
+            2451604,     2000,   FEBRUARY,  29,    2000,     FEBRUARY,  16,
+            2452269,     2001,   DECEMBER,  25,    2001,     DECEMBER,  12,
+            2416526,     1904,   FEBRUARY,  15,    1904,     FEBRUARY,   2,
+            2416656,     1904,       JUNE,  24,    1904,         JUNE,  11,
+            1721426,        1,    JANUARY,   1,       1,      JANUARY,   3,
+            2000000,      763,  SEPTEMBER,  18,     763,    SEPTEMBER,  14,
+            4000000,     6239,       JULY,  12,    6239,          MAY,  28,
+            8000000,    17191,   FEBRUARY,  26,   17190,      OCTOBER,  22,
+           10000000,    22666,   DECEMBER,  20,   22666,         JULY,   5};
 
         try {
             TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
@@ -123,11 +135,11 @@
             GregorianCalendar cal = new GregorianCalendar();
             for (int i = 0; i < DATA.length; i += 7) {
                 int julian = DATA[i];
-                int year = DATA[i+1];
-                int month = DATA[i+2];
-                int dom = DATA[i+3];
+                int year = DATA[i + 1];
+                int month = DATA[i + 2];
+                int dom = DATA[i + 3];
                 int year2, month2, dom2;
-                long millis = ((long)julian - EPOCH_JULIAN) * ONE_DAY;
+                long millis = ((long) julian - EPOCH_JULIAN) * ONE_DAY;
                 String s;
 
                 // Test Gregorian computation
@@ -137,56 +149,55 @@
                 long calMillis = cal.getTime().getTime();
                 long delta = calMillis - millis;
                 cal.setTime(new Date(millis));
-                year2 = cal.get(Calendar.YEAR);
-                month2 = cal.get(Calendar.MONTH);
-                dom2 = cal.get(Calendar.DAY_OF_MONTH);
-                s = "G " + year + "-" + (month+1-Calendar.JANUARY) + "-" + dom +
-                    " => " + calMillis +
-                    " (" + ((float)delta/ONE_DAY) + " day delta) => " +
-                    year2 + "-" + (month2+1-Calendar.JANUARY) + "-" + dom2;
-                if (delta != 0 || year != year2 || month != month2 ||
-                    dom != dom2) {
+                year2 = cal.get(YEAR);
+                month2 = cal.get(MONTH);
+                dom2 = cal.get(DAY_OF_MONTH);
+                s = "G " + year + "-" + (month + 1 - JANUARY) + "-" + dom
+                        + " => " + calMillis
+                        + " (" + ((float) delta / ONE_DAY) + " day delta) => "
+                        + year2 + "-" + (month2 + 1 - JANUARY) + "-" + dom2;
+                if (delta != 0 || year != year2 || month != month2
+                        || dom != dom2) {
                     errln(s + " FAIL");
                 } else {
                     logln(s);
                 }
 
                 // Test Julian computation
-                year = DATA[i+4];
-                month = DATA[i+5];
-                dom = DATA[i+6];
+                year = DATA[i + 4];
+                month = DATA[i + 5];
+                dom = DATA[i + 6];
                 cal.setGregorianChange(PURE_JULIAN);
                 cal.clear();
                 cal.set(year, month, dom);
                 calMillis = cal.getTime().getTime();
                 delta = calMillis - millis;
                 cal.setTime(new Date(millis));
-                year2 = cal.get(Calendar.YEAR);
-                month2 = cal.get(Calendar.MONTH);
-                dom2 = cal.get(Calendar.DAY_OF_MONTH);
-                s = "J " + year + "-" + (month+1-Calendar.JANUARY) + "-" + dom +
-                    " => " + calMillis +
-                    " (" + ((float)delta/ONE_DAY) + " day delta) => " +
-                    year2 + "-" + (month2+1-Calendar.JANUARY) + "-" + dom2;
-                if (delta != 0 || year != year2 || month != month2 ||
-                    dom != dom2) {
+                year2 = cal.get(YEAR);
+                month2 = cal.get(MONTH);
+                dom2 = cal.get(DAY_OF_MONTH);
+                s = "J " + year + "-" + (month + 1 - JANUARY) + "-" + dom
+                        + " => " + calMillis
+                        + " (" + ((float) delta / ONE_DAY) + " day delta) => "
+                        + year2 + "-" + (month2 + 1 - JANUARY) + "-" + dom2;
+                if (delta != 0 || year != year2 || month != month2
+                        || dom != dom2) {
                     errln(s + " FAIL");
                 } else {
                     logln(s);
                 }
             }
 
-            cal.setGregorianChange(new Date(1582-1900, Calendar.OCTOBER, 15));
-            auxMapping(cal, 1582, Calendar.OCTOBER, 4);
-            auxMapping(cal, 1582, Calendar.OCTOBER, 15);
-            auxMapping(cal, 1582, Calendar.OCTOBER, 16);
-            for (int y = 800; y < 3000; y += 1+(int)100*Math.random()) {
-                for (int m = Calendar.JANUARY; m <= Calendar.DECEMBER; ++m) {
+            cal.setGregorianChange(new Date(1582 - 1900, OCTOBER, 15));
+            auxMapping(cal, 1582, OCTOBER, 4);
+            auxMapping(cal, 1582, OCTOBER, 15);
+            auxMapping(cal, 1582, OCTOBER, 16);
+            for (int y = 800; y < 3000; y += 1 + 100 * Math.random()) {
+                for (int m = JANUARY; m <= DECEMBER; ++m) {
                     auxMapping(cal, y, m, 15);
                 }
             }
-        }
-        finally {
+        } finally {
             TimeZone.setDefault(saveZone);
         }
     }
@@ -195,14 +206,16 @@
         cal.set(y, m, d);
         long millis = cal.getTime().getTime();
         cal.setTime(new Date(millis));
-        int year2 = cal.get(Calendar.YEAR);
-        int month2 = cal.get(Calendar.MONTH);
-        int dom2 = cal.get(Calendar.DAY_OF_MONTH);
-        if (y != year2 || m != month2 || dom2 != d)
-            errln("Round-trip failure: " + y + "-" + (m+1) + "-"+d+" =>ms=> " +
-                  year2 + "-" + (month2+1) + "-" + dom2);
+        int year2 = cal.get(YEAR);
+        int month2 = cal.get(MONTH);
+        int dom2 = cal.get(DAY_OF_MONTH);
+        if (y != year2 || m != month2 || dom2 != d) {
+            errln("Round-trip failure: " + y + "-" + (m + 1) + "-" + d + " =>ms=> "
+                    + year2 + "-" + (month2 + 1) + "-" + dom2);
+        }
     }
 
+    @SuppressWarnings("deprecation")
     public void TestGenericAPI() {
         Locale locale = Locale.getDefault();
         if (!TestUtils.usesGregorianCalendar(locale)) {
@@ -211,76 +224,95 @@
         }
 
         String str;
-
-        Date when = new Date(90, Calendar.APRIL, 15);
+        Date when = new Date(90, APRIL, 15);
 
         String tzid = "TestZone";
         int tzoffset = 123400;
 
         SimpleTimeZone zone = new SimpleTimeZone(tzoffset, tzid);
-        Calendar cal = (Calendar)Calendar.getInstance((SimpleTimeZone)zone.clone());
+        Calendar cal = Calendar.getInstance((SimpleTimeZone) zone.clone());
 
-        if (!zone.equals(cal.getTimeZone())) errln("FAIL: Calendar.getTimeZone failed");
+        if (!zone.equals(cal.getTimeZone())) {
+            errln("FAIL: Calendar.getTimeZone failed");
+        }
 
         Calendar cal2 = Calendar.getInstance(cal.getTimeZone());
 
         cal.setTime(when);
         cal2.setTime(when);
 
-        if (!(cal.equals(cal2))) errln("FAIL: Calendar.operator== failed");
+        if (!(cal.equals(cal2))) {
+            errln("FAIL: Calendar.operator== failed");
+        }
         // if ((*cal != *cal2))  errln("FAIL: Calendar.operator!= failed");
-        if (!cal.equals(cal2) ||
-            cal.before(cal2) ||
-            cal.after(cal2)) errln("FAIL: equals/before/after failed");
+        if (!cal.equals(cal2)
+                || cal.before(cal2)
+                || cal.after(cal2)) {
+            errln("FAIL: equals/before/after failed");
+        }
 
         cal2.setTime(new Date(when.getTime() + 1000));
-        if (cal.equals(cal2) ||
-            cal2.before(cal) ||
-            cal.after(cal2)) errln("FAIL: equals/before/after failed");
+        if (cal.equals(cal2)
+                || cal2.before(cal)
+                || cal.after(cal2)) {
+            errln("FAIL: equals/before/after failed");
+        }
 
-        cal.roll(Calendar.SECOND, true);
-        if (!cal.equals(cal2) ||
-            cal.before(cal2) ||
-            cal.after(cal2)) errln("FAIL: equals/before/after failed");
+        cal.roll(SECOND, true);
+        if (!cal.equals(cal2)
+                || cal.before(cal2)
+                || cal.after(cal2)) {
+            errln("FAIL: equals/before/after failed");
+        }
 
         // Roll back to January
-        cal.roll(Calendar.MONTH, (int)(1 + Calendar.DECEMBER - cal.get(Calendar.MONTH)));
-        if (cal.equals(cal2) ||
-            cal2.before(cal) ||
-            cal.after(cal2)) errln("FAIL: equals/before/after failed");
+        cal.roll(MONTH, 1 + DECEMBER - cal.get(MONTH));
+        if (cal.equals(cal2)
+                || cal2.before(cal)
+                || cal.after(cal2)) {
+            errln("FAIL: equals/before/after failed");
+        }
 
         // C++ only
         /* TimeZone z = cal.orphanTimeZone();
-           if (z.getID(str) != tzid ||
-           z.getRawOffset() != tzoffset)
-           errln("FAIL: orphanTimeZone failed");
-           */
-
+        if (z.getID(str) != tzid ||
+        z.getRawOffset() != tzoffset)
+        errln("FAIL: orphanTimeZone failed");
+        */
         for (int i = 0; i < 2; ++i) {
-            boolean lenient = ( i > 0 );
+            boolean lenient = (i > 0);
             cal.setLenient(lenient);
-            if (lenient != cal.isLenient()) errln("FAIL: setLenient/isLenient failed");
+            if (lenient != cal.isLenient()) {
+                errln("FAIL: setLenient/isLenient failed");
+            }
             // Later: Check for lenient behavior
         }
 
         int i;
-        for (i = Calendar.SUNDAY; i <= Calendar.SATURDAY; ++i) {
+        for (i = SUNDAY; i <= SATURDAY; ++i) {
             cal.setFirstDayOfWeek(i);
-            if (cal.getFirstDayOfWeek() != i) errln("FAIL: set/getFirstDayOfWeek failed");
+            if (cal.getFirstDayOfWeek() != i) {
+                errln("FAIL: set/getFirstDayOfWeek failed");
+            }
         }
 
         for (i = 0; i <= 7; ++i) {
             cal.setMinimalDaysInFirstWeek(i);
-            if (cal.getMinimalDaysInFirstWeek() != i) errln("FAIL: set/getFirstDayOfWeek failed");
+            if (cal.getMinimalDaysInFirstWeek() != i) {
+                errln("FAIL: set/getFirstDayOfWeek failed");
+            }
         }
 
-        for (i = 0; i < Calendar.FIELD_COUNT; ++i) {
-            if (cal.getMinimum(i) != cal.getGreatestMinimum(i))
+        for (i = 0; i < FIELD_COUNT; ++i) {
+            if (cal.getMinimum(i) != cal.getGreatestMinimum(i)) {
                 errln("FAIL: getMinimum doesn't match getGreatestMinimum for field " + i);
-            if (cal.getLeastMaximum(i) > cal.getMaximum(i))
+            }
+            if (cal.getLeastMaximum(i) > cal.getMaximum(i)) {
                 errln("FAIL: getLeastMaximum larger than getMaximum for field " + i);
-            if (cal.getMinimum(i) >= cal.getMaximum(i))
+            }
+            if (cal.getMinimum(i) >= cal.getMaximum(i)) {
                 errln("FAIL: getMinimum not less than getMaximum for field " + i);
+            }
         }
 
         cal.setTimeZone(TimeZone.getDefault());
@@ -306,30 +338,36 @@
         }
 
         cal.getTime();
-        for (i = 0; i < Calendar.FIELD_COUNT; ++i) {
-            switch(i) {
-            case Calendar.YEAR: case Calendar.MONTH: case Calendar.DATE:
-            case Calendar.HOUR_OF_DAY: case Calendar.MINUTE: case Calendar.SECOND:
-                if (!cal.isSet(i))
-                    errln("FAIL: !Calendar.isSet test failed: " + calendarFieldNames[i]);
-                break;
-            default:
-                if (cal.isSet(i))
-                    errln("FAIL: Calendar.isSet test failed: " + calendarFieldNames[i]);
+        for (i = 0; i < FIELD_COUNT; ++i) {
+            switch (i) {
+                case YEAR:
+                case MONTH:
+                case DATE:
+                case HOUR_OF_DAY:
+                case MINUTE:
+                case SECOND:
+                    if (!cal.isSet(i)) {
+                        errln("FAIL: !Calendar.isSet test failed: " + calendarFieldNames[i]);
+                    }
+                    break;
+                default:
+                    if (cal.isSet(i)) {
+                        errln("FAIL: Calendar.isSet test failed: " + calendarFieldNames[i]);
+                    }
             }
             cal.clear(i);
-            if (cal.isSet(i)) errln("FAIL: Calendar.clear/isSet failed");
+            if (cal.isSet(i)) {
+                errln("FAIL: Calendar.clear/isSet failed");
+            }
         }
 
         // delete cal;
         // delete cal2;
-
         Locale[] loc = Calendar.getAvailableLocales();
         long count = loc.length;
         if (count < 1 || loc == null) {
             errln("FAIL: getAvailableLocales failed");
-        }
-        else {
+        } else {
             for (i = 0; i < count; ++i) {
                 cal = Calendar.getInstance(loc[i]);
                 // delete cal;
@@ -358,13 +396,15 @@
         // delete gc;
 
         gc = new GregorianCalendar(1998, 10, 14, 21, 43);
-        if (gc.getTime().getTime() != new Date(98, 10, 14, 21, 43).getTime())
+        if (gc.getTime().getTime() != new Date(98, 10, 14, 21, 43).getTime()) {
             errln("FAIL: new GregorianCalendar(ymdhm) failed");
+        }
         // delete gc;
 
         gc = new GregorianCalendar(1998, 10, 14, 21, 43, 55);
-        if (gc.getTime().getTime() != new Date(98, 10, 14, 21, 43, 55).getTime())
+        if (gc.getTime().getTime() != new Date(98, 10, 14, 21, 43, 55).getTime()) {
             errln("FAIL: new GregorianCalendar(ymdhms) failed");
+        }
 
         // C++ only:
         // GregorianCalendar gc2 = new GregorianCalendar(Locale.ENGLISH);
@@ -378,19 +418,20 @@
     public void TestRog() {
         GregorianCalendar gc = new GregorianCalendar();
 
-        int year = 1997, month = Calendar.APRIL, date = 1;
+        int year = 1997, month = APRIL, date = 1;
         gc.set(year, month, date); // April 1, 1997
 
-        gc.set(Calendar.HOUR_OF_DAY, 23);
-        gc.set(Calendar.MINUTE, 0);
-        gc.set(Calendar.SECOND, 0);
-        gc.set(Calendar.MILLISECOND, 0);
+        gc.set(HOUR_OF_DAY, 23);
+        gc.set(MINUTE, 0);
+        gc.set(SECOND, 0);
+        gc.set(MILLISECOND, 0);
 
-        for (int i = 0; i < 9; i++, gc.add(Calendar.DATE, 1)) {
-            if (gc.get(Calendar.YEAR) != year ||
-                gc.get(Calendar.MONTH) != month ||
-                gc.get(Calendar.DATE) != (date + i))
+        for (int i = 0; i < 9; i++, gc.add(DATE, 1)) {
+            if (gc.get(YEAR) != year
+                    || gc.get(MONTH) != month
+                    || gc.get(DATE) != (date + i)) {
                 errln("FAIL: Date " + gc.getTime() + " wrong");
+            }
         }
     }
 
@@ -402,162 +443,172 @@
 
     void dowTest(boolean lenient) {
         GregorianCalendar cal = new GregorianCalendar();
-        cal.set(1997, Calendar.AUGUST, 12); // Wednesday
+        cal.set(1997, AUGUST, 12); // Wednesday
         cal.getTime(); // Force update
         cal.setLenient(lenient);
-        cal.set(1996, Calendar.DECEMBER, 1); // Set the date to be December 1, 1996
-        int dow = cal.get(Calendar.DAY_OF_WEEK);
-        int min = cal.getMinimum(Calendar.DAY_OF_WEEK);
-        int max = cal.getMaximum(Calendar.DAY_OF_WEEK);
-        if (dow < min || dow > max) errln("FAIL: Day of week " + dow + " out of range");
-        if (dow != Calendar.SUNDAY) {
+        cal.set(1996, DECEMBER, 1); // Set the date to be December 1, 1996
+        int dow = cal.get(DAY_OF_WEEK);
+        int min = cal.getMinimum(DAY_OF_WEEK);
+        int max = cal.getMaximum(DAY_OF_WEEK);
+        if (dow < min || dow > max) {
+            errln("FAIL: Day of week " + dow + " out of range");
+        }
+        if (dow != SUNDAY) {
             errln("FAIL2: Day of week should be SUNDAY; is " + dow + ": " + cal.getTime());
         }
-        if (min != Calendar.SUNDAY || max != Calendar.SATURDAY) errln("FAIL: Min/max bad");
+        if (min != SUNDAY || max != SATURDAY) {
+            errln("FAIL: Min/max bad");
+        }
     }
 
     // Verify that the clone method produces distinct objects with no
     // unintentionally shared fields.
     public void TestClonesUnique908() {
         Calendar c = Calendar.getInstance();
-        Calendar d = (Calendar)c.clone();
-        c.set(Calendar.MILLISECOND, 123);
-        d.set(Calendar.MILLISECOND, 456);
-        if (c.get(Calendar.MILLISECOND) != 123 ||
-            d.get(Calendar.MILLISECOND) != 456) {
+        Calendar d = (Calendar) c.clone();
+        c.set(MILLISECOND, 123);
+        d.set(MILLISECOND, 456);
+        if (c.get(MILLISECOND) != 123
+                || d.get(MILLISECOND) != 456) {
             errln("FAIL: Clones share fields");
         }
     }
 
     // Verify effect of Gregorian cutoff value
+    @SuppressWarnings("deprecation")
     public void TestGregorianChange768() {
         boolean b;
         GregorianCalendar c = new GregorianCalendar();
         logln("With cutoff " + c.getGregorianChange());
-        logln(" isLeapYear(1800) = " + (b=c.isLeapYear(1800)));
+        logln(" isLeapYear(1800) = " + (b = c.isLeapYear(1800)));
         logln(" (should be FALSE)");
-        if (b != false) errln("FAIL");
+        if (b != false) {
+            errln("FAIL");
+        }
         c.setGregorianChange(new Date(0, 0, 1)); // Jan 1 1900
         logln("With cutoff " + c.getGregorianChange());
-        logln(" isLeapYear(1800) = " + (b=c.isLeapYear(1800)));
+        logln(" isLeapYear(1800) = " + (b = c.isLeapYear(1800)));
         logln(" (should be TRUE)");
-        if (b != true) errln("FAIL");
+        if (b != true) {
+            errln("FAIL");
+        }
     }
 
     // Test the correct behavior of the disambiguation algorithm.
     public void TestDisambiguation765() throws Exception {
-      Locale savedLocale = Locale.getDefault();
-      try {
-        Locale.setDefault(Locale.US);
-        Calendar c = Calendar.getInstance();
-        c.setLenient(false);
+        Locale savedLocale = Locale.getDefault();
+        try {
+            Locale.setDefault(Locale.US);
+            Calendar c = Calendar.getInstance();
+            c.setLenient(false);
 
-        c.clear();
-        c.set(Calendar.YEAR, 1997);
-        c.set(Calendar.MONTH, Calendar.JUNE);
-        c.set(Calendar.DATE, 3);
+            c.clear();
+            c.set(YEAR, 1997);
+            c.set(MONTH, JUNE);
+            c.set(DATE, 3);
 
-        verify765("1997 third day of June = ", c, 1997, Calendar.JUNE, 3);
+            verify765("1997 third day of June = ", c, 1997, JUNE, 3);
 
-        c.clear();
-        c.set(Calendar.YEAR, 1997);
-        c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
-        c.set(Calendar.MONTH, Calendar.JUNE);
-        c.set(Calendar.DAY_OF_WEEK_IN_MONTH, 1);
-        verify765("1997 first Tuesday in June = ", c, 1997, Calendar.JUNE, 3);
+            c.clear();
+            c.set(YEAR, 1997);
+            c.set(DAY_OF_WEEK, TUESDAY);
+            c.set(MONTH, JUNE);
+            c.set(DAY_OF_WEEK_IN_MONTH, 1);
+            verify765("1997 first Tuesday in June = ", c, 1997, JUNE, 3);
 
-        c.setLenient(true); // for 4944795
-        c.clear();
-        c.set(Calendar.YEAR, 1997);
-        c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
-        c.set(Calendar.MONTH, Calendar.JUNE);
-        c.set(Calendar.DAY_OF_WEEK_IN_MONTH, -1);
-        verify765("1997 last Tuesday in June = ", c, 1997, Calendar.JUNE, 24);
-
-        c.setLenient(false);
-        IllegalArgumentException e = null;
-        try {
+            c.setLenient(true); // for 4944795
             c.clear();
-            c.set(Calendar.YEAR, 1997);
-            c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
-            c.set(Calendar.MONTH, Calendar.JUNE);
-            c.set(Calendar.DAY_OF_WEEK_IN_MONTH, 0);
-            c.getTime();
-        }
-        catch (IllegalArgumentException ex) {
-            e = ex;
-        }
-        verify765("1997 zero-th Tuesday in June = ", e);
+            c.set(YEAR, 1997);
+            c.set(DAY_OF_WEEK, TUESDAY);
+            c.set(MONTH, JUNE);
+            c.set(DAY_OF_WEEK_IN_MONTH, -1);
+            verify765("1997 last Tuesday in June = ", c, 1997, JUNE, 24);
 
-        c.clear();
-        c.set(Calendar.YEAR, 1997);
-        c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
-        c.set(Calendar.MONTH, Calendar.JUNE);
-        c.set(Calendar.WEEK_OF_MONTH, 1);
-        verify765("1997 Tuesday in week 1 of June = ", c, 1997, Calendar.JUNE, 3);
+            c.setLenient(false);
+            IllegalArgumentException e = null;
+            try {
+                c.clear();
+                c.set(YEAR, 1997);
+                c.set(DAY_OF_WEEK, TUESDAY);
+                c.set(MONTH, JUNE);
+                c.set(DAY_OF_WEEK_IN_MONTH, 0);
+                c.getTime();
+            } catch (IllegalArgumentException ex) {
+                e = ex;
+            }
+            verify765("1997 zero-th Tuesday in June = ", e);
 
-        c.clear();
-        c.set(Calendar.YEAR, 1997);
-        c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
-        c.set(Calendar.MONTH, Calendar.JUNE);
-        c.set(Calendar.WEEK_OF_MONTH, 4);
-        verify765("1997 Tuesday in week 4 of June = ", c, 1997, Calendar.JUNE, 24);
-
-        try {
             c.clear();
-            c.set(Calendar.YEAR, 1997);
-            c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
-            c.set(Calendar.MONTH, Calendar.JUNE);
-            c.set(Calendar.WEEK_OF_MONTH, 1);
-            verify765("1997 Tuesday in week 0 of June = ", c, 1997, Calendar.JUNE, 3);
-        }
-        catch (IllegalArgumentException ex) {
-            errln("FAIL: Exception seen: " + ex.getMessage());
-            // ex.printStackTrace(log);
-        }
+            c.set(YEAR, 1997);
+            c.set(DAY_OF_WEEK, TUESDAY);
+            c.set(MONTH, JUNE);
+            c.set(WEEK_OF_MONTH, 1);
+            verify765("1997 Tuesday in week 1 of June = ", c, 1997, JUNE, 3);
 
-        c.clear();
-        c.set(Calendar.YEAR, 1997);
-        c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
-        c.set(Calendar.WEEK_OF_YEAR, 2);
-        verify765("1997 Tuesday in week 2 of year = ", c, 1997, Calendar.JANUARY, 7);
+            c.clear();
+            c.set(YEAR, 1997);
+            c.set(DAY_OF_WEEK, TUESDAY);
+            c.set(MONTH, JUNE);
+            c.set(WEEK_OF_MONTH, 4);
+            verify765("1997 Tuesday in week 4 of June = ", c, 1997, JUNE, 24);
 
-        c.clear();
-        c.set(Calendar.YEAR, 1997);
-        c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
-        c.set(Calendar.WEEK_OF_YEAR, 10);
-        verify765("1997 Tuesday in week 10 of year = ", c, 1997, Calendar.MARCH, 4);
+            try {
+                c.clear();
+                c.set(YEAR, 1997);
+                c.set(DAY_OF_WEEK, TUESDAY);
+                c.set(MONTH, JUNE);
+                c.set(WEEK_OF_MONTH, 1);
+                verify765("1997 Tuesday in week 0 of June = ", c, 1997, JUNE, 3);
+            } catch (IllegalArgumentException ex) {
+                errln("FAIL: Exception seen: " + ex.getMessage());
+                // ex.printStackTrace(log);
+            }
 
-        try {
             c.clear();
-            c.set(Calendar.YEAR, 1997);
-            c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
-            c.set(Calendar.WEEK_OF_YEAR, 0);
-            verify765("1997 Tuesday in week 0 of year = ", c, 1996, Calendar.DECEMBER, 24);
-            throw new Exception("Fail: WEEK_OF_YEAR 0 should be illegal");
-        }
-        catch (IllegalArgumentException ex) {}
-      }
-      finally {
-          Locale.setDefault(savedLocale);
-      }
-    }
-    void verify765(String msg, Calendar c, int year, int month, int day) {
-        if (c.get(Calendar.YEAR) == year &&
-            c.get(Calendar.MONTH) == month &&
-            c.get(Calendar.DATE) == day) {
-            logln("PASS: " + msg + c.getTime());
-        }
-        else {
-            errln("FAIL: " + msg + c.getTime() +
-                  "; expected " +
-                  year + "/" + (month+1) + "/" + day);
+            c.set(YEAR, 1997);
+            c.set(DAY_OF_WEEK, TUESDAY);
+            c.set(WEEK_OF_YEAR, 2);
+            verify765("1997 Tuesday in week 2 of year = ", c, 1997, JANUARY, 7);
+
+            c.clear();
+            c.set(YEAR, 1997);
+            c.set(DAY_OF_WEEK, TUESDAY);
+            c.set(WEEK_OF_YEAR, 10);
+            verify765("1997 Tuesday in week 10 of year = ", c, 1997, MARCH, 4);
+
+            try {
+                c.clear();
+                c.set(YEAR, 1997);
+                c.set(DAY_OF_WEEK, TUESDAY);
+                c.set(WEEK_OF_YEAR, 0);
+                verify765("1997 Tuesday in week 0 of year = ", c, 1996, DECEMBER, 24);
+                throw new Exception("Fail: WEEK_OF_YEAR 0 should be illegal");
+            } catch (IllegalArgumentException ex) {
+            }
+        } finally {
+            Locale.setDefault(savedLocale);
         }
     }
+
+    void verify765(String msg, Calendar c, int year, int month, int day) {
+        if (c.get(YEAR) == year
+                && c.get(MONTH) == month
+                && c.get(DATE) == day) {
+            logln("PASS: " + msg + c.getTime());
+        } else {
+            errln("FAIL: " + msg + c.getTime()
+                    + "; expected "
+                    + year + "/" + (month + 1) + "/" + day);
+        }
+    }
+
     // Called when e expected to be non-null
     void verify765(String msg, IllegalArgumentException e) {
-        if (e == null) errln("FAIL: No IllegalArgumentException for " + msg);
-        else logln("PASS: " + msg + "IllegalArgument as expected");
+        if (e == null) {
+            errln("FAIL: No IllegalArgumentException for " + msg);
+        } else {
+            logln("PASS: " + msg + "IllegalArgument as expected");
+        }
     }
 
     // Test the behavior of GMT vs. local time
@@ -588,106 +639,112 @@
         Date date;
         Calendar gmtcal = Calendar.getInstance();
         gmtcal.setTimeZone(TimeZone.getTimeZone("Africa/Casablanca"));
-        gmtcal.set(yr, mo-1, dt, hr, mn, sc);
-        gmtcal.set(Calendar.MILLISECOND, 0);
+        gmtcal.set(yr, mo - 1, dt, hr, mn, sc);
+        gmtcal.set(MILLISECOND, 0);
 
         date = gmtcal.getTime();
-        logln("date = "+date);
+        logln("date = " + date);
 
         Calendar cal = Calendar.getInstance();
         cal.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
         cal.setTime(date);
 
-        int offset = cal.getTimeZone().getOffset(cal.get(Calendar.ERA),
-                                                 cal.get(Calendar.YEAR),
-                                                 cal.get(Calendar.MONTH),
-                                                 cal.get(Calendar.DATE),
-                                                 cal.get(Calendar.DAY_OF_WEEK),
-                                                 cal.get(Calendar.MILLISECOND));
+        int offset = cal.getTimeZone().getOffset(cal.get(ERA),
+                cal.get(YEAR),
+                cal.get(MONTH),
+                cal.get(DATE),
+                cal.get(DAY_OF_WEEK),
+                cal.get(MILLISECOND));
 
-        logln("offset for "+date+"= "+(offset/1000/60/60.0) + "hr");
+        logln("offset for " + date + "= " + (offset / 1000 / 60 / 60.0) + "hr");
 
-        int utc = ((cal.get(Calendar.HOUR_OF_DAY) * 60 +
-                    cal.get(Calendar.MINUTE)) * 60 +
-                   cal.get(Calendar.SECOND)) * 1000 +
-            cal.get(Calendar.MILLISECOND) - offset;
+        int utc = ((cal.get(HOUR_OF_DAY) * 60
+                + cal.get(MINUTE)) * 60
+                + cal.get(SECOND)) * 1000
+                + cal.get(MILLISECOND) - offset;
 
         int expected = ((hr * 60 + mn) * 60 + sc) * 1000;
 
-        if (utc != expected)
-            errln("FAIL: Discrepancy of " +
-                  (utc - expected) + " millis = " +
-                  ((utc-expected)/1000/60/60.0) + " hr");
+        if (utc != expected) {
+            errln("FAIL: Discrepancy of "
+                    + (utc - expected) + " millis = "
+                    + ((utc - expected) / 1000 / 60 / 60.0) + " hr");
+        }
     }
 
     // Verify that add and set work regardless of the order in which
     // they are called.
     public void TestAddSetOrder621() {
+        @SuppressWarnings("deprecation")
         Date d = new Date(97, 4, 14, 13, 23, 45);
 
-        Calendar cal = Calendar.getInstance ();
-        cal.setTime (d);
-        cal.add (Calendar.DATE, -5);
-        cal.set (Calendar.HOUR_OF_DAY, 0);
-        cal.set (Calendar.MINUTE, 0);
-        cal.set (Calendar.SECOND, 0);
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(d);
+        cal.add(DATE, -5);
+        cal.set(HOUR_OF_DAY, 0);
+        cal.set(MINUTE, 0);
+        cal.set(SECOND, 0);
         // ma feb 03 00:00:00 GMT+00:00 1997
-        String s = cal.getTime ().toString ();
+        String s = cal.getTime().toString();
 
-        cal = Calendar.getInstance ();
-        cal.setTime (d);
-        cal.set (Calendar.HOUR_OF_DAY, 0);
-        cal.set (Calendar.MINUTE, 0);
-        cal.set (Calendar.SECOND, 0);
-        cal.add (Calendar.DATE, -5);
+        cal = Calendar.getInstance();
+        cal.setTime(d);
+        cal.set(HOUR_OF_DAY, 0);
+        cal.set(MINUTE, 0);
+        cal.set(SECOND, 0);
+        cal.add(DATE, -5);
         // ma feb 03 13:11:06 GMT+00:00 1997
-        String s2 = cal.getTime ().toString ();
+        String s2 = cal.getTime().toString();
 
-        if (s.equals(s2))
+        if (s.equals(s2)) {
             logln("Pass: " + s + " == " + s2);
-        else
+        } else {
             errln("FAIL: " + s + " != " + s2);
+        }
     }
 
     // Verify that add works.
     public void TestAdd520() {
-        int y = 1997, m = Calendar.FEBRUARY, d = 1;
-        GregorianCalendar temp = new GregorianCalendar( y, m, d );
+        int y = 1997, m = FEBRUARY, d = 1;
+        GregorianCalendar temp = new GregorianCalendar(y, m, d);
         check520(temp, y, m, d);
 
-        temp.add( temp.YEAR, 1 );
+        temp.add(YEAR, 1);
         y++;
         check520(temp, y, m, d);
 
-        temp.add( temp.MONTH, 1 );
+        temp.add(MONTH, 1);
         m++;
         check520(temp, y, m, d);
 
-        temp.add( temp.DATE, 1 );
+        temp.add(DATE, 1);
         d++;
         check520(temp, y, m, d);
 
-        temp.add( temp.DATE, 2 );
+        temp.add(DATE, 2);
         d += 2;
         check520(temp, y, m, d);
 
-        temp.add( temp.DATE, 28 );
-        d = 1; ++m;
+        temp.add(DATE, 28);
+        d = 1;
+        ++m;
         check520(temp, y, m, d);
     }
+
     void check520(Calendar c, int y, int m, int d) {
-        if (c.get(Calendar.YEAR) != y ||
-            c.get(Calendar.MONTH) != m ||
-            c.get(Calendar.DATE) != d) {
-            errln("FAILURE: Expected YEAR/MONTH/DATE of " +
-                  y + "/" + (m+1) + "/" + d +
-                  "; got " +
-                  c.get(Calendar.YEAR) + "/" +
-                  (c.get(Calendar.MONTH)+1) + "/" +
-                  c.get(Calendar.DATE));
+        if (c.get(YEAR) != y
+                || c.get(MONTH) != m
+                || c.get(DATE) != d) {
+            errln("FAILURE: Expected YEAR/MONTH/DATE of "
+                    + y + "/" + (m + 1) + "/" + d
+                    + "; got "
+                    + c.get(YEAR) + "/"
+                    + (c.get(MONTH) + 1) + "/"
+                    + c.get(DATE));
+        } else {
+            logln("Confirmed: "
+                    + y + "/" + (m + 1) + "/" + d);
         }
-        else logln("Confirmed: " +
-                   y + "/" + (m+1) + "/" + d);
     }
 
     // Verify that setting fields works.  This test fails when an exception is thrown.
@@ -697,18 +754,18 @@
             GregorianCalendar g2 = new GregorianCalendar();
             // At this point UTC value is set, various fields are not.
             // Now set to noon.
-            g2.set(Calendar.HOUR, 12);
-            g2.set(Calendar.MINUTE, 0);
-            g2.set(Calendar.SECOND, 0);
+            g2.set(HOUR, 12);
+            g2.set(MINUTE, 0);
+            g2.set(SECOND, 0);
             // At this point the object thinks UTC is NOT set, but fields are set.
             // The following line will result in IllegalArgumentException because
             // it thinks the YEAR is set and it is NOT.
-            if (g2.equals(g))
+            if (g2.equals(g)) {
                 logln("Same");
-            else
+            } else {
                 logln("Different");
-        }
-        catch (IllegalArgumentException e) {
+            }
+        } catch (IllegalArgumentException e) {
             errln("Unexpected exception seen: " + e);
         }
     }
@@ -729,28 +786,28 @@
 
             FileInputStream in = new FileInputStream(FILENAME);
             ObjectInputStream t = new ObjectInputStream(in);
-            String pre = (String)t.readObject();
-            Calendar c = (Calendar)t.readObject();
-            String post = (String)t.readObject();
+            String pre = (String) t.readObject();
+            Calendar c = (Calendar) t.readObject();
+            String post = (String) t.readObject();
             in.close();
 
-            ok = pre.equals(PREFIX) &&
-                post.equals(POSTFIX) &&
-                cal.equals(c);
+            ok = pre.equals(PREFIX)
+                    && post.equals(POSTFIX)
+                    && cal.equals(c);
 
             File fl = new File(FILENAME);
             fl.delete();
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             errln("FAIL: Exception received:");
             // e.printStackTrace(log);
-        }
-        catch (ClassNotFoundException e) {
+        } catch (ClassNotFoundException e) {
             errln("FAIL: Exception received:");
             // e.printStackTrace(log);
         }
 
-        if (!ok) errln("Serialization of Calendar object failed.");
+        if (!ok) {
+            errln("Serialization of Calendar object failed.");
+        }
     }
     static final String PREFIX = "abc";
     static final String POSTFIX = "def";
@@ -758,14 +815,16 @@
 
     // Try to zero out the seconds field
     public void TestSecondsZero121() {
-        Calendar        cal = new GregorianCalendar();
+        Calendar cal = new GregorianCalendar();
         // Initialize with current date/time
         cal.setTime(new Date());
         // Round down to minute
-        cal.set(Calendar.SECOND, 0);
-        Date    d = cal.getTime();
+        cal.set(SECOND, 0);
+        Date d = cal.getTime();
         String s = d.toString();
-        if (s.indexOf(":00 ") < 0) errln("Expected to see :00 in " + s);
+        if (s.indexOf(":00 ") < 0) {
+            errln("Expected to see :00 in " + s);
+        }
     }
 
     // Try various sequences of add, set, and get method calls.
@@ -777,15 +836,17 @@
         // - Addition uses millis which are still *now*
         //
         {
-            Calendar calendar = new GregorianCalendar( ) ;
-            calendar.set( 1993, Calendar.JANUARY, 4 ) ;
-            logln( "1A) " + value( calendar ) ) ;
-            calendar.add( Calendar.DATE, 1 ) ;
+            Calendar calendar = new GregorianCalendar();
+            calendar.set(1993, JANUARY, 4);
+            logln("1A) " + value(calendar));
+            calendar.add(DATE, 1);
             String v = value(calendar);
-            logln( "1B) " + v );
-            logln( "--) 1993/0/5" ) ;
-            if (!v.equals(EXPECTED_0610)) errln("Expected " + EXPECTED_0610 +
-                                                "; saw " + v);
+            logln("1B) " + v);
+            logln("--) 1993/0/5");
+            if (!v.equals(EXPECTED_0610)) {
+                errln("Expected " + EXPECTED_0610
+                        + "; saw " + v);
+            }
         }
 
         //
@@ -793,16 +854,17 @@
         // - Upon initialization calendar fields set, millis = 0
         // - Addition uses millis which are still 1970, 0, 1
         //
-
         {
-            Calendar calendar = new GregorianCalendar( 1993, Calendar.JANUARY, 4 ) ;
-            logln( "2A) " + value( calendar ) ) ;
-            calendar.add( Calendar.DATE, 1 ) ;
+            Calendar calendar = new GregorianCalendar(1993, JANUARY, 4);
+            logln("2A) " + value(calendar));
+            calendar.add(DATE, 1);
             String v = value(calendar);
-            logln( "2B) " + v );
-            logln( "--) 1993/0/5" ) ;
-            if (!v.equals(EXPECTED_0610)) errln("Expected " + EXPECTED_0610 +
-                                                "; saw " + v);
+            logln("2B) " + v);
+            logln("--) 1993/0/5");
+            if (!v.equals(EXPECTED_0610)) {
+                errln("Expected " + EXPECTED_0610
+                        + "; saw " + v);
+            }
         }
 
         //
@@ -811,102 +873,99 @@
         // - getTime( ) is called which forces the millis to be set
         // - Addition uses millis which are correct
         //
-
         {
-            Calendar calendar = new GregorianCalendar( 1993, Calendar.JANUARY, 4 ) ;
-            logln( "3A) " + value( calendar ) ) ;
-            calendar.getTime( ) ;
-            calendar.add( Calendar.DATE, 1 ) ;
+            Calendar calendar = new GregorianCalendar(1993, JANUARY, 4);
+            logln("3A) " + value(calendar));
+            calendar.getTime();
+            calendar.add(DATE, 1);
             String v = value(calendar);
-            logln( "3B) " + v ) ;
-            logln( "--) 1993/0/5" ) ;
-            if (!v.equals(EXPECTED_0610)) errln("Expected " + EXPECTED_0610 +
-                                                "; saw " + v);
+            logln("3B) " + v);
+            logln("--) 1993/0/5");
+            if (!v.equals(EXPECTED_0610)) {
+                errln("Expected " + EXPECTED_0610
+                        + "; saw " + v);
+            }
         }
     }
-    static String value( Calendar calendar ) {
-        return( calendar.get( Calendar.YEAR )  + "/" +
-                calendar.get( Calendar.MONTH ) + "/" +
-                calendar.get( Calendar.DATE ) ) ;
+    static String value(Calendar calendar) {
+        return (calendar.get(YEAR) + "/"
+                + calendar.get(MONTH) + "/"
+                + calendar.get(DATE));
     }
     static String EXPECTED_0610 = "1993/0/5";
 
     // Test that certain fields on a certain date are as expected.
     public void TestFields060() {
         int year = 1997;
-        int month = java.util.Calendar.OCTOBER;  //october
+        int month = OCTOBER;  //october
         int dDate = 22;   //DAYOFWEEK should return 3 for Wednesday
         GregorianCalendar calendar = null;
 
-        calendar = new GregorianCalendar( year, month, dDate);
-        for (int i = 0; i < EXPECTED_FIELDS.length; ) {
+        calendar = new GregorianCalendar(year, month, dDate);
+        for (int i = 0; i < EXPECTED_FIELDS.length;) {
             int field = EXPECTED_FIELDS[i++];
             int expected = EXPECTED_FIELDS[i++];
             if (calendar.get(field) != expected) {
-                errln("Expected field " + field + " to have value " + expected +
-                      "; received " + calendar.get(field) + " instead");
+                errln("Expected field " + field + " to have value " + expected
+                        + "; received " + calendar.get(field) + " instead");
             }
         }
     }
-    static int EXPECTED_FIELDS[] = {
-        Calendar.YEAR, 1997,
-        Calendar.MONTH, Calendar.OCTOBER,
-        Calendar.DAY_OF_MONTH, 22,
-        Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY,
-        Calendar.DAY_OF_WEEK_IN_MONTH, 4,
-        Calendar.DAY_OF_YEAR, 295
-    };
+    static int[] EXPECTED_FIELDS = {
+        YEAR, 1997,
+        MONTH, OCTOBER,
+        DAY_OF_MONTH, 22,
+        DAY_OF_WEEK, WEDNESDAY,
+        DAY_OF_WEEK_IN_MONTH, 4,
+        DAY_OF_YEAR, 295};
 
     static final String[] calendarFieldNames = {
-      /*  0 */  "ERA",
-      /*  1 */  "YEAR",
-      /*  2 */  "MONTH",
-      /*  3 */  "WEEK_OF_YEAR",
-      /*  4 */  "WEEK_OF_MONTH",
-      /*  5 */  "DAY_OF_MONTH",
-      /*  6 */  "DAY_OF_YEAR",
-      /*  7 */  "DAY_OF_WEEK",
-      /*  8 */  "DAY_OF_WEEK_IN_MONTH",
-      /*  9 */  "AM_PM",
-      /* 10 */  "HOUR",
-      /* 11 */  "HOUR_OF_DAY",
-      /* 12 */  "MINUTE",
-      /* 13 */  "SECOND",
-      /* 14 */  "MILLISECOND",
-      /* 15 */  "ZONE_OFFSET",
-      /* 16 */  "DST_OFFSET"
-    };
+        /*  0 */ "ERA",
+        /*  1 */ "YEAR",
+        /*  2 */ "MONTH",
+        /*  3 */ "WEEK_OF_YEAR",
+        /*  4 */ "WEEK_OF_MONTH",
+        /*  5 */ "DAY_OF_MONTH",
+        /*  6 */ "DAY_OF_YEAR",
+        /*  7 */ "DAY_OF_WEEK",
+        /*  8 */ "DAY_OF_WEEK_IN_MONTH",
+        /*  9 */ "AM_PM",
+        /* 10 */ "HOUR",
+        /* 11 */ "HOUR_OF_DAY",
+        /* 12 */ "MINUTE",
+        /* 13 */ "SECOND",
+        /* 14 */ "MILLISECOND",
+        /* 15 */ "ZONE_OFFSET",
+        /* 16 */ "DST_OFFSET"};
 
     // Verify that the fields are as expected (mostly zero) at the epoch start.
     // Note that we adjust for the default timezone to get most things to zero.
     public void TestEpochStartFields() {
         String[][] lt = {
-          {"en", "US", "US/Pacific"},        /* First day = 1, Minimum day = 1 */
-          {"en", "US", "America/Anchorage"}, /* First day = 1, Minimum day = 1 */
-          {"en", "TO", "Pacific/Tongatapu"}, /* First day = 1, Minimum day = 1 */
-          {"en", "MH", "Pacific/Majuro"},    /* First day = 1, Minimum day = 1 */
-          {"ja", "JP", "Asia/Tokyo"},        /* First day = 1, Minimum day = 1 */
-          {"iw", "IL", "Asia/Jerusalem"},    /* First day = 1, Minimum day = 1 */
-          {"hi", "IN", "Asia/Jakarta"},      /* First day = 1, Minimum day = 1 */
-          {"en", "GB", "Europe/London"},     /* First day = 2, Minimum day = 1 */
-          {"en", "GB", "GMT"},               /* First day = 2, Minimum day = 1 */
-          {"de", "DE", "Europe/Berlin"},     /* First day = 2, Minimum day = 4 */
-          {"ar", "EG", "Africa/Cairo"},      /* First day = 7, Minimum day = 1 */
-        };
+            {"en", "US", "US/Pacific"},        /* First day = 1, Minimum day = 1 */
+            {"en", "US", "America/Anchorage"}, /* First day = 1, Minimum day = 1 */
+            {"en", "TO", "Pacific/Tongatapu"}, /* First day = 1, Minimum day = 1 */
+            {"en", "MH", "Pacific/Majuro"},    /* First day = 1, Minimum day = 1 */
+            {"ja", "JP", "Asia/Tokyo"},        /* First day = 1, Minimum day = 1 */
+            {"iw", "IL", "Asia/Jerusalem"},    /* First day = 1, Minimum day = 1 */
+            {"hi", "IN", "Asia/Jakarta"},      /* First day = 1, Minimum day = 1 */
+            {"en", "GB", "Europe/London"},     /* First day = 2, Minimum day = 1 */
+            {"en", "GB", "GMT"},               /* First day = 2, Minimum day = 1 */
+            {"de", "DE", "Europe/Berlin"},     /* First day = 2, Minimum day = 4 */
+            {"ar", "EG", "Africa/Cairo"}};     /* First day = 7, Minimum day = 1 */
 
         int[][] goldenData = {
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, -28800000, 0},
-              {1, 1969, 11, 1, 5, 31, 365, 4, 5, 1, 11, 23, 0, 0, 0, -36000000, 0},
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 46800000, 0},
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 43200000, 0},
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 32400000, 0},
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 7200000, 0},
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 25200000, 0},
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 1, 1, 0, 0, 0, 3600000, 0},
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0},
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 3600000, 0},
-              {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 7200000, 0},
-        };
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, -28800000, 0},
+            {1, 1969, 11, 1, 5, 31, 365, 4, 5, 1, 11, 23, 0, 0, 0, -36000000, 0},
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 46800000, 0},
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 43200000, 0},
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 32400000, 0},
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 7200000, 0},
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 25200000, 0},
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 1, 1, 0, 0, 0, 3600000, 0},
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0},
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 3600000, 0},
+            {1, 1970, 0, 1, 1, 1, 1, 5, 1, 0, 0, 0, 0, 0, 0, 7200000, 0}};
 
         Locale savedLocale = Locale.getDefault();
         TimeZone savedTimeZone = TimeZone.getDefault();
@@ -927,19 +986,18 @@
                 boolean err = false;
                 for (int i = 0; i < calendarFieldNames.length; ++i) {
                     if ((val = c.get(i)) != EPOCH_FIELDS[i]) {
-                        errln("Wrong value: " + val +
-                              " for field(" + calendarFieldNames[i] +
-                              "), expected: " + EPOCH_FIELDS[i]);
+                        errln("Wrong value: " + val
+                                + " for field(" + calendarFieldNames[i]
+                                + "), expected: " + EPOCH_FIELDS[i]);
                         err = true;
                     }
                 }
                 if (err) {
-                    errln("Failed: \n\tDate=" + d + "\n\tTimeZone=" + z +
-                          "\n\tLocale=" + l + "\n\tCalendar=" + c);
+                    errln("Failed: \n\tDate=" + d + "\n\tTimeZone=" + z
+                            + "\n\tLocale=" + l + "\n\tCalendar=" + c);
                 }
             }
-        }
-        finally {
+        } finally {
             Locale.setDefault(savedLocale);
             TimeZone.setDefault(savedTimeZone);
         }
@@ -948,125 +1006,146 @@
     // Verify that as you add days to the calendar (e.g., 24 day periods),
     // the day of the week shifts in the expected pattern.
     public void TestDOWProgression() {
-        Calendar cal =
-            new GregorianCalendar(1972, Calendar.OCTOBER, 26);
+        Calendar cal
+                = new GregorianCalendar(1972, OCTOBER, 26);
         marchByDelta(cal, 24); // Last parameter must be != 0 modulo 7
     }
 
     // Supply a delta which is not a multiple of 7.
     void marchByDelta(Calendar cal, int delta) {
-        Calendar cur = (Calendar)cal.clone();
-        int initialDOW = cur.get(Calendar.DAY_OF_WEEK);
+        Calendar cur = (Calendar) cal.clone();
+        int initialDOW = cur.get(DAY_OF_WEEK);
         int DOW, newDOW = initialDOW;
         do {
             DOW = newDOW;
             logln("DOW = " + DOW + "  " + cur.getTime());
 
-            cur.add(Calendar.DAY_OF_WEEK, delta);
-            newDOW = cur.get(Calendar.DAY_OF_WEEK);
+            cur.add(DAY_OF_WEEK, delta);
+            newDOW = cur.get(DAY_OF_WEEK);
             int expectedDOW = 1 + (DOW + delta - 1) % 7;
             if (newDOW != expectedDOW) {
-                errln("Day of week should be " + expectedDOW +
-                      " instead of " + newDOW + " on " + cur.getTime());
+                errln("Day of week should be " + expectedDOW
+                        + " instead of " + newDOW + " on " + cur.getTime());
                 return;
             }
-        }
-        while (newDOW != initialDOW);
+        } while (newDOW != initialDOW);
     }
 
     public void TestActualMinMax() {
-        Calendar cal = new GregorianCalendar(1967, Calendar.MARCH, 10);
-        cal.setFirstDayOfWeek(Calendar.SUNDAY);
+        Calendar cal = new GregorianCalendar(1967, MARCH, 10);
+        cal.setFirstDayOfWeek(SUNDAY);
         cal.setMinimalDaysInFirstWeek(3);
 
-        if (cal.getActualMinimum(Calendar.DAY_OF_MONTH) != 1)
-            errln("Actual minimum date for 3/10/1967 should have been 1; got " +
-                  cal.getActualMinimum(Calendar.DAY_OF_MONTH));
-        if (cal.getActualMaximum(Calendar.DAY_OF_MONTH) != 31)
-            errln("Actual maximum date for 3/10/1967 should have been 31; got " +
-                  cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+        if (cal.getActualMinimum(DAY_OF_MONTH) != 1) {
+            errln("Actual minimum date for 3/10/1967 should have been 1; got "
+                    + cal.getActualMinimum(DAY_OF_MONTH));
+        }
+        if (cal.getActualMaximum(DAY_OF_MONTH) != 31) {
+            errln("Actual maximum date for 3/10/1967 should have been 31; got "
+                    + cal.getActualMaximum(DAY_OF_MONTH));
+        }
 
-        cal.set(Calendar.MONTH, Calendar.FEBRUARY);
-        if (cal.getActualMaximum(Calendar.DAY_OF_MONTH) != 28)
-            errln("Actual maximum date for 2/10/1967 should have been 28; got " +
-                  cal.getActualMaximum(Calendar.DAY_OF_MONTH));
-        if (cal.getActualMaximum(Calendar.DAY_OF_YEAR) != 365)
-            errln("Number of days in 1967 should have been 365; got " +
-                  cal.getActualMaximum(Calendar.DAY_OF_YEAR));
+        cal.set(MONTH, FEBRUARY);
+        if (cal.getActualMaximum(DAY_OF_MONTH) != 28) {
+            errln("Actual maximum date for 2/10/1967 should have been 28; got "
+                    + cal.getActualMaximum(DAY_OF_MONTH));
+        }
+        if (cal.getActualMaximum(DAY_OF_YEAR) != 365) {
+            errln("Number of days in 1967 should have been 365; got "
+                    + cal.getActualMaximum(DAY_OF_YEAR));
+        }
 
-        cal.set(Calendar.YEAR, 1968);
-        if (cal.getActualMaximum(Calendar.DAY_OF_MONTH) != 29)
-            errln("Actual maximum date for 2/10/1968 should have been 29; got " +
-                  cal.getActualMaximum(Calendar.DAY_OF_MONTH));
-        if (cal.getActualMaximum(Calendar.DAY_OF_YEAR) != 366)
-            errln("Number of days in 1968 should have been 366; got " +
-                  cal.getActualMaximum(Calendar.DAY_OF_YEAR));
+        cal.set(YEAR, 1968);
+        if (cal.getActualMaximum(DAY_OF_MONTH) != 29) {
+            errln("Actual maximum date for 2/10/1968 should have been 29; got "
+                    + cal.getActualMaximum(DAY_OF_MONTH));
+        }
+        if (cal.getActualMaximum(DAY_OF_YEAR) != 366) {
+            errln("Number of days in 1968 should have been 366; got "
+                    + cal.getActualMaximum(DAY_OF_YEAR));
+        }
         // Using week settings of SUNDAY/3 (see above)
-        if (cal.getActualMaximum(Calendar.WEEK_OF_YEAR) != 52)
-            errln("Number of weeks in 1968 should have been 52; got " +
-                  cal.getActualMaximum(Calendar.WEEK_OF_YEAR));
+        if (cal.getActualMaximum(WEEK_OF_YEAR) != 52) {
+            errln("Number of weeks in 1968 should have been 52; got "
+                    + cal.getActualMaximum(WEEK_OF_YEAR));
+        }
 
-        cal.set(Calendar.YEAR, 1976);
+        cal.set(YEAR, 1976);
         // Using week settings of SUNDAY/3 (see above)
-        if (cal.getActualMaximum(Calendar.WEEK_OF_YEAR) != 53)
-            errln("Number of weeks in 1976 should have been 53; got " +
-                  cal.getActualMaximum(Calendar.WEEK_OF_YEAR));
+        if (cal.getActualMaximum(WEEK_OF_YEAR) != 53) {
+            errln("Number of weeks in 1976 should have been 53; got "
+                    + cal.getActualMaximum(WEEK_OF_YEAR));
+        }
     }
 
     public void TestRoll() {
-        Calendar cal = new GregorianCalendar(1997, Calendar.JANUARY, 31);
+        Calendar cal = new GregorianCalendar(1997, JANUARY, 31);
 
-        int[] dayValues = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 };
+        int[] dayValues = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31};
 
         for (int i = 0; i < dayValues.length; i++) {
-            Calendar cal2 = (Calendar)cal.clone();
-            cal2.roll(Calendar.MONTH, i);
-            if (cal2.get(Calendar.DAY_OF_MONTH) != dayValues[i])
+            Calendar cal2 = (Calendar) cal.clone();
+            cal2.roll(MONTH, i);
+            if (cal2.get(DAY_OF_MONTH) != dayValues[i]) {
                 errln("Rolling the month in 1/31/1997 up by " + i + " should have yielded "
-                      + ((i + 1) % 12) + "/" + dayValues[i] + "/1997, but actually yielded "
-                      + ((i + 1) % 12) + "/" + cal2.get(Calendar.DAY_OF_MONTH) + "/1997.");
+                        + ((i + 1) % 12) + "/" + dayValues[i] + "/1997, but actually yielded "
+                        + ((i + 1) % 12) + "/" + cal2.get(DAY_OF_MONTH) + "/1997.");
+            }
         }
 
-        cal.set(1996, Calendar.FEBRUARY, 29);
+        cal.set(1996, FEBRUARY, 29);
 
-        int[] monthValues = { 1, 2, 2, 2, 1, 2, 2, 2, 1, 2 };
-        int[] dayValues2 = { 29, 1, 1, 1, 29, 1, 1, 1, 29, 1 };
+        int[] monthValues = {1, 2, 2, 2, 1, 2, 2, 2, 1, 2};
+        int[] dayValues2 = {29, 1, 1, 1, 29, 1, 1, 1, 29, 1};
 
         for (int i = 0; i < dayValues2.length; i++) {
-            Calendar cal2 = (Calendar)cal.clone();
-            cal2.roll(Calendar.YEAR, i);
-            if (cal2.get(Calendar.DAY_OF_MONTH) != dayValues2[i] || cal2.get(Calendar.MONTH)
-                != monthValues[i])
+            Calendar cal2 = (Calendar) cal.clone();
+            cal2.roll(YEAR, i);
+            if (cal2.get(DAY_OF_MONTH) != dayValues2[i] || cal2.get(MONTH)
+                    != monthValues[i]) {
                 errln("Rolling the year in 2/29/1996 up by " + i + " should have yielded "
-                      + (monthValues[i] + 1) + "/" + dayValues2[i] + "/"
-                      + (1996 + i) + ", but actually yielded "
-                      + (cal2.get(Calendar.MONTH) + 1) + "/" +
-                      cal2.get(Calendar.DAY_OF_MONTH) + "/" + (1996 + i) + ".");
+                        + (monthValues[i] + 1) + "/" + dayValues2[i] + "/"
+                        + (1996 + i) + ", but actually yielded "
+                        + (cal2.get(MONTH) + 1) + "/"
+                        + cal2.get(DAY_OF_MONTH) + "/" + (1996 + i) + ".");
+            }
         }
 
         // Test rolling hour of day
-        cal.set(Calendar.HOUR_OF_DAY, 0);
-        cal.roll(Calendar.HOUR_OF_DAY, -2);
-        int f = cal.get(Calendar.HOUR_OF_DAY);
-        if (f != 22) errln("Rolling HOUR_OF_DAY=0 delta=-2 gave " + f + " Wanted 22");
-        cal.roll(Calendar.HOUR_OF_DAY, 5);
-        f = cal.get(Calendar.HOUR_OF_DAY);
-        if (f != 3) errln("Rolling HOUR_OF_DAY=22 delta=5 gave " + f + " Wanted 3");
-        cal.roll(Calendar.HOUR_OF_DAY, 21);
-        f = cal.get(Calendar.HOUR_OF_DAY);
-        if (f != 0) errln("Rolling HOUR_OF_DAY=3 delta=21 gave " + f + " Wanted 0");
+        cal.set(HOUR_OF_DAY, 0);
+        cal.roll(HOUR_OF_DAY, -2);
+        int f = cal.get(HOUR_OF_DAY);
+        if (f != 22) {
+            errln("Rolling HOUR_OF_DAY=0 delta=-2 gave " + f + " Wanted 22");
+        }
+        cal.roll(HOUR_OF_DAY, 5);
+        f = cal.get(HOUR_OF_DAY);
+        if (f != 3) {
+            errln("Rolling HOUR_OF_DAY=22 delta=5 gave " + f + " Wanted 3");
+        }
+        cal.roll(HOUR_OF_DAY, 21);
+        f = cal.get(HOUR_OF_DAY);
+        if (f != 0) {
+            errln("Rolling HOUR_OF_DAY=3 delta=21 gave " + f + " Wanted 0");
+        }
 
         // Test rolling hour
-        cal.set(Calendar.HOUR_OF_DAY, 0);
-        cal.roll(Calendar.HOUR, -2);
-        f = cal.get(Calendar.HOUR);
-        if (f != 10) errln("Rolling HOUR=0 delta=-2 gave " + f + " Wanted 10");
-        cal.roll(Calendar.HOUR, 5);
-        f = cal.get(Calendar.HOUR);
-        if (f != 3) errln("Rolling HOUR=10 delta=5 gave " + f + " Wanted 3");
-        cal.roll(Calendar.HOUR, 9);
-        f = cal.get(Calendar.HOUR);
-        if (f != 0) errln("Rolling HOUR=3 delta=9 gave " + f + " Wanted 0");
+        cal.set(HOUR_OF_DAY, 0);
+        cal.roll(HOUR, -2);
+        f = cal.get(HOUR);
+        if (f != 10) {
+            errln("Rolling HOUR=0 delta=-2 gave " + f + " Wanted 10");
+        }
+        cal.roll(HOUR, 5);
+        f = cal.get(HOUR);
+        if (f != 3) {
+            errln("Rolling HOUR=10 delta=5 gave " + f + " Wanted 3");
+        }
+        cal.roll(HOUR, 9);
+        f = cal.get(HOUR);
+        if (f != 0) {
+            errln("Rolling HOUR=3 delta=9 gave " + f + " Wanted 0");
+        }
     }
 
     /*
@@ -1081,19 +1160,18 @@
             TimeZone.setDefault(TimeZone.getTimeZone("PST"));
 
             Calendar cal = Calendar.getInstance();
-            cal.set(Calendar.YEAR, 2001);
-            cal.set(Calendar.MONTH, Calendar.OCTOBER);
-            cal.set(Calendar.WEEK_OF_YEAR, 4);
-            cal.set(Calendar.DAY_OF_WEEK, 2);
+            cal.set(YEAR, 2001);
+            cal.set(MONTH, OCTOBER);
+            cal.set(WEEK_OF_YEAR, 4);
+            cal.set(DAY_OF_WEEK, 2);
 
-            if (cal.get(Calendar.YEAR) != 2001 ||
-                cal.get(Calendar.MONTH) != Calendar.JANUARY ||
-                cal.get(Calendar.DATE) != 22 ||
-                cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
+            if (cal.get(YEAR) != 2001
+                    || cal.get(MONTH) != JANUARY
+                    || cal.get(DATE) != 22
+                    || cal.get(DAY_OF_WEEK) != MONDAY) {
                 errln("Failed : got " + cal.getTime() + ", expected Mon Jan 22, 2001");
             }
-        }
-        finally {
+        } finally {
             Locale.setDefault(savedLocale);
             TimeZone.setDefault(savedTimeZone);
         }
--- a/jdk/test/java/util/Calendar/CalendarTypeTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/CalendarTypeTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,9 +27,13 @@
  * @summary Unit test for calendar types
  */
 
-import java.util.*;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.Set;
 
 public class CalendarTypeTest {
+
     // Calendar types supported in JRE
     static Locale[] locales = new Locale[] {
         Locale.US,
@@ -37,23 +41,20 @@
         new Locale("th", "TH"),
         Locale.forLanguageTag("en-US-u-ca-buddhist"),
         new Locale("ja", "JP", "JP"),
-        Locale.forLanguageTag("en-US-u-ca-japanese"),
-    };
+        Locale.forLanguageTag("en-US-u-ca-japanese")};
     static final String[] TYPES = new String[] {
         "gregory",
         "buddhist",
-        "japanese",
-    };
+        "japanese"};
     static final String[] ALIASES = new String[] {
         "gregorian",
-        "iso8601",
-    };
+        "iso8601"};
 
     public static void main(String[] args) {
         for (int i = 0; i < locales.length; i++) {
             Calendar cal = Calendar.getInstance(locales[i]);
             String type = cal.getCalendarType();
-            checkValue("bad calendar type", type, TYPES[i/2]);
+            checkValue("bad calendar type", type, TYPES[i / 2]);
         }
 
         GregorianCalendar gcal = new GregorianCalendar();
@@ -88,10 +89,13 @@
         }
     }
 
+    @SuppressWarnings("serial")
     private static class Gregorian extends GregorianCalendar {
     }
 
+    @SuppressWarnings("serial")
     private static class Koyomi extends Calendar {
+
         @Override
         protected void computeTime() {
             throw new UnsupportedOperationException("Not supported yet.");
--- a/jdk/test/java/util/Calendar/FieldStateTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/FieldStateTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -144,8 +144,11 @@
         }
 
         logln("Set day of week to SUNDAY and date to 2003/10/31. "
-              + "Then, getTime and set week of year to 43.");
-        cal.setTime(new Date(2003-1990, OCTOBER, 31));
+                + "Then, getTime and set week of year to 43.");
+
+        @SuppressWarnings("deprecation")
+        Date d = new Date(2003 - 1990, OCTOBER, 31);
+        cal.setTime(d);
         cal.set(DAY_OF_WEEK, SUNDAY);
         cal.set(2003, OCTOBER, 31); // 2003/10/31 is Friday.
         cal.set(ZONE_OFFSET, 0);
@@ -166,8 +169,8 @@
      * 4916815: REGRESSION: Problem with java.util.Calendar VM 1.4.2-b28
      */
     public void Test4916815() {
-        logln("Set date to 2003/9/26 (Fri). Roll to Aug and back to Sep. "+
-              "Set dayofweek to Sunday which should be 2003/9/21.");
+        logln("Set date to 2003/9/26 (Fri). Roll to Aug and back to Sep. "
+                + "Set dayofweek to Sunday which should be 2003/9/21.");
         Koyomi cal = new Koyomi();
         cal.clear();
         // 2003/9/26 (Fri)
@@ -192,17 +195,17 @@
         cal.clear();
         cal.set(YEAR, 2004);
         cal.set(WEEK_OF_YEAR, 1);
-        checkDate(cal, SUNDAY,    2003, DECEMBER, 28);
-        checkDate(cal, MONDAY,    2003, DECEMBER, 29);
-        checkDate(cal, TUESDAY,   2003, DECEMBER, 30);
+        checkDate(cal, SUNDAY, 2003, DECEMBER, 28);
+        checkDate(cal, MONDAY, 2003, DECEMBER, 29);
+        checkDate(cal, TUESDAY, 2003, DECEMBER, 30);
         checkDate(cal, WEDNESDAY, 2003, DECEMBER, 31);
-        checkDate(cal, THURSDAY,  2004, JANUARY,   1);
-        checkDate(cal, FRIDAY,    2004, JANUARY,   2);
-        checkDate(cal, SATURDAY,  2004, JANUARY,   3);
+        checkDate(cal, THURSDAY, 2004, JANUARY, 1);
+        checkDate(cal, FRIDAY, 2004, JANUARY, 2);
+        checkDate(cal, SATURDAY, 2004, JANUARY, 3);
     }
 
     private void checkDate(Koyomi cal, int dayOfWeek,
-                           int expectedYear, int expectedMonth, int expectedDayOfMonth) {
+            int expectedYear, int expectedMonth, int expectedDayOfMonth) {
         cal.set(DAY_OF_WEEK, dayOfWeek);
         cal.getTime();
         if (!cal.checkInternalDate(expectedYear, expectedMonth, expectedDayOfMonth, dayOfWeek)) {
--- a/jdk/test/java/util/Calendar/GregorianCutoverTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/GregorianCutoverTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -76,7 +76,9 @@
         checkContinuity(cal, WEEK_OF_YEAR);
 
         // Use large date (year >= 50000)
-        cal.setGregorianChange(new Date(50000-1900, JANUARY, 20));
+        @SuppressWarnings("deprecation")
+        Date d = new Date(50000 - 1900, JANUARY, 20);
+        cal.setGregorianChange(d);
         cal.set(49998, JANUARY, 1);
         checkContinuity(cal, DAY_OF_YEAR);
         checkContinuity(cal, WEEK_OF_YEAR);
@@ -124,7 +126,9 @@
 
         // should handle the gap between 1969/12/22 (Julian) to 1970/1/5 (Gregorian)
         logln("Cutover date is 1970/1/5");
-        cal.setGregorianChange(new Date(1970-1900, JANUARY, 5));
+        @SuppressWarnings("deprecation")
+        Date d1 = new Date(1970 - 1900, JANUARY, 5);
+        cal.setGregorianChange(d1);
         cal.set(ERA, AD);
         cal.set(YEAR, 1970);
         logln("  Set DAY_OF_YEAR to the 28th day of 1970");
@@ -203,16 +207,17 @@
     public void Test4928615() {
         Koyomi cal = new Koyomi();
         logln("Today is 2003/10/1 Gregorian.");
-        Date x = new Date(2003-1900, 10-1, 1);
+        @SuppressWarnings("deprecation")
+        Date x = new Date(2003 - 1900, 10 - 1, 1);
         cal.setTime(x);
 
         logln("  Changing the cutover date to yesterday...");
-        cal.setGregorianChange(new Date(x.getTime() - (24*3600*1000)));
+        cal.setGregorianChange(new Date(x.getTime() - (24 * 3600 * 1000)));
         if (!cal.checkDate(2003, OCTOBER, 1)) {
             errln("    " + cal.getMessage());
         }
         logln("  Changing the cutover date to tomorrow...");
-        cal.setGregorianChange(new Date(x.getTime() + (24*3600*1000)));
+        cal.setGregorianChange(new Date(x.getTime() + (24 * 3600 * 1000)));
         if (!cal.checkDate(2003, SEPTEMBER, 18)) {
             errln("    " + cal.getMessage());
         }
@@ -225,11 +230,11 @@
         Koyomi cal = new Koyomi();
         Koyomi cal2 = (Koyomi) cal.clone();
         logln("getLeastMaximum should handle cutover year.\n"
-              +"  default cutover date");
-        if (!cal.checkLeastMaximum(DAY_OF_YEAR, 365-10)) {
+                + "  default cutover date");
+        if (!cal.checkLeastMaximum(DAY_OF_YEAR, 365 - 10)) {
             errln("    " + cal.getMessage());
         }
-        if (!cal.checkLeastMaximum(WEEK_OF_YEAR, 52-((10+6)/7))) {
+        if (!cal.checkLeastMaximum(WEEK_OF_YEAR, 52 - ((10 + 6) / 7))) {
             errln("    " + cal.getMessage());
         }
         // Corrected for 4956232
@@ -261,7 +266,9 @@
 
         cal = new Koyomi();
         logln("Change the cutover date to 1970/1/5.");
-        cal.setGregorianChange(new Date(1970-1900, 0, 5));
+        @SuppressWarnings("deprecation")
+        Date d = new Date(1970 - 1900, 0, 5);
+        cal.setGregorianChange(d);
         if (!cal.checkLeastMaximum(DAY_OF_YEAR, 356)) {
             errln("    " + cal.getMessage());
         }
@@ -287,15 +294,15 @@
         int hour = 13865672;
         Koyomi gc1 = new Koyomi();
         gc1.clear();
-        gc1.set(1, gc1.JANUARY, 1, 0, 0, 0);
-        gc1.set(gc1.HOUR_OF_DAY, hour);
-        if (!gc1.checkDate(1582, gc1.OCTOBER, 4)) {
+        gc1.set(1, JANUARY, 1, 0, 0, 0);
+        gc1.set(HOUR_OF_DAY, hour);
+        if (!gc1.checkDate(1582, OCTOBER, 4)) {
             errln("test case 1: " + gc1.getMessage());
         }
         gc1.clear();
-        gc1.set(1, gc1.JANUARY, 1, 0, 0, 0);
-        gc1.set(gc1.HOUR_OF_DAY, hour + 24);
-        if (!gc1.checkDate(1582, gc1.OCTOBER, 15)) {
+        gc1.set(1, JANUARY, 1, 0, 0, 0);
+        gc1.set(HOUR_OF_DAY, hour + 24);
+        if (!gc1.checkDate(1582, OCTOBER, 15)) {
             errln("test case 2: " + gc1.getMessage());
         }
     }
--- a/jdk/test/java/util/Calendar/JavatimeTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/JavatimeTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,16 +28,16 @@
  * @key randomness
  */
 
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZonedDateTime;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.Random;
 import java.util.TimeZone;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZonedDateTime;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
 
 public class JavatimeTest {
 
@@ -46,10 +46,11 @@
     public static void main(String[] args) throws Throwable {
 
         int N = 10000;
+        @SuppressWarnings("deprecation")
         long t1970 = new java.util.Date(70, 0, 01).getTime();
         Random r = new Random();
         for (int i = 0; i < N; i++) {
-            int days  = r.nextInt(50) * 365 + r.nextInt(365);
+            int days = r.nextInt(50) * 365 + r.nextInt(365);
             long secs = t1970 + days * 86400 + r.nextInt(86400);
             int nanos = r.nextInt(NANOS_PER_SECOND);
             int nanos_ms = nanos / 1000000 * 1000000; // millis precision
@@ -61,15 +62,15 @@
             ///////////// java.util.Date /////////////////////////
             Date jud = new java.util.Date(millis);
             Instant inst0 = jud.toInstant();
-            if (jud.getTime() != inst0.toEpochMilli() ||
-                !jud.equals(Date.from(inst0))) {
+            if (jud.getTime() != inst0.toEpochMilli()
+                    || !jud.equals(Date.from(inst0))) {
                 System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                 throw new RuntimeException("FAILED: j.u.d -> instant -> j.u.d");
             }
             // roundtrip only with millis precision
             Date jud0 = Date.from(inst_ms);
-            if (jud0.getTime() != inst_ms.toEpochMilli() ||
-                !inst_ms.equals(jud0.toInstant())) {
+            if (jud0.getTime() != inst_ms.toEpochMilli()
+                    || !inst_ms.equals(jud0.toInstant())) {
                 System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                 throw new RuntimeException("FAILED: instant -> j.u.d -> instant");
             }
@@ -82,8 +83,8 @@
             cal.setMinimalDaysInFirstWeek(4);
             cal.setTimeInMillis(millis);
             ZonedDateTime zdt0 = cal.toZonedDateTime();
-            if (cal.getTimeInMillis() != zdt0.toInstant().toEpochMilli() ||
-                !cal.equals(GregorianCalendar.from(zdt0))) {
+            if (cal.getTimeInMillis() != zdt0.toInstant().toEpochMilli()
+                    || !cal.equals(GregorianCalendar.from(zdt0))) {
                 System.out.println("cal:" + cal);
                 System.out.println("zdt:" + zdt0);
                 System.out.println("calNew:" + GregorianCalendar.from(zdt0));
@@ -97,8 +98,8 @@
             }
             ZonedDateTime zdt = ZonedDateTime.of(ldt_ms, ZoneId.systemDefault());
             GregorianCalendar cal0 = GregorianCalendar.from(zdt);
-            if (zdt.toInstant().toEpochMilli() != cal0.getTimeInMillis() ||
-                !zdt.equals(GregorianCalendar.from(zdt).toZonedDateTime())) {
+            if (zdt.toInstant().toEpochMilli() != cal0.getTimeInMillis()
+                    || !zdt.equals(GregorianCalendar.from(zdt).toZonedDateTime())) {
                 System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
                 throw new RuntimeException("FAILED: zdt -> gcal -> zdt");
             }
@@ -107,12 +108,12 @@
         ///////////// java.util.TimeZone /////////////////////////
         for (String zidStr : TimeZone.getAvailableIDs()) {
             // TBD: tzdt intergration
-            if (zidStr.startsWith("SystemV") ||
-                zidStr.contains("Riyadh8") ||
-                zidStr.equals("US/Pacific-New") ||
-                zidStr.equals("EST") ||
-                zidStr.equals("HST") ||
-                zidStr.equals("MST")) {
+            if (zidStr.startsWith("SystemV")
+                    || zidStr.contains("Riyadh8")
+                    || zidStr.equals("US/Pacific-New")
+                    || zidStr.equals("EST")
+                    || zidStr.equals("HST")
+                    || zidStr.equals("MST")) {
                 continue;
             }
             ZoneId zid = ZoneId.of(zidStr, ZoneId.SHORT_IDS);
@@ -121,9 +122,9 @@
             }
             TimeZone tz = TimeZone.getTimeZone(zidStr);
             // no round-trip for alias and "GMT"
-            if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId())) &&
-                !ZoneId.SHORT_IDS.containsKey(zidStr) &&
-                !zidStr.startsWith("GMT")) {
+            if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId()))
+                    && !ZoneId.SHORT_IDS.containsKey(zidStr)
+                    && !zidStr.startsWith("GMT")) {
                 throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr);
             }
         }
--- a/jdk/test/java/util/Calendar/Koyomi.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/Koyomi.java	Wed Jul 05 22:30:23 2017 +0200
@@ -21,8 +21,6 @@
  * questions.
  */
 
-import static java.util.Calendar.*;
-
 import java.util.GregorianCalendar;
 import java.util.Locale;
 import java.util.TimeZone;
@@ -30,7 +28,9 @@
 /**
  * GregorianCalendar subclass for testing.
  */
+@SuppressWarnings("serial")
 public class Koyomi extends GregorianCalendar {
+
     static final String[] FIELD_NAMES = {
         "ERA", "YEAR", "MONTH", "WEEK_OF_YEAR", "WEEK_OF_MONTH", "DAY_OF_MONTH",
         "DAY_OF_YEAR", "DAY_OF_WEEK", "DAY_OF_WEEK_IN_MONTH", "AM_PM", "HOUR",
@@ -78,7 +78,7 @@
         StringBuilder sb = new StringBuilder();
         sb.append(internalGet(ERA) == 0 ? "BCE " : "");
         sb.append(internalGet(YEAR)).append('-');
-        sb.append(internalGet(MONTH)+1).append('-');
+        sb.append(internalGet(MONTH) + 1).append('-');
         sb.append(internalGet(DAY_OF_MONTH));
         return sb.toString();
     }
@@ -98,7 +98,7 @@
         sb.append(ms);
         int offset = internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET);
         offset /= 60000;
-        offset = (offset/60) * 100 + (offset%60);
+        offset = (offset / 60) * 100 + (offset % 60);
         if (offset >= 0) {
             sb.append('+');
         } else {
@@ -187,8 +187,8 @@
     boolean checkActualMaximum(int field, int expectedValue) {
         int val;
         if ((val = getActualMaximum(field)) != expectedValue) {
-            appendMessage("getActualMaximum("+FIELD_NAMES[field]+"): got " + val
-                          + " expected " + expectedValue);
+            appendMessage("getActualMaximum(" + FIELD_NAMES[field] + "): got " + val
+                    + " expected " + expectedValue);
         }
         return getStatus();
     }
@@ -196,8 +196,8 @@
     boolean checkLeastMaximum(int field, int expectedValue) {
         int val;
         if ((val = getLeastMaximum(field)) != expectedValue) {
-            appendMessage("getLeastMaximum("+FIELD_NAMES[field]+"): got " + val
-                          + " expected " + expectedValue);
+            appendMessage("getLeastMaximum(" + FIELD_NAMES[field] + "): got " + val
+                    + " expected " + expectedValue);
         }
         return getStatus();
     }
@@ -205,8 +205,8 @@
     boolean checkActualMinimum(int field, int expectedValue) {
         int val;
         if ((val = getActualMinimum(field)) != expectedValue) {
-            appendMessage("getActualMinimum("+FIELD_NAMES[field]+"): got " + val
-                          + " expected " + expectedValue);
+            appendMessage("getActualMinimum(" + FIELD_NAMES[field] + "): got " + val
+                    + " expected " + expectedValue);
         }
         return getStatus();
     }
@@ -214,8 +214,8 @@
     boolean checkGreatestMinimum(int field, int expectedValue) {
         int val;
         if ((val = getGreatestMinimum(field)) != expectedValue) {
-            appendMessage("getGreatestMinimum("+FIELD_NAMES[field]+"): got " + val
-                          + " expected " + expectedValue);
+            appendMessage("getGreatestMinimum(" + FIELD_NAMES[field] + "): got " + val
+                    + " expected " + expectedValue);
         }
         return getStatus();
     }
@@ -238,7 +238,7 @@
     }
 
     boolean checkDateTime(int year, int month, int dayOfMonth,
-                          int hourOfDay, int minute, int second, int ms) {
+            int hourOfDay, int minute, int second, int ms) {
         initTest();
         checkFieldValue(YEAR, year);
         checkFieldValue(MONTH, month);
@@ -270,8 +270,8 @@
     boolean checkFieldValue(int field, int expectedValue) {
         int val;
         if ((val = get(field)) != expectedValue) {
-            appendMessage("get(" + FIELD_NAMES[field] + "): got " + val +
-                          ", expected " + expectedValue + "; ");
+            appendMessage("get(" + FIELD_NAMES[field] + "): got " + val
+                    + ", expected " + expectedValue + "; ");
             return false;
         }
         return true;
@@ -280,8 +280,8 @@
     boolean checkInternalFieldValue(int field, int expectedValue) {
         int val;
         if ((val = internalGet(field)) != expectedValue) {
-            appendMessage("internalGet(" + FIELD_NAMES[field] + "): got " + val +
-                          ", expected " + expectedValue + "; ");
+            appendMessage("internalGet(" + FIELD_NAMES[field] + "): got " + val
+                    + ", expected " + expectedValue + "; ");
             return false;
         }
         return true;
--- a/jdk/test/java/util/Calendar/NonLenientTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/NonLenientTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -28,7 +28,10 @@
  * @library /java/text/testlib
  */
 
-import java.util.*;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
 
 import static java.util.Calendar.*;
 
@@ -129,7 +132,6 @@
         validate(cal, "6th Sunday in Jan 2003");
     }
 
-
     /**
      * 4726030: GregorianCalendar doesn't check invalid dates in non-lenient
      */
@@ -146,34 +148,34 @@
      */
     public void Test4147269() {
         Koyomi calendar = getNonLenient();
-        Date date = (new GregorianCalendar(1996,0,3)).getTime();
+        Date date = (new GregorianCalendar(1996, 0, 3)).getTime();
 
-        for (int field = 0; field < Calendar.FIELD_COUNT; field++) {
+        for (int field = 0; field < FIELD_COUNT; field++) {
             calendar.setTime(date);
             int max = calendar.getActualMaximum(field);
-            int value = max+1;
+            int value = max + 1;
             calendar.set(field, value);
             try {
                 calendar.computeTime(); // call method under test
-                errln("Test failed with field " + calendar.getFieldName(field)
-                      + "\n\tdate before:  " + date
-                      + "\n\tdate after:   " + calendar.getTime()
-                      + "\n\tvalue: " + value + "  (max = " + max +")");
+                errln("Test failed with field " + Koyomi.getFieldName(field)
+                        + "\n\tdate before:  " + date
+                        + "\n\tdate after:   " + calendar.getTime()
+                        + "\n\tvalue: " + value + "  (max = " + max + ")");
             } catch (IllegalArgumentException e) {
             }
         }
 
-        for (int field = 0; field < Calendar.FIELD_COUNT; field++) {
+        for (int field = 0; field < FIELD_COUNT; field++) {
             calendar.setTime(date);
             int min = calendar.getActualMinimum(field);
-            int value = min-1;
+            int value = min - 1;
             calendar.set(field, value);
             try {
                 calendar.computeTime(); // call method under test
-                errln("Test failed with field " + calendar.getFieldName(field)
-                      + "\n\tdate before:  " + date
-                      + "\n\tdate after:   " + calendar.getTime()
-                      + "\n\tvalue: " + value + "  (min = " + min +")");
+                errln("Test failed with field " + Koyomi.getFieldName(field)
+                        + "\n\tdate before:  " + date
+                        + "\n\tdate after:   " + calendar.getTime()
+                        + "\n\tvalue: " + value + "  (min = " + min + ")");
             } catch (IllegalArgumentException e) {
             }
         }
@@ -194,17 +196,17 @@
         // In non-lenient, calendar field values that have beeb set by
         // user shouldn't be modified.
         int[] afterFields = cal.getFields();
-        for (int i = 0; i < Calendar.FIELD_COUNT; i++) {
+        for (int i = 0; i < FIELD_COUNT; i++) {
             if (cal.isSet(i) && originalFields[i] != afterFields[i]) {
-                errln("    complete() modified fields[" + cal.getFieldName(i) + "] got "
-                      + afterFields[i] + ", expected " + originalFields[i]);
+                errln("    complete() modified fields[" + Koyomi.getFieldName(i) + "] got "
+                        + afterFields[i] + ", expected " + originalFields[i]);
             }
         }
         // In non-lenient, set state of fields shouldn't be modified.
         int afterSetFields = cal.getSetStateFields();
         if (setFields != afterSetFields) {
             errln("    complate() modified set states: before 0x" + toHex(setFields)
-                  + ", after 0x"+ toHex(afterSetFields));
+                    + ", after 0x" + toHex(afterSetFields));
         }
     }
 
--- a/jdk/test/java/util/Calendar/ZoneOffsets.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/ZoneOffsets.java	Wed Jul 05 22:30:23 2017 +0200
@@ -28,12 +28,20 @@
  * taken into account for time calculations.
  */
 
-import java.util.*;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
+
 import static java.util.GregorianCalendar.*;
 
 public class ZoneOffsets {
+
     // This TimeZone always returns the dstOffset value.
+    @SuppressWarnings("serial")
     private static class TestTimeZone extends TimeZone {
+
         private int gmtOffset;
         private int dstOffset;
 
@@ -44,7 +52,7 @@
         }
 
         public int getOffset(int era, int year, int month, int day,
-                             int dayOfWeek, int milliseconds) {
+                int dayOfWeek, int milliseconds) {
             return gmtOffset + dstOffset;
         }
 
@@ -80,22 +88,20 @@
     private static Locale[] locales = {
         Locale.getDefault(),
         new Locale("th", "TH"),
-        new Locale("ja", "JP", "JP"),
-    };
+        new Locale("ja", "JP", "JP")};
 
     private static final int HOUR = 60 * 60 * 1000;
 
     private static int[][] offsets = {
-        { 0, 0 },
-        { 0, HOUR },
-        { 0, 2 * HOUR },
-        { -8 * HOUR, 0 },
-        { -8 * HOUR, HOUR },
-        { -8 * HOUR, 2 * HOUR },
-        { 9 * HOUR, 0 },
-        { 9 * HOUR, HOUR },
-        { 9 * HOUR, 2 * HOUR },
-    };
+        {0, 0},
+        {0, HOUR},
+        {0, 2 * HOUR},
+        {-8 * HOUR, 0},
+        {-8 * HOUR, HOUR},
+        {-8 * HOUR, 2 * HOUR},
+        {9 * HOUR, 0},
+        {9 * HOUR, HOUR},
+        {9 * HOUR, 2 * HOUR}};
 
     public static void main(String[] args) {
         for (int l = 0; l < locales.length; l++) {
@@ -121,17 +127,17 @@
 
     private static void test(Locale loc, int gmtOffset, int dstOffset) {
         TimeZone tz1 = new TestTimeZone(gmtOffset,
-                                        "GMT" + (gmtOffset/HOUR) + "." + (dstOffset/HOUR),
-                                        dstOffset);
+                "GMT" + (gmtOffset / HOUR) + "." + (dstOffset / HOUR),
+                dstOffset);
         int someDifferentOffset = gmtOffset + 2 * HOUR;
         TimeZone tz2 = new TestTimeZone(someDifferentOffset,
-                                        "GMT"+ (someDifferentOffset/HOUR) + "." + (dstOffset/HOUR),
-                                        dstOffset);
+                "GMT" + (someDifferentOffset / HOUR) + "." + (dstOffset / HOUR),
+                dstOffset);
 
         int someDifferentDSTOffset = dstOffset == 2 * HOUR ? HOUR : dstOffset + HOUR;
         TimeZone tz3 = new TestTimeZone(gmtOffset,
-                                        "GMT"+ (gmtOffset/HOUR) + "." + (someDifferentDSTOffset/HOUR),
-                                        someDifferentDSTOffset);
+                "GMT" + (gmtOffset / HOUR) + "." + (someDifferentDSTOffset / HOUR),
+                someDifferentDSTOffset);
 
         // cal1 is the base line.
         Calendar cal1 = Calendar.getInstance(tz1, loc);
@@ -225,7 +231,7 @@
     private static void error(String msg, Locale loc, Calendar cal2, int gmtOffset, int dstOffset, long t1) {
         System.err.println(cal2);
         throw new RuntimeException(msg + ": Locale=" + loc
-                                   + ", gmtOffset=" + gmtOffset + ", dstOffset=" + dstOffset
-                                   + ", cal1 time=" + t1 + ", cal2 time=" + cal2.getTime().getTime());
+                + ", gmtOffset=" + gmtOffset + ", dstOffset=" + dstOffset
+                + ", cal1 time=" + t1 + ", cal2 time=" + cal2.getTime().getTime());
     }
 }
--- a/jdk/test/java/util/Calendar/bug4372743.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/bug4372743.java	Wed Jul 05 22:30:23 2017 +0200
@@ -28,9 +28,8 @@
  * @library /java/text/testlib
  */
 
-import java.io.*;
-import java.util.*;
-import java.text.*;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
 
 import static java.util.GregorianCalendar.*;
 
@@ -41,51 +40,50 @@
     }
 
     private int[][] data = {
-            {AD, 2, MARCH},
-            {AD, 2, FEBRUARY},
-            {AD, 2, JANUARY},
-            {AD, 1, DECEMBER},
-            {AD, 1, NOVEMBER},
-            {AD, 1, OCTOBER},
-            {AD, 1, SEPTEMBER},
-            {AD, 1, AUGUST},
-            {AD, 1, JULY},
-            {AD, 1, JUNE},
-            {AD, 1, MAY},
-            {AD, 1, APRIL},
-            {AD, 1, MARCH},
-            {AD, 1, FEBRUARY},
-            {AD, 1, JANUARY},
-            {BC, 1, DECEMBER},
-            {BC, 1, NOVEMBER},
-            {BC, 1, OCTOBER},
-            {BC, 1, SEPTEMBER},
-            {BC, 1, AUGUST},
-            {BC, 1, JULY},
-            {BC, 1, JUNE},
-            {BC, 1, MAY},
-            {BC, 1, APRIL},
-            {BC, 1, MARCH},
-            {BC, 1, FEBRUARY},
-            {BC, 1, JANUARY},
-            {BC, 2, DECEMBER},
-            {BC, 2, NOVEMBER},
-            {BC, 2, OCTOBER},
-        };
+        {AD, 2, MARCH},
+        {AD, 2, FEBRUARY},
+        {AD, 2, JANUARY},
+        {AD, 1, DECEMBER},
+        {AD, 1, NOVEMBER},
+        {AD, 1, OCTOBER},
+        {AD, 1, SEPTEMBER},
+        {AD, 1, AUGUST},
+        {AD, 1, JULY},
+        {AD, 1, JUNE},
+        {AD, 1, MAY},
+        {AD, 1, APRIL},
+        {AD, 1, MARCH},
+        {AD, 1, FEBRUARY},
+        {AD, 1, JANUARY},
+        {BC, 1, DECEMBER},
+        {BC, 1, NOVEMBER},
+        {BC, 1, OCTOBER},
+        {BC, 1, SEPTEMBER},
+        {BC, 1, AUGUST},
+        {BC, 1, JULY},
+        {BC, 1, JUNE},
+        {BC, 1, MAY},
+        {BC, 1, APRIL},
+        {BC, 1, MARCH},
+        {BC, 1, FEBRUARY},
+        {BC, 1, JANUARY},
+        {BC, 2, DECEMBER},
+        {BC, 2, NOVEMBER},
+        {BC, 2, OCTOBER}};
     private int tablesize = data.length;
 
     private void check(GregorianCalendar gc, int index) {
         if (gc.get(ERA) != data[index][ERA]) {
-            errln("Invalid era :" + gc.get(ERA) +
-                ", expected :" + data[index][ERA]);
+            errln("Invalid era :" + gc.get(ERA)
+                    + ", expected :" + data[index][ERA]);
         }
         if (gc.get(YEAR) != data[index][YEAR]) {
-            errln("Invalid year :" + gc.get(YEAR) +
-                ", expected :" + data[index][YEAR]);
+            errln("Invalid year :" + gc.get(YEAR)
+                    + ", expected :" + data[index][YEAR]);
         }
         if (gc.get(MONTH) != data[index][MONTH]) {
-            errln("Invalid month :" + gc.get(MONTH) +
-                ", expected :" + data[index][MONTH]);
+            errln("Invalid month :" + gc.get(MONTH)
+                    + ", expected :" + data[index][MONTH]);
         }
     }
 
@@ -97,36 +95,35 @@
             TimeZone.setDefault(TimeZone.getTimeZone("PST"));
 
             /* Set March 3, A.D. 2 */
-            gc  = new GregorianCalendar(2, MARCH, 3);
+            gc = new GregorianCalendar(2, MARCH, 3);
             for (int i = 0; i < tablesize; i++) {
                 check(gc, i);
-                gc.add(gc.MONTH, -1);
+                gc.add(MONTH, -1);
             }
 
             /* Again, Set March 3, A.D. 2 */
-            gc  = new GregorianCalendar(2, MARCH, 3);
-            for (int i = 0; i < tablesize; i+=7) {
+            gc = new GregorianCalendar(2, MARCH, 3);
+            for (int i = 0; i < tablesize; i += 7) {
                 check(gc, i);
-                gc.add(gc.MONTH, -7);
+                gc.add(MONTH, -7);
             }
 
             /* Set March 10, 2 B.C. */
-            gc  = new GregorianCalendar(2, OCTOBER, 10);
-            gc.add(gc.YEAR, -3);
-            for (int i = tablesize -1; i >= 0; i--) {
+            gc = new GregorianCalendar(2, OCTOBER, 10);
+            gc.add(YEAR, -3);
+            for (int i = tablesize - 1; i >= 0; i--) {
                 check(gc, i);
-                gc.add(gc.MONTH, 1);
+                gc.add(MONTH, 1);
             }
 
             /* Again, Set March 10, 2 B.C. */
-            gc  = new GregorianCalendar(2, OCTOBER, 10);
-            gc.add(gc.YEAR, -3);
-            for (int i = tablesize -1; i >= 0; i-=8) {
+            gc = new GregorianCalendar(2, OCTOBER, 10);
+            gc.add(YEAR, -3);
+            for (int i = tablesize - 1; i >= 0; i -= 8) {
                 check(gc, i);
-                gc.add(gc.MONTH, 8);
+                gc.add(MONTH, 8);
             }
-        }
-        finally {
+        } finally {
             TimeZone.setDefault(saveZone);
         }
     }
--- a/jdk/test/java/util/Calendar/bug4401223.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/bug4401223.java	Wed Jul 05 22:30:23 2017 +0200
@@ -28,7 +28,10 @@
  * @library /java/text/testlib
  */
 
-import java.util.*;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import static java.util.GregorianCalendar.*;
 
 public class bug4401223 extends IntlTest {
 
@@ -37,11 +40,12 @@
         String s = null;
 
         try {
-            Date date = new Date(2000-1900, Calendar.FEBRUARY, 29);
+            @SuppressWarnings("deprecation")
+            Date date = new Date(2000 - 1900, FEBRUARY, 29);
             GregorianCalendar gc = new GregorianCalendar();
             gc.setTime(date);
             gc.setLenient(false);
-            gc.set(Calendar.YEAR, 2001);
+            gc.set(YEAR, 2001);
             s = "02/29/00 & set(YEAR,2001) = " + gc.getTime().toString();
         } catch (Exception ex) {
             status++;
@@ -59,16 +63,17 @@
         String s = null;
 
         try {
-            Date date = new Date(2000-1900, Calendar.DECEMBER, 31);
+            @SuppressWarnings("deprecation")
+            Date date = new Date(2000 - 1900, DECEMBER, 31);
             GregorianCalendar gc = new GregorianCalendar();
             gc.setTime(date);
             gc.setLenient(false);
-            gc.set(Calendar.YEAR, 2001);
+            gc.set(YEAR, 2001);
 
-            if (gc.get(Calendar.YEAR) != 2001 ||
-                gc.get(Calendar.MONTH) != Calendar.DECEMBER ||
-                gc.get(Calendar.DATE) != 31 ||
-                gc.get(Calendar.DAY_OF_YEAR) != 365) {
+            if (gc.get(YEAR) != 2001
+                    || gc.get(MONTH) != DECEMBER
+                    || gc.get(DATE) != 31
+                    || gc.get(DAY_OF_YEAR) != 365) {
                 status++;
                 s = "Wrong Date : 12/31/00 & set(YEAR,2001) ---> " + gc.getTime().toString();
             } else {
--- a/jdk/test/java/util/Calendar/bug4514831.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Calendar/bug4514831.java	Wed Jul 05 22:30:23 2017 +0200
@@ -27,7 +27,12 @@
  * @summary Confirm that GregorianCalendar.roll() works properly during transition from Daylight Saving Time to Standard Time.
  */
 
-import java.util.*;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import static java.util.GregorianCalendar.*;
+
 
 public class bug4514831 {
 
@@ -36,52 +41,52 @@
         TimeZone savedTimeZone = TimeZone.getDefault();
         boolean err = false;
 
-        String golden_data1 ="27-28 28-29 29-30 30-31 31-1 1-2 2-3 ";
-        String golden_data2 ="27-28 28-29 29-30 30-31 31-25 25-26 26-27 ";
-        String golden_data3 ="1-8 8-15 15-22 22-29 29-1 1-8 8-15 ";
+        String golden_data1 = "27-28 28-29 29-30 30-31 31-1 1-2 2-3 ";
+        String golden_data2 = "27-28 28-29 29-30 30-31 31-25 25-26 26-27 ";
+        String golden_data3 = "1-8 8-15 15-22 22-29 29-1 1-8 8-15 ";
 
         try {
             Locale.setDefault(Locale.US);
             TimeZone.setDefault(TimeZone.getTimeZone("US/Pacific"));
 
             String test_roll = "";
-            GregorianCalendar c_roll = new GregorianCalendar(2001, Calendar.OCTOBER, 27);
-            for (int i=0; i < 7; i++) {
-                test_roll += c_roll.get(c_roll.DAY_OF_MONTH) + "-";
-                c_roll.roll(c_roll.DAY_OF_YEAR, true);
-                test_roll += c_roll.get(c_roll.DAY_OF_MONTH) + " ";
+            GregorianCalendar c_roll = new GregorianCalendar(2001, OCTOBER, 27);
+            for (int i = 0; i < 7; i++) {
+                test_roll += c_roll.get(DAY_OF_MONTH) + "-";
+                c_roll.roll(DAY_OF_YEAR, true);
+                test_roll += c_roll.get(DAY_OF_MONTH) + " ";
             }
             if (!test_roll.equals(golden_data1)) {
                 err = true;
-                System.err.println("Wrong roll(DAY_OF_YEAR) transition: got "+
-                                   test_roll + "expected " + golden_data1);
+                System.err.println("Wrong roll(DAY_OF_YEAR) transition: got "
+                        + test_roll + "expected " + golden_data1);
             }
 
             test_roll = "";
-            c_roll = new GregorianCalendar(2001, Calendar.OCTOBER, 27);
-            c_roll.setFirstDayOfWeek(Calendar.THURSDAY);
-            for (int i=0; i < 7; i++) {
-                test_roll += c_roll.get(c_roll.DAY_OF_MONTH) + "-";
-                c_roll.roll(c_roll.DAY_OF_WEEK, true);
-                test_roll += c_roll.get(c_roll.DAY_OF_MONTH) + " ";
+            c_roll = new GregorianCalendar(2001, OCTOBER, 27);
+            c_roll.setFirstDayOfWeek(THURSDAY);
+            for (int i = 0; i < 7; i++) {
+                test_roll += c_roll.get(DAY_OF_MONTH) + "-";
+                c_roll.roll(DAY_OF_WEEK, true);
+                test_roll += c_roll.get(DAY_OF_MONTH) + " ";
             }
             if (!test_roll.equals(golden_data2)) {
                 err = true;
-                System.err.println("Wrong roll(DAY_OF_WEEK) transition: got "+
-                                   test_roll + "expected " + golden_data2);
+                System.err.println("Wrong roll(DAY_OF_WEEK) transition: got "
+                        + test_roll + "expected " + golden_data2);
             }
 
             test_roll = "";
-            c_roll = new GregorianCalendar(2001, Calendar.OCTOBER, 1);
-            for (int i=0; i < 7; i++) {
-                test_roll += c_roll.get(c_roll.DAY_OF_MONTH) + "-";
-                c_roll.roll(c_roll.DAY_OF_WEEK_IN_MONTH, true);
-                test_roll += c_roll.get(c_roll.DAY_OF_MONTH) + " ";
+            c_roll = new GregorianCalendar(2001, OCTOBER, 1);
+            for (int i = 0; i < 7; i++) {
+                test_roll += c_roll.get(DAY_OF_MONTH) + "-";
+                c_roll.roll(DAY_OF_WEEK_IN_MONTH, true);
+                test_roll += c_roll.get(DAY_OF_MONTH) + " ";
             }
             if (!test_roll.equals(golden_data3)) {
                 err = true;
-                System.err.println("Wrong roll(DAY_OF_WEEK_IN_MONTH) transition: got "+
-                                   test_roll + "expected " + golden_data3);
+                System.err.println("Wrong roll(DAY_OF_WEEK_IN_MONTH) transition: got "
+                        + test_roll + "expected " + golden_data3);
             }
         } finally {
             Locale.setDefault(savedLocale);
--- a/jdk/test/java/util/Date/Bug4955000.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Date/Bug4955000.java	Wed Jul 05 22:30:23 2017 +0200
@@ -28,11 +28,15 @@
  * same date/time. Both are new implementations in 1.5.
  */
 
-import java.util.*;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
 import static java.util.GregorianCalendar.*;
 
 @SuppressWarnings("deprecation")
 public class Bug4955000 {
+
     // Tests for Date.UTC(), derived from JCK
     // Date.miscTests.Date1025 and Date2015
     public static void main(String[] args) {
@@ -51,17 +55,17 @@
             };
             for (int i = 0; i < years1.length; i++) {
                 gc.clear();
-                gc.set(years1[i], gc.JANUARY, 1);
+                gc.set(years1[i], JANUARY, 1);
                 long t = gc.getTimeInMillis();
-                long utc = Date.UTC(years1[i] - 1900, 1-1, 1,
-                                    0, 0, 0); // Jan 1 00:00:00
+                long utc = Date.UTC(years1[i] - 1900, 1 - 1, 1,
+                        0, 0, 0); // Jan 1 00:00:00
                 if (t != utc) {
-                    throw new RuntimeException("t (" + t + ") != utc (" + utc +")");
+                    throw new RuntimeException("t (" + t + ") != utc (" + utc + ")");
                 }
             }
 
             // Date2015
-            int years[] = {
+            int[] years = {
                 gc.getGreatestMinimum(YEAR),
                 gc.getGreatestMinimum(YEAR) + 1,
                 -1,
@@ -71,47 +75,47 @@
                 gc.getLeastMaximum(YEAR)
             };
 
-            int months[] = {
+            int[] months = {
                 gc.getMinimum(MONTH),
                 gc.getMinimum(MONTH) + 1,
                 gc.getMaximum(MONTH) - 1,
                 gc.getMaximum(MONTH)
             };
 
-            int dates[] = {
+            int[] dates = {
                 gc.getMinimum(DAY_OF_MONTH),
                 gc.getMinimum(DAY_OF_MONTH) + 1,
                 gc.getMaximum(DAY_OF_MONTH) - 1,
                 gc.getMaximum(DAY_OF_MONTH)
             };
 
-            int hs[] = {
+            int[] hs = {
                 gc.getMinimum(HOUR),
                 gc.getMinimum(HOUR) + 1,
                 gc.getMaximum(HOUR) - 1,
                 gc.getMaximum(HOUR)
             };
 
-            int ms[] = {
+            int[] ms = {
                 gc.getMinimum(MINUTE),
                 gc.getMinimum(MINUTE) + 1,
                 gc.getMaximum(MINUTE) - 1,
                 gc.getMaximum(MINUTE)
             };
 
-            int ss[] = {
+            int[] ss = {
                 gc.getMinimum(SECOND),
                 gc.getMinimum(SECOND) + 1,
                 gc.getMaximum(SECOND) - 1,
                 gc.getMaximum(SECOND)
             };
 
-            for(int i = 0; i < years.length; i++) {
-                for(int j = 0; j < months.length; j++) {
-                    for(int k = 0; k < dates.length; k++) {
-                        for(int m = 0; m < hs.length; m++) {
-                            for(int n = 0; n < ms.length; n++) {
-                                for(int p = 0; p < ss.length; p++) {
+            for (int i = 0; i < years.length; i++) {
+                for (int j = 0; j < months.length; j++) {
+                    for (int k = 0; k < dates.length; k++) {
+                        for (int m = 0; m < hs.length; m++) {
+                            for (int n = 0; n < ms.length; n++) {
+                                for (int p = 0; p < ss.length; p++) {
                                     int year = years[i] - 1900;
                                     int month = months[j];
                                     int date = dates[k];
@@ -120,7 +124,7 @@
                                     int seconds = ss[p];
 
                                     long result = Date.UTC(year, month, date,
-                                                           hours, minutes, seconds);
+                                            hours, minutes, seconds);
 
                                     gc.clear();
                                     gc.set(year + 1900, month, date, hours, minutes, seconds);
@@ -129,7 +133,7 @@
 
                                     if (expected != result) {
                                         throw new RuntimeException("expected (" + expected
-                                                                   + ") != result (" + result +")");
+                                                + ") != result (" + result + ")");
                                     }
                                 }
                             }
--- a/jdk/test/java/util/Locale/Bug4175998Test.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Locale/Bug4175998Test.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary test ISO639-2 language codes
+ * @library /java/text/testlib
  * @compile -encoding ascii Bug4175998Test.java
  * @run main Bug4175998Test
  * @bug 4175998
@@ -43,14 +44,13 @@
  */
 
 import java.util.*;
-import java.io.*;
 
 /**
  *  Bug4175998Test verifies that the following bug has been fixed:
  *  Bug 4175998 - The java.util.Locale.getISO3Language() returns wrong result for a locale with
  *           language code 'ta'(Tamil).
  */
-public class Bug4175998Test extends LocaleTestFmwk {
+public class Bug4175998Test extends IntlTest {
     public static void main(String[] args) throws Exception {
         new Bug4175998Test().run(args);
         //generateTables();    //uncomment this to regenerate data tables
--- a/jdk/test/java/util/Locale/Bug4184873Test.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Locale/Bug4184873Test.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 /*
     @test
     @summary test that locale invariants are preserved across serialization
+    @library /java/text/testlib
     @run main Bug4184873Test
     @bug 4184873
 */
@@ -63,7 +64,7 @@
 /**
  *  A Locale can never contain the following language codes: he, yi or id.
  */
-public class Bug4184873Test extends LocaleTestFmwk {
+public class Bug4184873Test extends IntlTest {
     public static void main(String[] args) throws Exception {
         if (args.length == 1 && args[0].equals("prepTest")) {
             prepTest();
--- a/jdk/test/java/util/Locale/Bug8001562.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Locale/Bug8001562.java	Wed Jul 05 22:30:23 2017 +0200
@@ -30,37 +30,46 @@
  * @run main Bug8001562
  */
 
-import java.text.*;
-import java.util.*;
+import java.text.BreakIterator;
+import java.text.Collator;
+import java.text.DateFormat;
+import java.text.DateFormatSymbols;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
 
 public class Bug8001562 {
 
-    static final String[] jdk7availTags = {
-        "ar", "ar-AE", "ar-BH", "ar-DZ", "ar-EG", "ar-IQ", "ar-JO", "ar-KW",
-        "ar-LB", "ar-LY", "ar-MA", "ar-OM", "ar-QA", "ar-SA", "ar-SD", "ar-SY",
-        "ar-TN", "ar-YE", "be", "be-BY", "bg", "bg-BG", "ca", "ca-ES", "cs",
-        "cs-CZ", "da", "da-DK", "de", "de-AT", "de-CH", "de-DE", "de-LU", "el",
-        "el-CY", "el-GR", "en", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN",
-        "en-MT", "en-NZ", "en-PH", "en-SG", "en-US", "en-ZA", "es", "es-AR",
-        "es-BO", "es-CL", "es-CO", "es-CR", "es-DO", "es-EC", "es-ES", "es-GT",
-        "es-HN", "es-MX", "es-NI", "es-PA", "es-PE", "es-PR", "es-PY", "es-SV",
-        "es-US", "es-UY", "es-VE", "et", "et-EE", "fi", "fi-FI", "fr", "fr-BE",
-        "fr-CA", "fr-CH", "fr-FR", "fr-LU", "ga", "ga-IE", "he", "he-IL",
-        "hi-IN", "hr", "hr-HR", "hu", "hu-HU", "id", "id-ID", "is", "is-IS",
-        "it", "it-CH", "it-IT", "ja", "ja-JP",
-        "ja-JP-u-ca-japanese-x-lvariant-JP", "ko", "ko-KR", "lt", "lt-LT", "lv",
-        "lv-LV", "mk", "mk-MK", "ms", "ms-MY", "mt", "mt-MT", "nl", "nl-BE",
-        "nl-NL", "no", "no-NO", "no-NO-x-lvariant-NY", "pl", "pl-PL", "pt",
-        "pt-BR", "pt-PT", "ro", "ro-RO", "ru", "ru-RU", "sk", "sk-SK", "sl",
-        "sl-SI", "sq", "sq-AL", "sr", "sr-BA", "sr-CS", "sr-Latn", "sr-Latn-BA",
-        "sr-Latn-ME", "sr-Latn-RS", "sr-ME", "sr-RS", "sv", "sv-SE", "th",
-        "th-TH", "th-TH-u-nu-thai-x-lvariant-TH", "tr", "tr-TR", "uk", "uk-UA",
-        "vi", "vi-VN", "zh", "zh-CN", "zh-HK", "zh-SG", "zh-TW", };
-    static List<Locale> jdk7availLocs = new ArrayList<>();
+    static final List<String> jdk7availTags = List.of(
+            "ar", "ar-AE", "ar-BH", "ar-DZ", "ar-EG", "ar-IQ", "ar-JO", "ar-KW",
+            "ar-LB", "ar-LY", "ar-MA", "ar-OM", "ar-QA", "ar-SA", "ar-SD", "ar-SY",
+            "ar-TN", "ar-YE", "be", "be-BY", "bg", "bg-BG", "ca", "ca-ES", "cs",
+            "cs-CZ", "da", "da-DK", "de", "de-AT", "de-CH", "de-DE", "de-LU", "el",
+            "el-CY", "el-GR", "en", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN",
+            "en-MT", "en-NZ", "en-PH", "en-SG", "en-US", "en-ZA", "es", "es-AR",
+            "es-BO", "es-CL", "es-CO", "es-CR", "es-DO", "es-EC", "es-ES", "es-GT",
+            "es-HN", "es-MX", "es-NI", "es-PA", "es-PE", "es-PR", "es-PY", "es-SV",
+            "es-US", "es-UY", "es-VE", "et", "et-EE", "fi", "fi-FI", "fr", "fr-BE",
+            "fr-CA", "fr-CH", "fr-FR", "fr-LU", "ga", "ga-IE", "he", "he-IL",
+            "hi-IN", "hr", "hr-HR", "hu", "hu-HU", "id", "id-ID", "is", "is-IS",
+            "it", "it-CH", "it-IT", "ja", "ja-JP",
+            "ja-JP-u-ca-japanese-x-lvariant-JP", "ko", "ko-KR", "lt", "lt-LT", "lv",
+            "lv-LV", "mk", "mk-MK", "ms", "ms-MY", "mt", "mt-MT", "nl", "nl-BE",
+            "nl-NL", "no", "no-NO", "no-NO-x-lvariant-NY", "pl", "pl-PL", "pt",
+            "pt-BR", "pt-PT", "ro", "ro-RO", "ru", "ru-RU", "sk", "sk-SK", "sl",
+            "sl-SI", "sq", "sq-AL", "sr", "sr-BA", "sr-CS", "sr-Latn", "sr-Latn-BA",
+            "sr-Latn-ME", "sr-Latn-RS", "sr-ME", "sr-RS", "sv", "sv-SE", "th",
+            "th-TH", "th-TH-u-nu-thai-x-lvariant-TH", "tr", "tr-TR", "uk", "uk-UA",
+            "vi", "vi-VN", "zh", "zh-CN", "zh-HK", "zh-SG", "zh-TW");
+    static List<Locale> jdk7availLocs;
+
     static {
-        for (String locStr : jdk7availTags) {
-            jdk7availLocs.add(Locale.forLanguageTag(locStr));
-        }
+        jdk7availLocs = jdk7availTags.stream()
+                .map(Locale::forLanguageTag)
+                .collect(Collectors.toList());
     }
 
     public static void main(String[] args) {
@@ -86,13 +95,13 @@
         diffLocale(Locale.class, avail);
     }
 
-    static void diffLocale(Class c, List<Locale> locs) {
+    static void diffLocale(Class<?> c, List<Locale> locs) {
         String diff = "";
 
         System.out.printf("Only in target locales (%s.getAvailableLocales()): ", c.getSimpleName());
         for (Locale l : locs) {
             if (!jdk7availLocs.contains(l)) {
-                diff += "\""+l.toLanguageTag()+"\", ";
+                diff += "\"" + l.toLanguageTag() + "\", ";
             }
         }
         System.out.println(diff);
@@ -101,7 +110,7 @@
         System.out.printf("Only in JDK7 (%s.getAvailableLocales()): ", c.getSimpleName());
         for (Locale l : jdk7availLocs) {
             if (!locs.contains(l)) {
-                diff += "\""+l.toLanguageTag()+"\", ";
+                diff += "\"" + l.toLanguageTag() + "\", ";
             }
         }
         System.out.println(diff);
--- a/jdk/test/java/util/Locale/HashCodeTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Locale/HashCodeTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -27,14 +27,17 @@
  * @modules jdk.localedata
  */
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
 
 public class HashCodeTest {
+
     public static void main(String[] args) {
         Locale[] locales = Locale.getAvailableLocales();
         int min = Integer.MAX_VALUE;
         int max = Integer.MIN_VALUE;
-        Map map = new HashMap(locales.length);
+        Map<Integer, Locale> map = new HashMap<>(locales.length);
         int conflicts = 0;
 
         for (int i = 0; i < locales.length; i++) {
@@ -42,19 +45,19 @@
             int hc = loc.hashCode();
             min = Math.min(hc, min);
             max = Math.max(hc, max);
-            Integer key = new Integer(hc);
+            Integer key = hc;
             if (map.containsKey(key)) {
                 conflicts++;
-                System.out.println("conflict: " + (Locale) map.get(key) + ", " + loc);
+                System.out.println("conflict: " + map.get(key) + ", " + loc);
             } else {
                 map.put(key, loc);
             }
         }
-        System.out.println(locales.length+" locales: conflicts="+conflicts
-                           +", min="+min+", max="+max +", diff="+(max-min));
+        System.out.println(locales.length + " locales: conflicts=" + conflicts
+                + ", min=" + min + ", max=" + max + ", diff=" + (max - min));
         if (conflicts >= (locales.length / 10)) {
             throw new RuntimeException("too many conflicts: " + conflicts
-                                       + " per " + locales.length + " locales");
+                    + " per " + locales.length + " locales");
         }
     }
 }
--- a/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -46,11 +46,12 @@
  * @bug 6875847 6992272 7002320 7015500 7023613 7032820 7033504 7004603
  *    7044019 8008577
  * @summary test API changes to Locale
+ * @library /java/text/testlib
  * @modules jdk.localedata
  * @compile LocaleEnhanceTest.java
  * @run main/othervm -Djava.locale.providers=JRE,SPI -esa LocaleEnhanceTest
  */
-public class LocaleEnhanceTest extends LocaleTestFmwk {
+public class LocaleEnhanceTest extends IntlTest {
 
     public static void main(String[] args) throws Exception {
         List<String> argList = new ArrayList<String>();
--- a/jdk/test/java/util/Locale/LocaleTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Locale/LocaleTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -27,6 +27,7 @@
  * 4147315 4147317 4147552 4335196 4778440 4940539 5010672 6475525 6544471 6627549
  * 6786276 7066203 7085757 8008577 8030696
  * @summary test Locales
+ * @library /java/text/testlib
  * @modules jdk.localedata
  * @run main/othervm -Djava.locale.providers=JRE,SPI LocaleTest
  */
@@ -63,16 +64,25 @@
  *
  */
 
-import java.text.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OptionalDataException;
+import java.io.StreamCorruptedException;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
 import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 import java.util.MissingResourceException;
-import java.util.Date;
-import java.util.Calendar;
-import java.io.*;
 
-public class LocaleTest extends LocaleTestFmwk {
+public class LocaleTest extends IntlTest {
     public LocaleTest() {
     }
 
@@ -186,18 +196,22 @@
             Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
             logln("Testing " + testLocale + "...");
 
-            if (!testLocale.getLanguage().equals(dataTable[LANG][i]))
+            if (!testLocale.getLanguage().equals(dataTable[LANG][i])) {
                 errln("  Language code mismatch: " + testLocale.getLanguage() + " versus "
-                            + dataTable[LANG][i]);
-            if (!testLocale.getCountry().equals(dataTable[CTRY][i]))
+                        + dataTable[LANG][i]);
+            }
+            if (!testLocale.getCountry().equals(dataTable[CTRY][i])) {
                 errln("  Country code mismatch: " + testLocale.getCountry() + " versus "
-                            + dataTable[CTRY][i]);
-            if (!testLocale.getVariant().equals(dataTable[VAR][i]))
+                        + dataTable[CTRY][i]);
+            }
+            if (!testLocale.getVariant().equals(dataTable[VAR][i])) {
                 errln("  Variant code mismatch: " + testLocale.getVariant() + " versus "
-                            + dataTable[VAR][i]);
-            if (!testLocale.toString().equals(dataTable[NAME][i]))
+                        + dataTable[VAR][i]);
+            }
+            if (!testLocale.toString().equals(dataTable[NAME][i])) {
                 errln("  Locale name mismatch: " + testLocale.toString() + " versus "
-                            + dataTable[NAME][i]);
+                        + dataTable[NAME][i]);
+            }
         }
 
         logln("Same thing without variant codes...");
@@ -205,31 +219,37 @@
             Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i]);
             logln("Testing " + testLocale + "...");
 
-            if (!testLocale.getLanguage().equals(dataTable[LANG][i]))
+            if (!testLocale.getLanguage().equals(dataTable[LANG][i])) {
                 errln("  Language code mismatch: " + testLocale.getLanguage() + " versus "
-                            + dataTable[LANG][i]);
-            if (!testLocale.getCountry().equals(dataTable[CTRY][i]))
+                        + dataTable[LANG][i]);
+            }
+            if (!testLocale.getCountry().equals(dataTable[CTRY][i])) {
                 errln("  Country code mismatch: " + testLocale.getCountry() + " versus "
-                            + dataTable[CTRY][i]);
-            if (!testLocale.getVariant().equals(""))
+                        + dataTable[CTRY][i]);
+            }
+            if (!testLocale.getVariant().equals("")) {
                 errln("  Variant code mismatch: " + testLocale.getVariant() + " versus \"\"");
+            }
         }
     }
 
     public void TestSimpleResourceInfo() {
         for (int i = 0; i <= MAX_LOCALES; i++) {
-            if (dataTable[LANG][i].equals("xx"))
+            if (dataTable[LANG][i].equals("xx")) {
                 continue;
+            }
 
             Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
             logln("Testing " + testLocale + "...");
 
-            if (!testLocale.getISO3Language().equals(dataTable[LANG3][i]))
+            if (!testLocale.getISO3Language().equals(dataTable[LANG3][i])) {
                 errln("  ISO-3 language code mismatch: " + testLocale.getISO3Language()
-                            + " versus " + dataTable[LANG3][i]);
-            if (!testLocale.getISO3Country().equals(dataTable[CTRY3][i]))
+                        + " versus " + dataTable[LANG3][i]);
+            }
+            if (!testLocale.getISO3Country().equals(dataTable[CTRY3][i])) {
                 errln("  ISO-3 country code mismatch: " + testLocale.getISO3Country()
-                            + " versus " + dataTable[CTRY3][i]);
+                        + " versus " + dataTable[CTRY3][i]);
+            }
 /*
             // getLCID() is currently private
             if (!String.valueOf(testLocale.getLCID()).equals(dataTable[LCID][i]))
@@ -246,11 +266,11 @@
      * @bug 4052440 Stop falling back to the default locale.
      */
     public void TestDisplayNames() {
-        Locale  saveDefault = Locale.getDefault();
-        Locale  english = new Locale("en", "US");
-        Locale  french = new Locale("fr", "FR");
-        Locale  croatian = new Locale("hr", "HR");
-        Locale  greek = new Locale("el", "GR");
+        Locale saveDefault = Locale.getDefault();
+        Locale english = new Locale("en", "US");
+        Locale french = new Locale("fr", "FR");
+        Locale croatian = new Locale("hr", "HR");
+        Locale greek = new Locale("el", "GR");
 
         Locale.setDefault(english);
         logln("With default = en_US...");
@@ -282,97 +302,116 @@
     }
 
     private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
-        if (defaultIsFrench && !Locale.getDefault().getLanguage().equals("fr"))
-            errln("Default locale should be French, but it's really " + Locale.getDefault().getLanguage());
-        else if (!defaultIsFrench && !Locale.getDefault().getLanguage().equals("en"))
-            errln("Default locale should be English, but it's really " + Locale.getDefault().getLanguage());
+        String language = Locale.getDefault().getLanguage();
+
+        if (defaultIsFrench && !language.equals("fr")) {
+            errln("Default locale should be French, but it's really " + language);
+        } else if (!defaultIsFrench && !language.equals("en")) {
+            errln("Default locale should be English, but it's really " + language);
+        }
 
         for (int i = 0; i <= MAX_LOCALES; i++) {
             Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
             logln("  Testing " + testLocale + "...");
 
-            String  testLang;
-            String  testCtry;
-            String  testVar;
-            String  testName;
+            String testLang;
+            String testCtry;
+            String testVar;
+            String testName;
 
             if (inLocale == null) {
                 testLang = testLocale.getDisplayLanguage();
                 testCtry = testLocale.getDisplayCountry();
                 testVar = testLocale.getDisplayVariant();
                 testName = testLocale.getDisplayName();
-            }
-            else {
+            } else {
                 testLang = testLocale.getDisplayLanguage(inLocale);
                 testCtry = testLocale.getDisplayCountry(inLocale);
                 testVar = testLocale.getDisplayVariant(inLocale);
                 testName = testLocale.getDisplayName(inLocale);
             }
 
-            String  expectedLang;
-            String  expectedCtry;
-            String  expectedVar;
-            String  expectedName;
+            String expectedLang;
+            String expectedCtry;
+            String expectedVar;
+            String expectedName;
 
             expectedLang = dataTable[compareIndex][i];
-            if (expectedLang.equals("") && defaultIsFrench)
+            if (expectedLang.equals("") && defaultIsFrench) {
                 expectedLang = dataTable[DLANG_EN][i];
-            if (expectedLang.equals(""))
+            }
+            if (expectedLang.equals("")) {
                 expectedLang = dataTable[DLANG_ROOT][i];
+            }
 
             expectedCtry = dataTable[compareIndex + 1][i];
-            if (expectedCtry.equals("") && defaultIsFrench)
+            if (expectedCtry.equals("") && defaultIsFrench) {
                 expectedCtry = dataTable[DCTRY_EN][i];
-            if (expectedCtry.equals(""))
+            }
+            if (expectedCtry.equals("")) {
                 expectedCtry = dataTable[DCTRY_ROOT][i];
+            }
 
             expectedVar = dataTable[compareIndex + 2][i];
-            if (expectedVar.equals("") && defaultIsFrench)
+            if (expectedVar.equals("") && defaultIsFrench) {
                 expectedVar = dataTable[DVAR_EN][i];
-            if (expectedVar.equals(""))
+            }
+            if (expectedVar.equals("")) {
                 expectedVar = dataTable[DVAR_ROOT][i];
+            }
 
             expectedName = dataTable[compareIndex + 3][i];
-            if (expectedName.equals("") && defaultIsFrench)
+            if (expectedName.equals("") && defaultIsFrench) {
                 expectedName = dataTable[DNAME_EN][i];
-            if (expectedName.equals(""))
+            }
+            if (expectedName.equals("")) {
                 expectedName = dataTable[DNAME_ROOT][i];
+            }
 
-            if (!testLang.equals(expectedLang))
+            if (!testLang.equals(expectedLang)) {
                 errln("Display language mismatch: " + testLang + " versus " + expectedLang);
-            if (!testCtry.equals(expectedCtry))
+            }
+            if (!testCtry.equals(expectedCtry)) {
                 errln("Display country mismatch: " + testCtry + " versus " + expectedCtry);
-            if (!testVar.equals(expectedVar))
+            }
+            if (!testVar.equals(expectedVar)) {
                 errln("Display variant mismatch: " + testVar + " versus " + expectedVar);
-            if (!testName.equals(expectedName))
+            }
+            if (!testName.equals(expectedName)) {
                 errln("Display name mismatch: " + testName + " versus " + expectedName);
+            }
         }
     }
 
     public void TestSimpleObjectStuff() {
-        Locale  test1 = new Locale("aa", "AA");
-        Locale  test2 = new Locale("aa", "AA");
-        Locale  test3 = (Locale)test1.clone();
-        Locale  test4 = new Locale("zz", "ZZ");
+        Locale test1 = new Locale("aa", "AA");
+        Locale test2 = new Locale("aa", "AA");
+        Locale test3 = (Locale) test1.clone();
+        Locale test4 = new Locale("zz", "ZZ");
 
-        if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3)
+        if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) {
             errln("Some of the test variables point to the same locale!");
+        }
 
-        if (test3 == null)
+        if (test3 == null) {
             errln("clone() failed to produce a valid object!");
+        }
 
-        if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3))
+        if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) {
             errln("clone() or equals() failed: objects that should compare equal don't");
+        }
 
-        if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4))
+        if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) {
             errln("equals() failed: objects that shouldn't compare equal do");
+        }
 
         int hash1 = test1.hashCode();
         int hash2 = test2.hashCode();
         int hash3 = test3.hashCode();
 
-        if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3)
+        if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) {
             errln("hashCode() failed: objects that should have the same hash code don't");
+        }
     }
 
     /**
@@ -385,22 +424,22 @@
 
         try {
             result = test.getISO3Language();
-        }
-        catch (MissingResourceException e) {
+        } catch (MissingResourceException e) {
             gotException = true;
         }
-        if (!gotException)
+        if (!gotException) {
             errln("getISO3Language() on xx_YY returned " + result + " instead of throwing an exception");
+        }
 
         gotException = false;
         try {
             result = test.getISO3Country();
-        }
-        catch (MissingResourceException e) {
+        } catch (MissingResourceException e) {
             gotException = true;
         }
-        if (!gotException)
+        if (!gotException) {
             errln("getISO3Country() on xx_YY returned " + result + " instead of throwing an exception");
+        }
     }
 
     /**
@@ -416,53 +455,65 @@
         //     all lower case for the language codes, all upper case for the country codes)
         // 4) Is each list in sorted order?
         String[] test = Locale.getISOLanguages();
-        String[] spotCheck1 = { "en", "es", "fr", "de", "it", "ja", "ko", "zh", "th",
-                                "he", "id", "iu", "ug", "yi", "za" };
+        String[] spotCheck1 = {"en", "es", "fr", "de", "it", "ja", "ko", "zh", "th",
+            "he", "id", "iu", "ug", "yi", "za"};
 
-        if (test.length != 188)
+        if (test.length != 188) {
             errln("Expected getISOLanguages() to return 188 languages; it returned " + test.length);
-        else {
+        } else {
             for (int i = 0; i < spotCheck1.length; i++) {
                 int j;
-                for (j = 0; j < test.length; j++)
-                    if (test[j].equals(spotCheck1[i]))
+                for (j = 0; j < test.length; j++) {
+                    if (test[j].equals(spotCheck1[i])) {
                         break;
-                if (j == test.length || !test[j].equals(spotCheck1[i]))
+                    }
+                }
+                if (j == test.length || !test[j].equals(spotCheck1[i])) {
                     errln("Couldn't find " + spotCheck1[i] + " in language list.");
+                }
             }
         }
         for (int i = 0; i < test.length; i++) {
-            if (!test[i].equals(test[i].toLowerCase()))
+            if (!test[i].equals(test[i].toLowerCase())) {
                 errln(test[i] + " is not all lower case.");
-            if (test[i].length() != 2)
+            }
+            if (test[i].length() != 2) {
                 errln(test[i] + " is not two characters long.");
-            if (i > 0 && test[i].compareTo(test[i - 1]) <= 0)
+            }
+            if (i > 0 && test[i].compareTo(test[i - 1]) <= 0) {
                 errln(test[i] + " appears in an out-of-order position in the list.");
+            }
         }
 
         test = Locale.getISOCountries();
-        String[] spotCheck2 = { "US", "CA", "GB", "FR", "DE", "IT", "JP", "KR", "CN", "TW", "TH" };
+        String[] spotCheck2 = {"US", "CA", "GB", "FR", "DE", "IT", "JP", "KR", "CN", "TW", "TH"};
 
 
-        if (test.length != 250)
+        if (test.length != 250) {
             errln("Expected getISOCountries to return 250 countries; it returned " + test.length);
-        else {
+        } else {
             for (int i = 0; i < spotCheck2.length; i++) {
                 int j;
-                for (j = 0; j < test.length; j++)
-                    if (test[j].equals(spotCheck2[i]))
+                for (j = 0; j < test.length; j++) {
+                    if (test[j].equals(spotCheck2[i])) {
                         break;
-                if (j == test.length || !test[j].equals(spotCheck2[i]))
+                    }
+                }
+                if (j == test.length || !test[j].equals(spotCheck2[i])) {
                     errln("Couldn't find " + spotCheck2[i] + " in country list.");
+                }
             }
         }
         for (int i = 0; i < test.length; i++) {
-            if (!test[i].equals(test[i].toUpperCase()))
+            if (!test[i].equals(test[i].toUpperCase())) {
                 errln(test[i] + " is not all upper case.");
-            if (test[i].length() != 2)
+            }
+            if (test[i].length() != 2) {
                 errln(test[i] + " is not two characters long.");
-            if (i > 0 && test[i].compareTo(test[i - 1]) <= 0)
+            }
+            if (i > 0 && test[i].compareTo(test[i - 1]) <= 0) {
                 errln(test[i] + " appears in an out-of-order position in the list.");
+            }
         }
     }
 
@@ -475,14 +526,16 @@
         test = Locale.getISOCountries();
         test[0] = "SUCKER!!!";
         test = Locale.getISOCountries();
-        if (test[0].equals("SUCKER!!!"))
+        if (test[0].equals("SUCKER!!!")) {
             errln("Changed internal country code list!");
+        }
 
         test = Locale.getISOLanguages();
         test[0] = "HAHAHAHA!!!";
         test = Locale.getISOLanguages();
-        if (test[0].equals("HAHAHAHA!!!")) // Fixed typo
+        if (test[0].equals("HAHAHAHA!!!")) { // Fixed typo
             errln("Changes internal language code list!");
+        }
     }
 
     /**
@@ -490,12 +543,13 @@
      */
     public void TestGetAvailableLocales() {
         Locale[] locales = Locale.getAvailableLocales();
-        if (locales == null || locales.length == 0)
+        if (locales == null || locales.length == 0) {
             errln("Locale.getAvailableLocales() returned no installed locales!");
-        else {
+        } else {
             logln("Locale.getAvailableLocales() returned a list of " + locales.length + " locales.");
-            for (int i = 0; i < locales.length; i++)
+            for (int i = 0; i < locales.length; i++) {
                 logln(locales[i].toString());
+            }
         }
     }
 
@@ -505,8 +559,9 @@
     public void TestBug4135316() {
         Locale[] locales1 = Locale.getAvailableLocales();
         Locale[] locales2 = Locale.getAvailableLocales();
-        if (locales1 == locales2)
+        if (locales1 == locales2) {
             errln("Locale.getAvailableLocales() doesn't clone its internal storage!");
+        }
     }
 
     /**
@@ -548,8 +603,7 @@
      * @bug 4110613
      */
     public void TestSerialization() throws ClassNotFoundException, OptionalDataException,
-                    IOException, StreamCorruptedException
-    {
+            IOException, StreamCorruptedException {
         ObjectOutputStream ostream;
         ByteArrayOutputStream obstream;
         byte[] bytes = null;
@@ -565,10 +619,11 @@
 
         ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes));
 
-        Locale test2 = (Locale)(istream.readObject());
+        Locale test2 = (Locale) (istream.readObject());
 
-        if (!test1.equals(test2) || test1.hashCode() != test2.hashCode())
+        if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) {
             errln("Locale failed to deserialize correctly.");
+        }
     }
 
     /**
@@ -579,15 +634,16 @@
         // fallback behavior, combination of language and country names to form locale
         // names, and other stuff like that.  This test just checks specific language
         // and country codes to make sure we have the correct names for them.
-        String[] languageCodes = { "he", "id", "iu", "ug", "yi", "za" };
-        String[] languageNames = { "Hebrew", "Indonesian", "Inuktitut", "Uighur", "Yiddish",
-                                   "Zhuang" };
+        String[] languageCodes = {"he", "id", "iu", "ug", "yi", "za"};
+        String[] languageNames = {"Hebrew", "Indonesian", "Inuktitut", "Uighur", "Yiddish",
+            "Zhuang"};
 
         for (int i = 0; i < languageCodes.length; i++) {
             String test = (new Locale(languageCodes[i], "", "")).getDisplayLanguage(Locale.US);
-            if (!test.equals(languageNames[i]))
-                errln("Got wrong display name for " + languageCodes[i] + ": Expected \"" +
-                      languageNames[i] + "\", got \"" + test + "\".");
+            if (!test.equals(languageNames[i])) {
+                errln("Got wrong display name for " + languageCodes[i] + ": Expected \""
+                        + languageNames[i] + "\", got \"" + test + "\".");
+            }
         }
     }
 
@@ -597,24 +653,26 @@
     public void TestUninstalledISO3Names() {
         // This test checks to make sure getISO3Language and getISO3Country work right
         // even for locales that are not installed.
-        String[] iso2Languages = { "am", "ba", "fy", "mr", "rn", "ss", "tw", "zu" };
-        String[] iso3Languages = { "amh", "bak", "fry", "mar", "run", "ssw", "twi", "zul" };
+        String[] iso2Languages = {"am", "ba", "fy", "mr", "rn", "ss", "tw", "zu"};
+        String[] iso3Languages = {"amh", "bak", "fry", "mar", "run", "ssw", "twi", "zul"};
 
         for (int i = 0; i < iso2Languages.length; i++) {
             String test = (new Locale(iso2Languages[i], "", "")).getISO3Language();
-            if (!test.equals(iso3Languages[i]))
-                errln("Got wrong ISO3 code for " + iso2Languages[i] + ": Expected \"" +
-                        iso3Languages[i] + "\", got \"" + test + "\".");
+            if (!test.equals(iso3Languages[i])) {
+                errln("Got wrong ISO3 code for " + iso2Languages[i] + ": Expected \""
+                        + iso3Languages[i] + "\", got \"" + test + "\".");
+            }
         }
 
-        String[] iso2Countries = { "AF", "BW", "KZ", "MO", "MN", "SB", "TC", "ZW" };
-        String[] iso3Countries = { "AFG", "BWA", "KAZ", "MAC", "MNG", "SLB", "TCA", "ZWE" };
+        String[] iso2Countries = {"AF", "BW", "KZ", "MO", "MN", "SB", "TC", "ZW"};
+        String[] iso3Countries = {"AFG", "BWA", "KAZ", "MAC", "MNG", "SLB", "TCA", "ZWE"};
 
         for (int i = 0; i < iso2Countries.length; i++) {
             String test = (new Locale("", iso2Countries[i], "")).getISO3Country();
-            if (!test.equals(iso3Countries[i]))
-                errln("Got wrong ISO3 code for " + iso2Countries[i] + ": Expected \"" +
-                        iso3Countries[i] + "\", got \"" + test + "\".");
+            if (!test.equals(iso3Countries[i])) {
+                errln("Got wrong ISO3 code for " + iso2Countries[i] + ": Expected \""
+                        + iso3Countries[i] + "\", got \"" + test + "\".");
+            }
         }
     }
 
@@ -629,15 +687,18 @@
         Locale indonesianOld = new Locale("in", "", "");
         Locale indonesianNew = new Locale("id", "", "");
 
-        if (!hebrewNew.getLanguage().equals("iw"))
-            errln("Got back wrong language code for Hebrew: expected \"iw\", got \"" +
-                            hebrewNew.getLanguage() + "\"");
-        if (!yiddishNew.getLanguage().equals("ji"))
-            errln("Got back wrong language code for Yiddish: expected \"ji\", got \"" +
-                            yiddishNew.getLanguage() + "\"");
-        if (!indonesianNew.getLanguage().equals("in"))
-            errln("Got back wrong language code for Indonesian: expected \"in\", got \"" +
-                            indonesianNew.getLanguage() + "\"");
+        if (!hebrewNew.getLanguage().equals("iw")) {
+            errln("Got back wrong language code for Hebrew: expected \"iw\", got \""
+                    + hebrewNew.getLanguage() + "\"");
+        }
+        if (!yiddishNew.getLanguage().equals("ji")) {
+            errln("Got back wrong language code for Yiddish: expected \"ji\", got \""
+                    + yiddishNew.getLanguage() + "\"");
+        }
+        if (!indonesianNew.getLanguage().equals("in")) {
+            errln("Got back wrong language code for Indonesian: expected \"in\", got \""
+                    + indonesianNew.getLanguage() + "\"");
+        }
     }
 
     /**
@@ -703,25 +764,28 @@
         for (int i = 0; i < localesToTest.length; i++) {
             String name = localesToTest[i].getDisplayName(Locale.US);
             logln(name);
-            if (!name.equals(englishDisplayNames[i]))
+            if (!name.equals(englishDisplayNames[i])) {
                 errln("Lookup in English failed: expected \"" + englishDisplayNames[i]
-                            + "\", got \"" + name + "\"");
+                        + "\", got \"" + name + "\"");
+            }
         }
 
         for (int i = 0; i < localesToTest.length; i++) {
             String name = localesToTest[i].getDisplayName(new Locale("es", "ES"));
             logln(name);
-            if (!name.equals(spanishDisplayNames[i]))
+            if (!name.equals(spanishDisplayNames[i])) {
                 errln("Lookup in Spanish failed: expected \"" + spanishDisplayNames[i]
-                            + "\", got \"" + name + "\"");
+                        + "\", got \"" + name + "\"");
+            }
         }
 
         for (int i = 0; i < localesToTest.length; i++) {
             String name = localesToTest[i].getDisplayName(Locale.FRANCE);
             logln(name);
-            if (!name.equals(frenchDisplayNames[i]))
+            if (!name.equals(frenchDisplayNames[i])) {
                 errln("Lookup in French failed: expected \"" + frenchDisplayNames[i]
-                            + "\", got \"" + name + "\"");
+                        + "\", got \"" + name + "\"");
+            }
         }
 
         // restore the default locale for other tests
@@ -737,15 +801,16 @@
         boolean gotException = false;
         try {
             Locale.setDefault(null);
-        }
-        catch (NullPointerException e) {
+        } catch (NullPointerException e) {
             // all other exception types propagate through here back to the test harness
             gotException = true;
         }
-        if (Locale.getDefault() == null)
+        if (Locale.getDefault() == null) {
             errln("Locale.getDefault() allowed us to set default to NULL!");
-        if (!gotException)
+        }
+        if (!gotException) {
             errln("Trying to set default locale to NULL didn't throw exception!");
+        }
     }
 
     /**
@@ -754,14 +819,16 @@
      * get the LocaleDataTest working again.
      */
     public void TestThaiCurrencyFormat() {
-        DecimalFormat thaiCurrency = (DecimalFormat)NumberFormat.getCurrencyInstance(
-                        new Locale("th", "TH"));
-        if (!thaiCurrency.getPositivePrefix().equals("\u0e3f"))
-            errln("Thai currency prefix wrong: expected \"\u0e3f\", got \"" +
-                            thaiCurrency.getPositivePrefix() + "\"");
-        if (!thaiCurrency.getPositiveSuffix().equals(""))
-            errln("Thai currency suffix wrong: expected \"\", got \"" +
-                            thaiCurrency.getPositiveSuffix() + "\"");
+        DecimalFormat thaiCurrency = (DecimalFormat) NumberFormat.getCurrencyInstance(
+                new Locale("th", "TH"));
+        if (!thaiCurrency.getPositivePrefix().equals("\u0e3f")) {
+            errln("Thai currency prefix wrong: expected \"\u0e3f\", got \""
+                    + thaiCurrency.getPositivePrefix() + "\"");
+        }
+        if (!thaiCurrency.getPositiveSuffix().equals("")) {
+            errln("Thai currency suffix wrong: expected \"\", got \""
+                    + thaiCurrency.getPositiveSuffix() + "\"");
+        }
     }
 
     /**
@@ -778,26 +845,25 @@
      * iterate through all locales.
      */
     public void TestEuroSupport() {
-        final String EURO_VARIANT  = "EURO";
+        final String EURO_VARIANT = "EURO";
         final String EURO_CURRENCY = "\u20AC"; // Look for this string in formatted Euro currency
 
         Locale[] locales = NumberFormat.getAvailableLocales();
-        for (int i=0; i<locales.length; ++i) {
+        for (int i = 0; i < locales.length; ++i) {
             Locale loc = locales[i];
             if (loc.getVariant().indexOf(EURO_VARIANT) >= 0) {
                 NumberFormat nf = NumberFormat.getCurrencyInstance(loc);
                 String pos = nf.format(271828.182845);
                 String neg = nf.format(-271828.182845);
-                if (pos.indexOf(EURO_CURRENCY) >= 0 &&
-                    neg.indexOf(EURO_CURRENCY) >= 0) {
-                    logln("Ok: " + loc.toString() +
-                          ": " + pos + " / " + neg);
-                }
-                else {
-                    errln("Fail: " + loc.toString() +
-                          " formats without " + EURO_CURRENCY +
-                          ": " + pos + " / " + neg +
-                          "\n*** THIS FAILURE MAY ONLY MEAN THAT LOCALE DATA HAS CHANGED ***");
+                if (pos.indexOf(EURO_CURRENCY) >= 0
+                        && neg.indexOf(EURO_CURRENCY) >= 0) {
+                    logln("Ok: " + loc.toString()
+                            + ": " + pos + " / " + neg);
+                } else {
+                    errln("Fail: " + loc.toString()
+                            + " formats without " + EURO_CURRENCY
+                            + ": " + pos + " / " + neg
+                            + "\n*** THIS FAILURE MAY ONLY MEAN THAT LOCALE DATA HAS CHANGED ***");
                 }
             }
         }
@@ -811,15 +877,15 @@
         Object[] DATA = {
             new Locale("xx", "", ""), "xx",
             new Locale("", "YY", ""), "_YY",
-        new Locale("", "", "ZZ"), "",
+            new Locale("", "", "ZZ"), "",
             new Locale("xx", "YY", ""), "xx_YY",
             new Locale("xx", "", "ZZ"), "xx__ZZ",
             new Locale("", "YY", "ZZ"), "_YY_ZZ",
             new Locale("xx", "YY", "ZZ"), "xx_YY_ZZ",
         };
-        for (int i=0; i<DATA.length; i+=2) {
-            Locale loc = (Locale)DATA[i];
-            String fmt = (String)DATA[i+1];
+        for (int i = 0; i < DATA.length; i += 2) {
+            Locale loc = (Locale) DATA[i];
+            String fmt = (String) DATA[i + 1];
             if (!loc.toString().equals(fmt)) {
                 errln("Fail: Locale.toString(" + fmt + ")=>" + loc);
             }
@@ -832,9 +898,9 @@
      * end to test the whole pipe.
      */
     public void Test4105828() {
-        Locale[] LOC = { Locale.CHINESE, new Locale("zh", "CN", ""),
-                         new Locale("zh", "TW", ""), new Locale("zh", "HK", "") };
-        for (int i=0; i<LOC.length; ++i) {
+        Locale[] LOC = {Locale.CHINESE, new Locale("zh", "CN", ""),
+            new Locale("zh", "TW", ""), new Locale("zh", "HK", "")};
+        for (int i = 0; i < LOC.length; ++i) {
             NumberFormat fmt = NumberFormat.getPercentInstance(LOC[i]);
             String result = fmt.format(1);
             if (!result.equals("100%")) {
@@ -860,14 +926,16 @@
      * test that here.
      */
     public void Test4139940() {
-        Locale mylocale=new Locale("hu", "", "");
-        Date mydate = new Date(98,3,13); // A Monday
+        Locale mylocale = new Locale("hu", "", "");
+        @SuppressWarnings("deprecation")
+        Date mydate = new Date(98, 3, 13); // A Monday
         DateFormat df_full = new SimpleDateFormat("EEEE", mylocale);
         String str = df_full.format(mydate);
         // Make sure that o circumflex (\u00F4) is NOT there, and
         // o double acute (\u0151) IS.
-        if (str.indexOf('\u0151') < 0 || str.indexOf('\u00F4') >= 0)
+        if (str.indexOf('\u0151') < 0 || str.indexOf('\u00F4') >= 0) {
             errln("Fail: Monday in Hungarian is wrong");
+        }
     }
 
     /**
@@ -894,9 +962,10 @@
         try {
             String result = locale.getISO3Country();
 
-            errln("ERROR: getISO3Country() returns: " + result +
-                " for locale '" + locale + "' rather than exception" );
-        } catch(MissingResourceException e) { }
+            errln("ERROR: getISO3Country() returns: " + result
+                    + " for locale '" + locale + "' rather than exception");
+        } catch (MissingResourceException e) {
+        }
     }
 
     /**
@@ -912,8 +981,8 @@
 
         String result = locale.getISO3Language();
         if (!result.equals("aaa")) {
-            errln("ERROR: getISO3Language() returns: " + result +
-                " for locale '" + locale + "' rather than returning it as is" );
+            errln("ERROR: getISO3Language() returns: " + result
+                    + " for locale '" + locale + "' rather than returning it as is");
         }
 
         // Try an invalid two letter language code, and check whether it
@@ -923,36 +992,39 @@
         try {
             result = locale.getISO3Language();
 
-            errln("ERROR: getISO3Language() returns: " + result +
-                " for locale '" + locale + "' rather than exception" );
-        } catch(MissingResourceException e) { }
+            errln("ERROR: getISO3Language() returns: " + result
+                    + " for locale '" + locale + "' rather than exception");
+        } catch (MissingResourceException e) {
+        }
     }
 
     /*
      * @bug 4147552 4778440 8030696
      */
     public void Test4147552() {
-        Locale[] locales = { new Locale("no", "NO"), new Locale("no", "NO", "B"),
-                             new Locale("no", "NO", "NY"), new Locale("nb", "NO"),
-                             new Locale("nn", "NO") };
-        String[] englishDisplayNames = { "Norwegian (Norway)",
-                     "Norwegian (Norway,Bokm\u00e5l)",
-                     "Norwegian (Norway,Nynorsk)",
-                     "Norwegian Bokm\u00e5l (Norway)",
-                     "Norwegian Nynorsk (Norway)" };
-        String[] norwegianDisplayNames = { "norsk (Norge)",
-                     "norsk (Norge,bokm\u00e5l)", "norsk (Noreg,nynorsk)",
-                     "bokm\u00e5l (Norge)", "nynorsk (Noreg)" };
+        Locale[] locales = {new Locale("no", "NO"), new Locale("no", "NO", "B"),
+            new Locale("no", "NO", "NY"), new Locale("nb", "NO"),
+            new Locale("nn", "NO")};
+        String[] englishDisplayNames = {"Norwegian (Norway)",
+            "Norwegian (Norway,Bokm\u00e5l)",
+            "Norwegian (Norway,Nynorsk)",
+            "Norwegian Bokm\u00e5l (Norway)",
+            "Norwegian Nynorsk (Norway)"};
+        String[] norwegianDisplayNames = {"norsk (Norge)",
+            "norsk (Norge,bokm\u00e5l)", "norsk (Noreg,nynorsk)",
+            "bokm\u00e5l (Norge)", "nynorsk (Noreg)"};
 
         for (int i = 0; i < locales.length; i++) {
             Locale loc = locales[i];
-            if (!loc.getDisplayName(Locale.US).equals(englishDisplayNames[i]))
-               errln("English display-name mismatch: expected " +
-                       englishDisplayNames[i] + ", got " + loc.getDisplayName());
-            if (!loc.getDisplayName(loc).equals(norwegianDisplayNames[i]))
-                errln("Norwegian display-name mismatch: expected " +
-                       norwegianDisplayNames[i] + ", got " +
-                       loc.getDisplayName(loc));
+            if (!loc.getDisplayName(Locale.US).equals(englishDisplayNames[i])) {
+                errln("English display-name mismatch: expected "
+                        + englishDisplayNames[i] + ", got " + loc.getDisplayName());
+            }
+            if (!loc.getDisplayName(loc).equals(norwegianDisplayNames[i])) {
+                errln("Norwegian display-name mismatch: expected "
+                        + norwegianDisplayNames[i] + ", got "
+                        + loc.getDisplayName(loc));
+            }
         }
     }
 
@@ -961,21 +1033,24 @@
      */
     public void Test8030696() {
         List<Locale> av = Arrays.asList(Locale.getAvailableLocales());
-        if (!av.contains(new Locale("nb", "NO")) ||
-            !av.contains(new Locale("nn", "NO"))) {
-                errln("\"nb-NO\" and/or \"nn-NO\" locale(s) not returned from getAvailableLocales().");
+        if (!av.contains(new Locale("nb", "NO"))
+                || !av.contains(new Locale("nn", "NO"))) {
+            errln("\"nb-NO\" and/or \"nn-NO\" locale(s) not returned from getAvailableLocales().");
         }
     }
 
     static String escapeUnicode(String s) {
         StringBuffer buf = new StringBuffer();
-        for (int i=0; i<s.length(); ++i) {
+        for (int i = 0; i < s.length(); ++i) {
             char c = s.charAt(i);
-            if (c >= 0x20 && c <= 0x7F) buf.append(c);
-            else {
+            if (c >= 0x20 && c <= 0x7F) {
+                buf.append(c);
+            } else {
                 buf.append("\\u");
                 String h = "000" + Integer.toHexString(c);
-                if (h.length() > 4) h = h.substring(h.length() - 4);
+                if (h.length() > 4) {
+                    h = h.substring(h.length() - 4);
+                }
                 buf.append(h);
             }
         }
--- a/jdk/test/java/util/Locale/LocaleTestFmwk.java	Fri Nov 25 11:16:51 2016 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- *
- *
- * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
- * (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
- *
- * Portions copyright (c) 2007 Sun Microsystems, Inc.
- * All Rights Reserved.
- *
- * The original version of this source code and documentation
- * is copyrighted and owned by Taligent, Inc., a wholly-owned
- * subsidiary of IBM. These materials are provided under terms
- * of a License Agreement between Taligent and Sun. This technology
- * is protected by multiple US and International patents.
- *
- * This notice and attribution to Taligent may not be removed.
- * Taligent is a registered trademark of Taligent, Inc.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for NON-COMMERCIAL purposes and without
- * fee is hereby granted provided that this copyright notice
- * appears in all copies. Please refer to the file "copyright.html"
- * for further important copyright and licensing information.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
- *
- */
-
-import java.lang.reflect.*;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import java.util.Vector;
-import java.io.*;
-import java.text.*;
-
-/**
- * LocaleTestFmwk is a base class for tests that can be run conveniently from
- * the command line as well as under the Java test harness.
- * <p>
- * Sub-classes implement a set of methods named Test<something>. Each
- * of these methods performs some test. Test methods should indicate
- * errors by calling either err or errln.  This will increment the
- * errorCount field and may optionally print a message to the log.
- * Debugging information may also be added to the log via the log
- * and logln methods.  These methods will add their arguments to the
- * log only if the test is being run in verbose mode.
- */
-public class LocaleTestFmwk {
-    //------------------------------------------------------------------------
-    // Everything below here is boilerplate code that makes it possible
-    // to add a new test by simply adding a function to an existing class
-    //------------------------------------------------------------------------
-
-    protected LocaleTestFmwk() {
-        // Create a hashtable containing all the test methods.
-        testMethods = new Hashtable();
-        Method[] methods = getClass().getDeclaredMethods();
-        for( int i=0; i<methods.length; i++ ) {
-            if( methods[i].getName().startsWith("Test")
-                    || methods[i].getName().startsWith("test")) {
-                testMethods.put( methods[i].getName(), methods[i] );
-            }
-        }
-    }
-
-    protected void run(String[] args) throws Exception
-    {
-        System.out.println(getClass().getName() + " {");
-        indentLevel++;
-
-        // Set up the log and reference streams.  We use PrintWriters in order to
-        // take advantage of character conversion.  The JavaEsc converter will
-        // convert Unicode outside the ASCII range to Java's \\uxxxx notation.
-        log = new PrintWriter(System.out,true);
-
-        // Parse the test arguments.  They can be either the flag
-        // "-verbose" or names of test methods. Create a list of
-        // tests to be run.
-        Vector testsToRun = new Vector( args.length );
-        for( int i=0; i<args.length; i++ ) {
-            if( args[i].equals("-verbose") ) {
-                verbose = true;
-            }
-            else if( args[i].equals("-prompt") ) {
-                prompt = true;
-            } else if (args[i].equals("-nothrow")) {
-                nothrow = true;
-            } else if (args[i].equals("-exitcode")) {
-                exitcode = true;
-            } else {
-                Object m = testMethods.get( args[i] );
-                if( m != null ) {
-                    testsToRun.addElement( m );
-                }
-                else {
-                    usage();
-                    return;
-                }
-            }
-        }
-
-        // If no test method names were given explicitly, run them all.
-        if( testsToRun.size() == 0 ) {
-            Enumeration methodNames = testMethods.elements();
-            while( methodNames.hasMoreElements() ) {
-                testsToRun.addElement( methodNames.nextElement() );
-            }
-        }
-
-        // Run the list of tests given in the test arguments
-        for( int i=0; i<testsToRun.size(); i++ ) {
-            int oldCount = errorCount;
-
-            Method testMethod = (Method)testsToRun.elementAt(i);
-            writeTestName(testMethod.getName());
-
-            try {
-                testMethod.invoke(this, new Object[0]);
-            }
-            catch( IllegalAccessException e ) {
-                errln("Can't acces test method " + testMethod.getName());
-            }
-            catch( InvocationTargetException e ) {
-                errln("Uncaught exception thrown in test method "
-                               + testMethod.getName());
-                e.getTargetException().printStackTrace(this.log);
-            }
-            writeTestResult(errorCount - oldCount);
-        }
-        indentLevel--;
-        writeTestResult(errorCount);
-
-        if (prompt) {
-            System.out.println("Hit RETURN to exit...");
-            try {
-                System.in.read();
-            }
-            catch (IOException e) {
-                System.out.println("Exception: " + e.toString() + e.getMessage());
-            }
-        }
-        if (nothrow) {
-            if (exitcode) {
-                System.exit(errorCount);
-            }
-            if (errorCount > 0) {
-                throw new IllegalArgumentException("encountered " + errorCount + " errors");
-            }
-        }
-    }
-
-    /**
-     * Adds given string to the log if we are in verbose mode.
-     */
-    protected void log( String message ) {
-        if( verbose ) {
-            indent(indentLevel + 1);
-            log.print( message );
-        }
-    }
-
-    protected void logln( String message ) {
-        log(message + System.getProperty("line.separator"));
-    }
-
-    /**
-     * Report an error
-     */
-    protected void err( String message ) {
-        errorCount++;
-        indent(indentLevel + 1);
-        log.print( message );
-        log.flush();
-
-        if (!nothrow) {
-            throw new RuntimeException(message);
-        }
-    }
-
-    protected void errln( String message ) {
-        err(message + System.getProperty("line.separator"));
-    }
-
-
-    protected void writeTestName(String testName) {
-        indent(indentLevel);
-        log.print(testName);
-        log.flush();
-        needLineFeed = true;
-    }
-
-    protected void writeTestResult(int count) {
-        if (!needLineFeed) {
-            indent(indentLevel);
-            log.print("}");
-        }
-        needLineFeed = false;
-
-        if (count != 0)
-            log.println(" FAILED");
-        else
-            log.println(" Passed");
-    }
-
-    private final void indent(int distance) {
-        if (needLineFeed) {
-            log.println(" {");
-            needLineFeed = false;
-        }
-        log.print(spaces.substring(0, distance * 2));
-    }
-
-    /**
-     * Print a usage message for this test class.
-     */
-    void usage() {
-        System.out.println(getClass().getName() +
-                            ": [-verbose] [-nothrow] [-exitcode] [-prompt] [test names]");
-
-        System.out.println("test names:");
-        Enumeration methodNames = testMethods.keys();
-        while( methodNames.hasMoreElements() ) {
-            System.out.println("\t" + methodNames.nextElement() );
-        }
-    }
-
-    private boolean     prompt = false;
-    private boolean     nothrow = false;
-    private boolean     exitcode = false;
-    protected boolean   verbose = false;
-
-    private PrintWriter log;
-    private int         indentLevel = 0;
-    private boolean     needLineFeed = false;
-    private int         errorCount = 0;
-
-    private Hashtable testMethods;
-    private final String spaces = "                                          ";
-}
--- a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary Spliterator traversing and splitting tests
  * @run testng SpliteratorTraversingAndSplittingTest
- * @bug 8020016 8071477
+ * @bug 8020016 8071477 8072784 8169838
  */
 
 import org.testng.annotations.DataProvider;
@@ -37,6 +37,7 @@
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.BitSet;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
@@ -80,7 +81,9 @@
 import java.util.function.LongConsumer;
 import java.util.function.Supplier;
 import java.util.function.UnaryOperator;
+import java.util.stream.IntStream;
 
+import static java.util.stream.Collectors.toList;
 import static org.testng.Assert.*;
 import static org.testng.Assert.assertEquals;
 
@@ -883,6 +886,30 @@
             cdb.add("new StringBuffer(\"%s\")", StringBuffer::new);
         }
 
+
+        Object[][] bitStreamTestcases = new Object[][] {
+                { "none", IntStream.empty().toArray() },
+                { "index 0", IntStream.of(0).toArray() },
+                { "index 255", IntStream.of(255).toArray() },
+                { "index 0 and 255", IntStream.of(0, 255).toArray() },
+                { "every bit", IntStream.range(0, 255).toArray() },
+                { "step 2", IntStream.range(0, 255).map(f -> f * 2).toArray() },
+                { "step 3", IntStream.range(0, 255).map(f -> f * 3).toArray() },
+                { "step 5", IntStream.range(0, 255).map(f -> f * 5).toArray() },
+                { "step 7", IntStream.range(0, 255).map(f -> f * 7).toArray() },
+                { "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000).toArray() },
+        };
+        for (Object[] tc : bitStreamTestcases) {
+            String description = (String)tc[0];
+            int[] exp = (int[])tc[1];
+            SpliteratorOfIntDataBuilder db = new SpliteratorOfIntDataBuilder(
+                    data, IntStream.of(exp).boxed().collect(toList()));
+
+            db.add("BitSet.stream.spliterator() {" + description + "}", () ->
+                IntStream.of(exp).collect(BitSet::new, BitSet::set, BitSet::or).
+                        stream().spliterator()
+            );
+        }
         return spliteratorOfIntDataProvider = data.toArray(new Object[0][]);
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/ReadWithoutBaselineTagSet.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8164750
+ * @summary Verify reader does not fail when the BaselineTIFFTagSet is
+ *          removed via the TIFFImageReadParam both when ignoring and
+ *          not ignoring metadata.
+ */
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Map;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.plugins.tiff.BaselineTIFFTagSet;
+import javax.imageio.plugins.tiff.TIFFImageReadParam;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.MemoryCacheImageInputStream;
+import javax.imageio.stream.MemoryCacheImageOutputStream;
+
+public class ReadWithoutBaselineTagSet {
+    private static final int WIDTH = 47;
+    private static final int HEIGHT = 53;
+
+    private static final Map<Integer,String[]> typeToCompression =
+        Map.of(BufferedImage.TYPE_3BYTE_BGR,
+            new String[] {null, "LZW", "JPEG", "ZLib", "PackBits"},
+            BufferedImage.TYPE_BYTE_BINARY,
+            new String[] {null, "CCITT RLE", "CCITT T.4", "CCITT T.6",
+                "LZW", "PackBits"},
+            BufferedImage.TYPE_BYTE_GRAY,
+            new String[] {null, "LZW", "JPEG", "ZLib", "PackBits"},
+            BufferedImage.TYPE_USHORT_GRAY,
+            new String[] {null, "LZW", "ZLib", "PackBits"});
+
+    public static void main(String[] args) throws IOException {
+        test();
+    }
+
+    private static void test() throws IOException {
+        int failures = 0;
+
+        for (int imageType : typeToCompression.keySet()) {
+            BufferedImage image = new BufferedImage(WIDTH, HEIGHT, imageType);
+            System.out.println("Image: " + image.toString());
+
+            for (String compression : typeToCompression.get(imageType)) {
+                System.out.println("Compression: "
+                        + (compression == null ? "None" : compression));
+                ByteArrayOutputStream output = new ByteArrayOutputStream();
+                ImageOutputStream ios = new MemoryCacheImageOutputStream(output);
+                ImageWriter writer =
+                        ImageIO.getImageWritersByFormatName("TIFF").next();
+                ImageWriteParam wparam = writer.getDefaultWriteParam();
+                if (compression == null) {
+                    wparam.setCompressionMode(ImageWriteParam.MODE_DEFAULT);
+                } else {
+                    wparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+                    wparam.setCompressionType(compression);
+                }
+                writer.setOutput(ios);
+                writer.write(null, new IIOImage(image, null, null), wparam);
+                ios.flush();
+
+                ImageReader reader =
+                        ImageIO.getImageReadersByFormatName("TIFF").next();
+                ByteArrayInputStream input
+                        = new ByteArrayInputStream(output.toByteArray());
+                ImageInputStream iis = new MemoryCacheImageInputStream(input);
+                iis.mark();
+
+                TIFFImageReadParam rparam = new TIFFImageReadParam();
+                rparam.removeAllowedTagSet(BaselineTIFFTagSet.getInstance());
+
+                reader.setInput(iis, false, false);
+                BufferedImage resultFalse = reader.read(0, rparam);
+                if (resultFalse.getWidth() != WIDTH
+                        || resultFalse.getHeight() != HEIGHT) {
+                    System.err.printf("Read image dimensions != %d x %d%n",
+                            WIDTH, HEIGHT);
+                    failures++;
+                } else {
+                    System.out.println("ignoreMetadata == false test passed");
+                }
+
+                iis.reset();
+                reader.setInput(iis, false, true);
+                BufferedImage resultTrue;
+                try {
+                    resultTrue = reader.read(0, rparam);
+                    if (resultTrue.getWidth() != WIDTH
+                            || resultTrue.getHeight() != HEIGHT) {
+                        System.err.printf("Read image dimensions != %d x %d%n",
+                                WIDTH, HEIGHT);
+                        failures++;
+                    } else {
+                        System.out.println("ignoreMetadata == true test passed");
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    failures++;
+                }
+            }
+        }
+
+        if (failures != 0) {
+            throw new RuntimeException("Test failed with "
+                    + failures + " errors!");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/finalize/SSLSessionFinalizeTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,355 @@
+/*
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test behavior related to finalize
+ * @run main/othervm  SSLSessionFinalizeTest
+ * @run main/othervm/policy=security.policy  SSLSessionFinalizeTest
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.concurrent.ArrayBlockingQueue;
+
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSessionBindingEvent;
+import javax.net.ssl.SSLSessionBindingListener;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+public class SSLSessionFinalizeTest {
+
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = true;
+
+    /*
+     * Where do we find the keystores?
+     */
+    static String pathToStores = "../etc";
+    static String keyStoreFile = "keystore";
+    static String trustStoreFile = "truststore";
+    static String passwd = "passphrase";
+
+    /*
+     * Is the server ready to serve?
+     */
+    volatile static boolean serverReady = false;
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * If the client or server is doing some kind of object creation
+     * that the other side depends on, and that thread prematurely
+     * exits, you may experience a hang.  The test harness will
+     * terminate all hung threads after its timeout has expired,
+     * currently 3 minutes by default, but you might try to be
+     * smart about it....
+     */
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+        SSLServerSocketFactory sslssf =
+            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+        SSLServerSocket sslServerSocket =
+            (SSLServerSocket) sslssf.createServerSocket(serverPort);
+        serverPort = sslServerSocket.getLocalPort();
+
+        /*
+         * Signal Client, we're ready for his connect.
+         */
+        serverReady = true;
+
+        while (serverReady) {
+            SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+//            System.out.printf("  accept: %s%n", sslSocket);
+            InputStream sslIS = sslSocket.getInputStream();
+            OutputStream sslOS = sslSocket.getOutputStream();
+
+            sslIS.read();
+            sslOS.write(85);
+            sslOS.flush();
+
+            sslSocket.close();
+        }
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    SBListener doClientSide() throws Exception {
+
+        /*
+         * Wait for server to get started.
+         */
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+
+        SSLSocketFactory sslsf =
+            (SSLSocketFactory) SSLSocketFactory.getDefault();
+
+        try {
+                SSLSocket sslSocket = (SSLSocket)
+                    sslsf.createSocket("localhost", serverPort);
+                InputStream sslIS = sslSocket.getInputStream();
+                OutputStream sslOS = sslSocket.getOutputStream();
+
+            sslOS.write(280);
+            sslOS.flush();
+            sslIS.read();
+
+            sslOS.close();
+            sslIS.close();
+
+            SSLSession sslSession = sslSocket.getSession();
+            System.out.printf(" sslSession: %s %n   %s%n", sslSession, sslSession.getClass());
+            SBListener sbListener = new SBListener(sslSession);
+
+            sslSession.putValue("x", sbListener);
+
+            sslSession.invalidate();
+
+            sslSocket.close();
+
+            sslOS = null;
+            sslIS = null;
+            sslSession = null;
+            sslSocket = null;
+            Reference.reachabilityFence(sslOS);
+            Reference.reachabilityFence(sslIS);
+            Reference.reachabilityFence(sslSession);
+            Reference.reachabilityFence(sslSocket);
+
+            return sbListener;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            throw ex;
+        }
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    public static void main(String[] args) throws Exception {
+        String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+        String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
+        /*
+         * Start the tests.
+         */
+        new SSLSessionFinalizeTest();
+    }
+
+    ArrayBlockingQueue<Thread> threads = new ArrayBlockingQueue<Thread>(100);
+
+    ArrayBlockingQueue<SBListener> sbListeners = new ArrayBlockingQueue<>(100);
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    SSLSessionFinalizeTest() throws Exception {
+        final int count = 1;
+        if (separateServerThread) {
+            startServer(true);
+            startClients(true, count);
+        } else {
+            startClients(true, count);
+            startServer(true);
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        Thread t;
+        while ((t = threads.take()) != Thread.currentThread()) {
+            System.out.printf("  joining: %s%n", t);
+            t.join(1000L);
+        }
+        serverReady = false;
+        System.gc();
+        System.gc();
+
+
+        SBListener listener = null;
+        while ((listener = sbListeners.poll()) != null) {
+            if (!listener.check()) {
+                System.out.printf("  sbListener not called on finalize: %s%n",
+                        listener);
+            }
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         *
+         * If the main thread excepted, that propagates back
+         * immediately.  If the other thread threw an exception, we
+         * should report back.
+         */
+        if (serverException != null) {
+            System.out.print("Server Exception:");
+            throw serverException;
+        }
+        if (clientException != null) {
+            System.out.print("Client Exception:");
+            throw clientException;
+        }
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            Thread t = new Thread("Server") {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died..." + e);
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            threads.add(t);
+            t.setDaemon(true);
+            t.start();
+        } else {
+            doServerSide();
+        }
+    }
+
+    void startClients(boolean newThread, int count) throws Exception {
+        for (int i = 0; i < count; i++) {
+            System.out.printf(" newClient: %d%n", i);
+            startClient(newThread);
+        }
+        serverReady = false;
+
+        threads.add(Thread.currentThread());    // add ourselves at the 'end'
+    }
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            Thread t = new Thread("Client") {
+                public void run() {
+                    try {
+                        sbListeners.add(doClientSide());
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died..." + e);
+                        clientException = e;
+                    }
+                }
+            };
+            System.out.printf(" starting: %s%n", t);
+            threads.add(t);
+            t.start();
+        } else {
+            sbListeners.add(doClientSide());
+        }
+    }
+
+
+    static class SBListener implements SSLSessionBindingListener {
+        private volatile int unboundNotified;
+        private final WeakReference<SSLSession> session;
+
+        SBListener(SSLSession session) {
+            this.unboundNotified = 0;
+            this.session = new WeakReference<SSLSession>(session);
+        }
+
+        boolean check() {
+            System.out.printf("  check: %s%n", this);
+            return unboundNotified > 0 && session.get() == null;
+        }
+
+        @Override
+        public void valueBound(SSLSessionBindingEvent event) {
+            System.out.printf(" valueBound: %s%n", event.getName());
+        }
+
+        @Override
+        public void valueUnbound(SSLSessionBindingEvent event) {
+            System.out.printf(" valueUnbound: %s%n", event.getName());
+            unboundNotified++;
+        }
+
+        public String toString() {
+            return "count: " + unboundNotified +
+                    ", ref: " + session.get();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/net/ssl/finalize/security.policy	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,13 @@
+/*
+ * 
+ */
+grant {
+
+    // used by TestLibrary to determine test environment
+    permission java.util.PropertyPermission "test.*", "read";
+    permission java.util.PropertyPermission "user.dir", "read";
+    permission java.util.PropertyPermission "java.home", "read";
+    permission java.util.PropertyPermission "javax.net.ssl.*", "write";
+    permission java.lang.RuntimePermission "accessClassInPackage.sun.security.ssl";
+    permission java.security.AllPermission;
+};
--- a/jdk/test/javax/net/ssl/templates/SSLSocketSample.java	Fri Nov 25 11:16:51 2016 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,404 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// Please run in othervm mode.  SunJSSE does not support dynamic system
-// properties, no way to re-use system properties in samevm/agentvm mode.
-
-/*
- * @test
- * @bug 8161106
- * @summary Improve SSLSocket test template
- * @run main/othervm SSLSocketSample
- */
-
-import java.io.*;
-import javax.net.ssl.*;
-import java.net.*;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Template to help speed your client/server tests.
- */
-public final class SSLSocketSample {
-
-    /*
-     * =============================================================
-     * Set the various variables needed for the tests, then
-     * specify what tests to run on each side.
-     */
-
-    /*
-     * Should we run the client or server in a separate thread?
-     * Both sides can throw exceptions, but do you have a preference
-     * as to which side should be the main thread.
-     */
-    private static final boolean separateServerThread = false;
-
-    /*
-     * Where do we find the keystores?
-     */
-    private static final String pathToStores = "../etc";
-    private static final String keyStoreFile = "keystore";
-    private static final String trustStoreFile = "truststore";
-    private static final String passwd = "passphrase";
-
-    /*
-     * Turn on SSL debugging?
-     */
-    private static final boolean debug = false;
-
-    /*
-     * Is the server ready to serve?
-     */
-    private static final CountDownLatch serverCondition = new CountDownLatch(1);
-
-    /*
-     * Is the client ready to handshake?
-     */
-    private static final CountDownLatch clientCondition = new CountDownLatch(1);
-
-    /*
-     * What's the server port?  Use any free port by default
-     */
-    private volatile int serverPort = 0;
-
-    /*
-     * If the client or server is doing some kind of object creation
-     * that the other side depends on, and that thread prematurely
-     * exits, you may experience a hang.  The test harness will
-     * terminate all hung threads after its timeout has expired,
-     * currently 3 minutes by default, but you might try to be
-     * smart about it....
-     */
-
-    /*
-     * Define the server side of the test.
-     */
-    void doServerSide() throws Exception {
-        SSLServerSocket sslServerSocket;
-
-        // kick start the server side service
-        SSLServerSocketFactory sslssf =
-                (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
-        sslServerSocket =
-                (SSLServerSocket)sslssf.createServerSocket(serverPort);
-
-        serverPort = sslServerSocket.getLocalPort();
-
-        // Signal the client, the server is ready to accept connection.
-        serverCondition.countDown();
-
-
-        // Try to accept a connection in 30 seconds.
-        SSLSocket sslSocket;
-        try {
-            sslServerSocket.setSoTimeout(30000);
-            sslSocket = (SSLSocket)sslServerSocket.accept();
-        } catch (SocketTimeoutException ste) {
-            sslServerSocket.close();
-
-            // Ignore the test case if no connection within 30 seconds.
-            System.out.println(
-                "No incoming client connection in 30 seconds. " +
-                "Ignore in server side.");
-            return;
-        }
-
-        // handle the connection
-        try {
-            // Is it the expected client connection?
-            //
-            // Naughty test cases or third party routines may try to
-            // connection to this server port unintentionally.  In
-            // order to mitigate the impact of unexpected client
-            // connections and avoid intermittent failure, it should
-            // be checked that the accepted connection is really linked
-            // to the expected client.
-            boolean clientIsReady =
-                    clientCondition.await(30L, TimeUnit.SECONDS);
-
-            if (clientIsReady) {
-                // Run the application in server side.
-                runServerApplication(sslSocket);
-            } else {    // Otherwise, ignore
-                // We don't actually care about plain socket connections
-                // for TLS communication testing generally.  Just ignore
-                // the test if the accepted connection is not linked to
-                // the expected client or the client connection timeout
-                // in 30 seconds.
-                System.out.println(
-                        "The client is not the expected one or timeout. " +
-                        "Ignore in server side.");
-            }
-        } finally {
-            sslSocket.close();
-            sslServerSocket.close();
-        }
-    }
-
-    /*
-     * Define the server side application of the test for the specified socket.
-     */
-    void runServerApplication(SSLSocket socket) throws Exception {
-        // here comes the test logic
-        InputStream sslIS = socket.getInputStream();
-        OutputStream sslOS = socket.getOutputStream();
-
-        sslIS.read();
-        sslOS.write(85);
-        sslOS.flush();
-    }
-
-    /*
-     * Define the client side of the test.
-     */
-    void doClientSide() throws Exception {
-
-        // Wait for server to get started.
-        //
-        // The server side takes care of the issue if the server cannot
-        // get started in 90 seconds.  The client side would just ignore
-        // the test case if the serer is not ready.
-        boolean serverIsReady =
-                serverCondition.await(90L, TimeUnit.SECONDS);
-        if (!serverIsReady) {
-            System.out.println(
-                    "The server is not ready yet in 90 seconds. " +
-                    "Ignore in client side.");
-            return;
-        }
-
-        SSLSocketFactory sslsf =
-            (SSLSocketFactory)SSLSocketFactory.getDefault();
-        try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) {
-            try {
-                sslSocket.connect(
-                        new InetSocketAddress("localhost", serverPort), 15000);
-            } catch (IOException ioe) {
-                // The server side may be impacted by naughty test cases or
-                // third party routines, and cannot accept connections.
-                //
-                // Just ignore the test if the connection cannot be
-                // established.
-                System.out.println(
-                        "Cannot make a connection in 15 seconds. " +
-                        "Ignore in client side.");
-                return;
-            }
-
-            // OK, here the client and server get connected.
-
-            // Signal the server, the client is ready to communicate.
-            clientCondition.countDown();
-
-            // There is still a chance in theory that the server thread may
-            // wait client-ready timeout and then quit.  The chance should
-            // be really rare so we don't consider it until it becomes a
-            // real problem.
-
-            // Run the application in client side.
-            runClientApplication(sslSocket);
-        }
-    }
-
-    /*
-     * Define the server side application of the test for the specified socket.
-     */
-    void runClientApplication(SSLSocket socket) throws Exception {
-        InputStream sslIS = socket.getInputStream();
-        OutputStream sslOS = socket.getOutputStream();
-
-        sslOS.write(280);
-        sslOS.flush();
-        sslIS.read();
-    }
-
-    /*
-     * =============================================================
-     * The remainder is just support stuff
-     */
-
-    private volatile Exception serverException = null;
-    private volatile Exception clientException = null;
-
-    public static void main(String[] args) throws Exception {
-        String keyFilename =
-            System.getProperty("test.src", ".") + "/" + pathToStores +
-                "/" + keyStoreFile;
-        String trustFilename =
-            System.getProperty("test.src", ".") + "/" + pathToStores +
-                "/" + trustStoreFile;
-
-        System.setProperty("javax.net.ssl.keyStore", keyFilename);
-        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
-        System.setProperty("javax.net.ssl.trustStore", trustFilename);
-        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
-
-        if (debug) {
-            System.setProperty("javax.net.debug", "all");
-        }
-
-        /*
-         * Start the tests.
-         */
-        new SSLSocketSample();
-    }
-
-    private Thread clientThread = null;
-    private Thread serverThread = null;
-
-    /*
-     * Primary constructor, used to drive remainder of the test.
-     *
-     * Fork off the other side, then do your work.
-     */
-    SSLSocketSample() throws Exception {
-        Exception startException = null;
-        try {
-            if (separateServerThread) {
-                startServer(true);
-                startClient(false);
-            } else {
-                startClient(true);
-                startServer(false);
-            }
-        } catch (Exception e) {
-            startException = e;
-        }
-
-        /*
-         * Wait for other side to close down.
-         */
-        if (separateServerThread) {
-            if (serverThread != null) {
-                serverThread.join();
-            }
-        } else {
-            if (clientThread != null) {
-                clientThread.join();
-            }
-        }
-
-        /*
-         * When we get here, the test is pretty much over.
-         * Which side threw the error?
-         */
-        Exception local;
-        Exception remote;
-
-        if (separateServerThread) {
-            remote = serverException;
-            local = clientException;
-        } else {
-            remote = clientException;
-            local = serverException;
-        }
-
-        Exception exception = null;
-
-        /*
-         * Check various exception conditions.
-         */
-        if ((local != null) && (remote != null)) {
-            // If both failed, return the curthread's exception.
-            local.initCause(remote);
-            exception = local;
-        } else if (local != null) {
-            exception = local;
-        } else if (remote != null) {
-            exception = remote;
-        } else if (startException != null) {
-            exception = startException;
-        }
-
-        /*
-         * If there was an exception *AND* a startException,
-         * output it.
-         */
-        if (exception != null) {
-            if (exception != startException && startException != null) {
-                exception.addSuppressed(startException);
-            }
-            throw exception;
-        }
-
-        // Fall-through: no exception to throw!
-    }
-
-    void startServer(boolean newThread) throws Exception {
-        if (newThread) {
-            serverThread = new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        doServerSide();
-                    } catch (Exception e) {
-                        /*
-                         * Our server thread just died.
-                         *
-                         * Release the client, if not active already...
-                         */
-                        System.out.println("Server died: " + e);
-                        serverException = e;
-                    }
-                }
-            };
-            serverThread.start();
-        } else {
-            try {
-                doServerSide();
-            } catch (Exception e) {
-                System.out.println("Server failed: " + e);
-                serverException = e;
-            }
-        }
-    }
-
-    void startClient(boolean newThread) throws Exception {
-        if (newThread) {
-            clientThread = new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        doClientSide();
-                    } catch (Exception e) {
-                        /*
-                         * Our client thread just died.
-                         */
-                        System.out.println("Client died: " + e);
-                        clientException = e;
-                    }
-                }
-            };
-            clientThread.start();
-        } else {
-            try {
-                doClientSide();
-            } catch (Exception e) {
-                System.out.println("Client failed: " + e);
-                clientException = e;
-            }
-        }
-    }
-}
--- a/jdk/test/javax/net/ssl/templates/SSLSocketTemplate.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/javax/net/ssl/templates/SSLSocketTemplate.java	Wed Jul 05 22:30:23 2017 +0200
@@ -21,251 +21,561 @@
  * questions.
  */
 
-// SunJSSE does not support dynamic system properties, no way to re-use
-// system properties in samevm/agentvm mode.
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.SocketTimeoutException;
+import java.security.KeyStore;
+import java.security.Security;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+/**
+ * This class defines a framework for JSSE tests.
+ *
+ * Please run in othervm mode.  SunJSSE does not support dynamic system
+ * properties, no way to re-use system properties in samevm/agentvm mode.
+ */
 
 /*
  * @test
  * @bug 1234567
- * @summary Use this template to help speed your client/server tests.
+ * @summary Use this class for JSSE tests
  * @run main/othervm SSLSocketTemplate
  * @author Brad Wetmore
  */
 
-import java.io.*;
-import javax.net.ssl.*;
-
 public class SSLSocketTemplate {
 
+    public static final String TEST_SRC = System.getProperty("test.src", ".");
+
     /*
-     * =============================================================
-     * Set the various variables needed for the tests, then
-     * specify what tests to run on each side.
+     * Where do we find the keystores?
      */
+    public static final String PATH_TO_STORES = "../etc";
+    public static final String KEY_STORE_FILE = "keystore";
+    public static final String TRUST_STORE_FILE = "truststore";
+    public static final String PASSWORD = "passphrase";
+
+    public static final int FREE_PORT = 0;
+
+    // in seconds
+    public static final long CLIENT_SIGNAL_TIMEOUT = 30L;
+    public static final long SERVER_SIGNAL_TIMEOUT = 90L;
+
+    // in millis
+    public static final int CLIENT_TIMEOUT = 15000;
+    public static final int SERVER_TIMEOUT = 30000;
 
     /*
      * Should we run the client or server in a separate thread?
      * Both sides can throw exceptions, but do you have a preference
      * as to which side should be the main thread.
      */
-    static boolean separateServerThread = false;
+    private boolean separateServerThread = false;
 
     /*
-     * Where do we find the keystores?
+     * What's the server port?  Use any free port by default
      */
-    static String pathToStores = "../etc";
-    static String keyStoreFile = "keystore";
-    static String trustStoreFile = "truststore";
-    static String passwd = "passphrase";
+    private volatile int serverPort;
+
+    private volatile Exception serverException;
+    private volatile Exception clientException;
+
+    private Thread clientThread;
+    private Thread serverThread;
+
+    private Peer serverPeer;
+    private Peer clientPeer;
+
+    private Application serverApplication;
+    private Application clientApplication;
+
+    private SSLContext context;
 
     /*
      * Is the server ready to serve?
      */
-    volatile static boolean serverReady = false;
+    private final CountDownLatch serverReadyCondition = new CountDownLatch(1);
+
+    /*
+     * Is the client ready to handshake?
+     */
+    private final CountDownLatch clientReadyCondition = new CountDownLatch(1);
+
+    /*
+     * Is the server done?
+     */
+    private final CountDownLatch serverDoneCondition = new CountDownLatch(1);
+
+    /*
+     * Is the client done?
+     */
+    private final CountDownLatch clientDoneCondition = new CountDownLatch(1);
 
     /*
-     * Turn on SSL debugging?
+     * Public API.
      */
-    static boolean debug = false;
+
+    public static interface Peer {
+        void run(SSLSocketTemplate test) throws Exception;
+    }
+
+    public static interface Application {
+        void run(SSLSocket socket, SSLSocketTemplate test) throws Exception;
+    }
+
+    public static void debug() {
+        debug("ssl");
+    }
+
+    public static void debug(String mode) {
+        System.setProperty("javax.net.debug", mode);
+    }
+
+    public static void setup(String keyFilename, String trustFilename,
+            String password) {
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", password);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", password);
+    }
+
+    public static void setup() throws Exception {
+        String keyFilename = TEST_SRC + "/" + PATH_TO_STORES + "/"
+                + KEY_STORE_FILE;
+        String trustFilename = TEST_SRC + "/" + PATH_TO_STORES + "/"
+                + TRUST_STORE_FILE;
+
+        setup(keyFilename, trustFilename, PASSWORD);
+    }
+
+    public static void print(String message, Throwable... errors) {
+        synchronized (System.out) {
+            System.out.println(message);
+            for (Throwable e : errors) {
+                e.printStackTrace(System.out);
+            }
+        }
+    }
+
+    public static KeyStore loadJksKeyStore(String filename, String password)
+            throws Exception {
+
+        return loadKeyStore(filename, password, "JKS");
+    }
+
+    public static KeyStore loadKeyStore(String filename, String password,
+            String type) throws Exception {
+
+        KeyStore keystore = KeyStore.getInstance(type);
+        FileInputStream fis = new FileInputStream(filename);
+        try {
+            keystore.load(fis, password.toCharArray());
+        } finally {
+            fis.close();
+        }
+        return keystore;
+    }
+
+    // Try to accept a connection in 30 seconds.
+    public static SSLSocket accept(SSLServerSocket sslServerSocket)
+            throws IOException {
+
+        return accept(sslServerSocket, SERVER_TIMEOUT);
+    }
+
+    public static SSLSocket accept(SSLServerSocket sslServerSocket, int timeout)
+            throws IOException {
+
+        try {
+            sslServerSocket.setSoTimeout(timeout);
+            return (SSLSocket) sslServerSocket.accept();
+        } catch (SocketTimeoutException ste) {
+            print("Warning: ", ste);
+            return null;
+        }
+    }
+
+    public SSLSocketTemplate setSeparateServerThread(
+            boolean separateServerThread) {
+
+        this.separateServerThread = separateServerThread;
+        return this;
+    }
+
+    public SSLSocketTemplate setServerPort(int serverPort) {
+        this.serverPort = serverPort;
+        return this;
+    }
+
+    public int getServerPort() {
+        return serverPort;
+    }
+
+    public SSLSocketTemplate setSSLContext(SSLContext context) {
+        this.context = context;
+        return this;
+    }
+
+    public SSLContext getSSLContext() {
+        return context;
+    }
+
+    public SSLServerSocketFactory getSSLServerSocketFactory() {
+        if (context != null) {
+            return context.getServerSocketFactory();
+        }
+
+        return (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+    }
+
+    public SSLSocketFactory getSSLSocketFactory() {
+        if (context != null) {
+            return context.getSocketFactory();
+        }
+
+        return (SSLSocketFactory) SSLSocketFactory.getDefault();
+    }
+
+    public void signalServerReady() {
+        serverReadyCondition.countDown();
+    }
+
+    public void signalServerDone() {
+        serverDoneCondition.countDown();
+    }
+
+    public boolean waitForClientSignal(long timeout, TimeUnit unit)
+            throws InterruptedException {
+
+        return clientReadyCondition.await(timeout, unit);
+    }
+
+    public boolean waitForClientSignal() throws InterruptedException {
+        return waitForClientSignal(CLIENT_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
+    }
+
+    public boolean waitForClientDone(long timeout, TimeUnit unit)
+            throws InterruptedException {
+
+        return clientDoneCondition.await(timeout, unit);
+    }
+
+    public boolean waitForClientDone() throws InterruptedException {
+        return waitForClientDone(CLIENT_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
+    }
+
+    public void signalClientReady() {
+        clientReadyCondition.countDown();
+    }
+
+    public void signalClientDone() {
+        clientDoneCondition.countDown();
+    }
+
+    public boolean waitForServerSignal(long timeout, TimeUnit unit)
+            throws InterruptedException {
+
+        return serverReadyCondition.await(timeout, unit);
+    }
+
+    public boolean waitForServerSignal() throws InterruptedException {
+        return waitForServerSignal(SERVER_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
+    }
+
+    public boolean waitForServerDone(long timeout, TimeUnit unit)
+            throws InterruptedException {
+
+        return serverDoneCondition.await(timeout, unit);
+    }
+
+    public boolean waitForServerDone() throws InterruptedException {
+        return waitForServerDone(SERVER_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
+    }
+
+    public SSLSocketTemplate setServerPeer(Peer serverPeer) {
+        this.serverPeer = serverPeer;
+        return this;
+    }
+
+    public Peer getServerPeer() {
+        return serverPeer;
+    }
+
+    public SSLSocketTemplate setServerApplication(
+            Application serverApplication) {
+
+        this.serverApplication = serverApplication;
+        return this;
+    }
+
+    public Application getServerApplication() {
+        return serverApplication;
+    }
+
+    public SSLSocketTemplate setClientPeer(Peer clientPeer) {
+        this.clientPeer = clientPeer;
+        return this;
+    }
+
+    public Peer getClientPeer() {
+        return clientPeer;
+    }
+
+    public SSLSocketTemplate setClientApplication(
+            Application clientApplication) {
+
+        this.clientApplication = clientApplication;
+        return this;
+    }
+
+    public Application getClientApplication() {
+        return clientApplication;
+    }
+
+    public void runTest() throws Exception {
+        if (separateServerThread) {
+            startServer(true, this);
+            startClient(false, this);
+            serverThread.join();
+        } else {
+            startClient(true, this);
+            startServer(false, this);
+            clientThread.join();
+        }
+
+        if (clientException != null || serverException != null) {
+            throw new RuntimeException("Test failed");
+        }
+    }
+
+    public SSLSocketTemplate() {
+        serverPeer = new Peer() {
+
+            @Override
+            public void run(SSLSocketTemplate test) throws Exception {
+                doServerSide(test);
+            }
+        };
+
+        clientPeer = new Peer() {
+
+            @Override
+            public void run(SSLSocketTemplate test) throws Exception {
+                doClientSide(test);
+            }
+        };
+
+        serverApplication = new Application() {
+
+            @Override
+            public void run(SSLSocket socket, SSLSocketTemplate test)
+                    throws Exception {
+
+                runServerApplication(socket);
+            }
+
+        };
+
+        clientApplication = new Application() {
+
+            @Override
+            public void run(SSLSocket socket, SSLSocketTemplate test)
+                    throws Exception {
+
+                runClientApplication(socket);
+            }
+        };
+    }
+
+    public static void main(String args[]) throws Exception {
+        // reset the security property to make sure that the algorithms
+        // and keys used in this test are not disabled.
+        Security.setProperty("jdk.tls.disabledAlgorithms", "");
+
+        // MD5 is used in this test case, don't disable MD5 algorithm.
+        Security.setProperty(
+                "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");
+
+        setup();
+
+        new SSLSocketTemplate().runTest();
+    }
 
     /*
-     * If the client or server is doing some kind of object creation
-     * that the other side depends on, and that thread prematurely
-     * exits, you may experience a hang.  The test harness will
-     * terminate all hung threads after its timeout has expired,
-     * currently 3 minutes by default, but you might try to be
-     * smart about it....
+     * Private part.
      */
 
     /*
      * Define the server side of the test.
-     *
-     * If the server prematurely exits, serverReady will be set to true
-     * to avoid infinite hangs.
      */
-    void doServerSide() throws Exception {
-        SSLServerSocketFactory sslssf =
-            (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
-        try (SSLServerSocket sslServerSocket =
-                (SSLServerSocket)sslssf.createServerSocket(serverPort)) {
+    private static void doServerSide(SSLSocketTemplate test) throws Exception {
+        SSLServerSocket sslServerSocket;
+
+        // kick start the server side service
+        SSLServerSocketFactory sslssf = test.getSSLServerSocketFactory();
+        sslServerSocket = (SSLServerSocket)sslssf.createServerSocket(FREE_PORT);
+
+        test.setServerPort(sslServerSocket.getLocalPort());
+        print("Server is listening on port " + test.getServerPort());
 
-            serverPort = sslServerSocket.getLocalPort();
+        // Signal the client, the server is ready to accept connection.
+        test.signalServerReady();
+
+        // Try to accept a connection in 30 seconds.
+        SSLSocket sslSocket = accept(sslServerSocket);
+        if (sslSocket == null) {
+            // Ignore the test case if no connection within 30 seconds.
+            print("No incoming client connection in 30 seconds. "
+                    + "Ignore in server side.");
+            return;
+        }
+        print("Server accepted connection");
 
-            /*
-             * Signal Client, we're ready for his connect.
-             */
-            serverReady = true;
+        // handle the connection
+        try {
+            // Is it the expected client connection?
+            //
+            // Naughty test cases or third party routines may try to
+            // connection to this server port unintentionally.  In
+            // order to mitigate the impact of unexpected client
+            // connections and avoid intermittent failure, it should
+            // be checked that the accepted connection is really linked
+            // to the expected client.
+            boolean clientIsReady = test.waitForClientSignal();
 
-            try (SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept()) {
-                InputStream sslIS = sslSocket.getInputStream();
-                OutputStream sslOS = sslSocket.getOutputStream();
+            if (clientIsReady) {
+                // Run the application in server side.
+                print("Run server application");
+                test.getServerApplication().run(sslSocket, test);
+            } else {    // Otherwise, ignore
+                // We don't actually care about plain socket connections
+                // for TLS communication testing generally.  Just ignore
+                // the test if the accepted connection is not linked to
+                // the expected client or the client connection timeout
+                // in 30 seconds.
+                print("The client is not the expected one or timeout. "
+                        + "Ignore in server side.");
+            }
+        } finally {
+            sslSocket.close();
+            sslServerSocket.close();
+        }
 
-                sslIS.read();
-                sslOS.write(85);
-                sslOS.flush();
-            }
-        }
+        test.signalServerDone();
+    }
+
+    /*
+     * Define the server side application of the test for the specified socket.
+     */
+    private static void runServerApplication(SSLSocket socket)
+            throws Exception {
+
+        // here comes the test logic
+        InputStream sslIS = socket.getInputStream();
+        OutputStream sslOS = socket.getOutputStream();
+
+        sslIS.read();
+        sslOS.write(85);
+        sslOS.flush();
     }
 
     /*
      * Define the client side of the test.
-     *
-     * If the server prematurely exits, serverReady will be set to true
-     * to avoid infinite hangs.
      */
-    void doClientSide() throws Exception {
+    private static void doClientSide(SSLSocketTemplate test) throws Exception {
 
-        /*
-         * Wait for server to get started.
-         */
-        while (!serverReady) {
-            Thread.sleep(50);
+        // Wait for server to get started.
+        //
+        // The server side takes care of the issue if the server cannot
+        // get started in 90 seconds.  The client side would just ignore
+        // the test case if the serer is not ready.
+        boolean serverIsReady = test.waitForServerSignal();
+        if (!serverIsReady) {
+            print("The server is not ready yet in 90 seconds. "
+                    + "Ignore in client side.");
+            return;
         }
 
-        SSLSocketFactory sslsf =
-            (SSLSocketFactory)SSLSocketFactory.getDefault();
-        try (SSLSocket sslSocket =
-                (SSLSocket)sslsf.createSocket("localhost", serverPort)) {
+        SSLSocketFactory sslsf = test.getSSLSocketFactory();
+        SSLSocket sslSocket = (SSLSocket)sslsf.createSocket();
+        try {
+            try {
+                sslSocket.connect(
+                        new InetSocketAddress("localhost",
+                                test.getServerPort()), CLIENT_TIMEOUT);
+                print("Client connected to server");
+            } catch (IOException ioe) {
+                // The server side may be impacted by naughty test cases or
+                // third party routines, and cannot accept connections.
+                //
+                // Just ignore the test if the connection cannot be
+                // established.
+                print("Cannot make a connection in 15 seconds. "
+                        + "Ignore in client side.", ioe);
+                return;
+            }
 
-            InputStream sslIS = sslSocket.getInputStream();
-            OutputStream sslOS = sslSocket.getOutputStream();
+            // OK, here the client and server get connected.
+
+            // Signal the server, the client is ready to communicate.
+            test.signalClientReady();
 
-            sslOS.write(280);
-            sslOS.flush();
-            sslIS.read();
+            // There is still a chance in theory that the server thread may
+            // wait client-ready timeout and then quit.  The chance should
+            // be really rare so we don't consider it until it becomes a
+            // real problem.
+
+            // Run the application in client side.
+            print("Run client application");
+            test.getClientApplication().run(sslSocket, test);
+        } finally {
+            sslSocket.close();
         }
+
+        test.signalClientDone();
     }
 
     /*
-     * =============================================================
-     * The remainder is just support stuff
+     * Define the client side application of the test for the specified socket.
      */
-
-    // use any free port by default
-    volatile int serverPort = 0;
-
-    volatile Exception serverException = null;
-    volatile Exception clientException = null;
+    private static void runClientApplication(SSLSocket socket)
+            throws Exception {
 
-    public static void main(String[] args) throws Exception {
-        String keyFilename =
-            System.getProperty("test.src", ".") + "/" + pathToStores +
-                "/" + keyStoreFile;
-        String trustFilename =
-            System.getProperty("test.src", ".") + "/" + pathToStores +
-                "/" + trustStoreFile;
+        InputStream sslIS = socket.getInputStream();
+        OutputStream sslOS = socket.getOutputStream();
 
-        System.setProperty("javax.net.ssl.keyStore", keyFilename);
-        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
-        System.setProperty("javax.net.ssl.trustStore", trustFilename);
-        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
-
-        if (debug) {
-            System.setProperty("javax.net.debug", "all");
-        }
-
-        /*
-         * Start the tests.
-         */
-        new SSLSocketTemplate();
+        sslOS.write(280);
+        sslOS.flush();
+        sslIS.read();
     }
 
-    Thread clientThread = null;
-    Thread serverThread = null;
-
-    /*
-     * Primary constructor, used to drive remainder of the test.
-     *
-     * Fork off the other side, then do your work.
-     */
-    SSLSocketTemplate() throws Exception {
-        Exception startException = null;
-        try {
-            if (separateServerThread) {
-                startServer(true);
-                startClient(false);
-            } else {
-                startClient(true);
-                startServer(false);
-            }
-        } catch (Exception e) {
-            startException = e;
-        }
-
-        /*
-         * Wait for other side to close down.
-         */
-        if (separateServerThread) {
-            if (serverThread != null) {
-                serverThread.join();
-            }
-        } else {
-            if (clientThread != null) {
-                clientThread.join();
-            }
-        }
+    private void startServer(boolean newThread, SSLSocketTemplate test)
+            throws Exception {
 
-        /*
-         * When we get here, the test is pretty much over.
-         * Which side threw the error?
-         */
-        Exception local;
-        Exception remote;
-
-        if (separateServerThread) {
-            remote = serverException;
-            local = clientException;
-        } else {
-            remote = clientException;
-            local = serverException;
-        }
-
-        Exception exception = null;
-
-        /*
-         * Check various exception conditions.
-         */
-        if ((local != null) && (remote != null)) {
-            // If both failed, return the curthread's exception.
-            local.initCause(remote);
-            exception = local;
-        } else if (local != null) {
-            exception = local;
-        } else if (remote != null) {
-            exception = remote;
-        } else if (startException != null) {
-            exception = startException;
-        }
-
-        /*
-         * If there was an exception *AND* a startException,
-         * output it.
-         */
-        if (exception != null) {
-            if (exception != startException && startException != null) {
-                exception.addSuppressed(startException);
-            }
-            throw exception;
-        }
-
-        // Fall-through: no exception to throw!
-    }
-
-    void startServer(boolean newThread) throws Exception {
         if (newThread) {
             serverThread = new Thread() {
+
                 @Override
                 public void run() {
                     try {
-                        doServerSide();
+                        serverPeer.run(test);
                     } catch (Exception e) {
                         /*
                          * Our server thread just died.
                          *
                          * Release the client, if not active already...
                          */
-                        System.err.println("Server died...");
-                        serverReady = true;
+                        print("Server died ...", e);
                         serverException = e;
                     }
                 }
@@ -273,27 +583,29 @@
             serverThread.start();
         } else {
             try {
-                doServerSide();
+                serverPeer.run(test);
             } catch (Exception e) {
+                print("Server failed ...", e);
                 serverException = e;
-            } finally {
-                serverReady = true;
             }
         }
     }
 
-    void startClient(boolean newThread) throws Exception {
+    private void startClient(boolean newThread, SSLSocketTemplate test)
+            throws Exception {
+
         if (newThread) {
             clientThread = new Thread() {
+
                 @Override
                 public void run() {
                     try {
-                        doClientSide();
+                        clientPeer.run(test);
                     } catch (Exception e) {
                         /*
                          * Our client thread just died.
                          */
-                        System.err.println("Client died...");
+                        print("Client died ...", e);
                         clientException = e;
                     }
                 }
@@ -301,8 +613,9 @@
             clientThread.start();
         } else {
             try {
-                doClientSide();
+                clientPeer.run(test);
             } catch (Exception e) {
+                print("Client failed ...", e);
                 clientException = e;
             }
         }
--- a/jdk/test/javax/net/ssl/templates/SSLTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,549 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.net.SocketTimeoutException;
-import java.security.KeyStore;
-import java.util.Arrays;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLServerSocket;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-
-/**
- * Helper class for JSSE tests.
- *
- * Please run in othervm mode.  SunJSSE does not support dynamic system
- * properties, no way to re-use system properties in samevm/agentvm mode.
- */
-public class SSLTest {
-
-    public static final String TEST_SRC = System.getProperty("test.src", ".");
-
-    /*
-     * Where do we find the keystores?
-     */
-    public static final String PATH_TO_STORES = "../etc";
-    public static final String KEY_STORE_FILE = "keystore";
-    public static final String TRUST_STORE_FILE = "truststore";
-    public static final String PASSWORD = "passphrase";
-
-    public static final int FREE_PORT = 0;
-
-    // in seconds
-    public static final long CLIENT_SIGNAL_TIMEOUT = 30L;
-    public static final long SERVER_SIGNAL_TIMEOUT = 90L;
-
-    // in millis
-    public static final int CLIENT_TIMEOUT = 15000;
-    public static final int SERVER_TIMEOUT = 30000;
-
-    /*
-     * Should we run the client or server in a separate thread?
-     * Both sides can throw exceptions, but do you have a preference
-     * as to which side should be the main thread.
-     */
-    private boolean separateServerThread = false;
-
-    /*
-     * What's the server port?  Use any free port by default
-     */
-    private volatile int serverPort;
-
-    private volatile Exception serverException;
-    private volatile Exception clientException;
-
-    private Thread clientThread;
-    private Thread serverThread;
-
-    private Peer serverPeer;
-    private Peer clientPeer;
-
-    private Application serverApplication;
-    private Application clientApplication;
-
-    private SSLContext context;
-
-    /*
-     * Is the server ready to serve?
-     */
-    private final CountDownLatch serverReadyCondition = new CountDownLatch(1);
-
-    /*
-     * Is the client ready to handshake?
-     */
-    private final CountDownLatch clientReadyCondition = new CountDownLatch(1);
-
-    /*
-     * Is the server done?
-     */
-    private final CountDownLatch serverDoneCondition = new CountDownLatch(1);
-
-    /*
-     * Is the client done?
-     */
-    private final CountDownLatch clientDoneCondition = new CountDownLatch(1);
-
-    /*
-     * Public API.
-     */
-
-    public static interface Peer {
-        void run(SSLTest test) throws Exception;
-    }
-
-    public static interface Application {
-        void run(SSLSocket socket, SSLTest test) throws Exception;
-    }
-
-    public static void debug() {
-        debug("ssl");
-    }
-
-    public static void debug(String mode) {
-        System.setProperty("javax.net.debug", mode);
-    }
-
-    public static void setup(String keyFilename, String trustFilename,
-            String password) {
-
-        System.setProperty("javax.net.ssl.keyStore", keyFilename);
-        System.setProperty("javax.net.ssl.keyStorePassword", password);
-        System.setProperty("javax.net.ssl.trustStore", trustFilename);
-        System.setProperty("javax.net.ssl.trustStorePassword", password);
-    }
-
-    public static void setup() throws Exception {
-        String keyFilename = TEST_SRC + "/" + PATH_TO_STORES + "/"
-                + KEY_STORE_FILE;
-        String trustFilename = TEST_SRC + "/" + PATH_TO_STORES + "/"
-                + TRUST_STORE_FILE;
-
-        setup(keyFilename, trustFilename, PASSWORD);
-    }
-
-    public static void print(String message, Throwable... errors) {
-        synchronized (System.out) {
-            System.out.println(message);
-            Arrays.stream(errors).forEach(e -> e.printStackTrace(System.out));
-        }
-    }
-
-    public static KeyStore loadJksKeyStore(String filename, String password)
-            throws Exception {
-
-        return loadKeyStore(filename, password, "JKS");
-    }
-
-    public static KeyStore loadKeyStore(String filename, String password,
-            String type) throws Exception {
-
-        KeyStore keystore = KeyStore.getInstance(type);
-        try (FileInputStream fis = new FileInputStream(filename)) {
-            keystore.load(fis, password.toCharArray());
-        }
-        return keystore;
-    }
-
-    // Try to accept a connection in 30 seconds.
-    public static SSLSocket accept(SSLServerSocket sslServerSocket)
-            throws IOException {
-
-        return accept(sslServerSocket, SERVER_TIMEOUT);
-    }
-
-    public static SSLSocket accept(SSLServerSocket sslServerSocket, int timeout)
-            throws IOException {
-
-        try {
-            sslServerSocket.setSoTimeout(timeout);
-            return (SSLSocket) sslServerSocket.accept();
-        } catch (SocketTimeoutException ste) {
-            sslServerSocket.close();
-            return null;
-        }
-    }
-
-    public SSLTest setSeparateServerThread(boolean separateServerThread) {
-        this.separateServerThread = separateServerThread;
-        return this;
-    }
-
-    public SSLTest setServerPort(int serverPort) {
-        this.serverPort = serverPort;
-        return this;
-    }
-
-    public int getServerPort() {
-        return serverPort;
-    }
-
-    public SSLTest setSSLContext(SSLContext context) {
-        this.context = context;
-        return this;
-    }
-
-    public SSLContext getSSLContext() {
-        return context;
-    }
-
-    public SSLServerSocketFactory getSSLServerSocketFactory() {
-        if (context != null) {
-            return context.getServerSocketFactory();
-        }
-
-        return (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
-    }
-
-    public SSLSocketFactory getSSLSocketFactory() {
-        if (context != null) {
-            return context.getSocketFactory();
-        }
-
-        return (SSLSocketFactory) SSLSocketFactory.getDefault();
-    }
-
-    public void signalServerReady() {
-        serverReadyCondition.countDown();
-    }
-
-    public void signalServerDone() {
-        serverDoneCondition.countDown();
-    }
-
-    public boolean waitForClientSignal(long timeout, TimeUnit unit)
-            throws InterruptedException {
-
-        return clientReadyCondition.await(timeout, unit);
-    }
-
-    public boolean waitForClientSignal() throws InterruptedException {
-        return waitForClientSignal(CLIENT_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
-    }
-
-    public boolean waitForClientDone(long timeout, TimeUnit unit)
-            throws InterruptedException {
-
-        return clientDoneCondition.await(timeout, unit);
-    }
-
-    public boolean waitForClientDone() throws InterruptedException {
-        return waitForClientDone(CLIENT_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
-    }
-
-    public void signalClientReady() {
-        clientReadyCondition.countDown();
-    }
-
-    public void signalClientDone() {
-        clientDoneCondition.countDown();
-    }
-
-    public boolean waitForServerSignal(long timeout, TimeUnit unit)
-            throws InterruptedException {
-
-        return serverReadyCondition.await(timeout, unit);
-    }
-
-    public boolean waitForServerSignal() throws InterruptedException {
-        return waitForServerSignal(SERVER_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
-    }
-
-    public boolean waitForServerDone(long timeout, TimeUnit unit)
-            throws InterruptedException {
-
-        return serverDoneCondition.await(timeout, unit);
-    }
-
-    public boolean waitForServerDone() throws InterruptedException {
-        return waitForServerDone(SERVER_SIGNAL_TIMEOUT, TimeUnit.SECONDS);
-    }
-
-    public SSLTest setServerPeer(Peer serverPeer) {
-        this.serverPeer = serverPeer;
-        return this;
-    }
-
-    public Peer getServerPeer() {
-        return serverPeer;
-    }
-
-    public SSLTest setServerApplication(Application serverApplication) {
-        this.serverApplication = serverApplication;
-        return this;
-    }
-
-    public Application getServerApplication() {
-        return serverApplication;
-    }
-
-    public SSLTest setClientPeer(Peer clientPeer) {
-        this.clientPeer = clientPeer;
-        return this;
-    }
-
-    public Peer getClientPeer() {
-        return clientPeer;
-    }
-
-    public SSLTest setClientApplication(Application clientApplication) {
-        this.clientApplication = clientApplication;
-        return this;
-    }
-
-    public Application getClientApplication() {
-        return clientApplication;
-    }
-
-    public void runTest() throws Exception {
-        if (separateServerThread) {
-            startServer(true, this);
-            startClient(false, this);
-            serverThread.join();
-        } else {
-            startClient(true, this);
-            startServer(false, this);
-            clientThread.join();
-        }
-
-        if (clientException != null || serverException != null) {
-            throw new RuntimeException("Test failed");
-        }
-    }
-
-    public SSLTest() {
-        serverPeer = (test) -> doServerSide(test);
-        clientPeer = (test) -> doClientSide(test);
-        serverApplication = (socket, test) -> runServerApplication(socket);
-        clientApplication = (socket, test) -> runClientApplication(socket);
-    }
-
-    /*
-     * Private part.
-     */
-
-
-    /*
-     * Define the server side of the test.
-     */
-    private static void doServerSide(SSLTest test) throws Exception {
-        SSLServerSocket sslServerSocket;
-
-        // kick start the server side service
-        SSLServerSocketFactory sslssf = test.getSSLServerSocketFactory();
-        sslServerSocket = (SSLServerSocket)sslssf.createServerSocket(FREE_PORT);
-
-        test.setServerPort(sslServerSocket.getLocalPort());
-        print("Server is listening on port " + test.getServerPort());
-
-        // Signal the client, the server is ready to accept connection.
-        test.signalServerReady();
-
-        // Try to accept a connection in 30 seconds.
-        SSLSocket sslSocket = accept(sslServerSocket);
-        if (sslSocket == null) {
-            // Ignore the test case if no connection within 30 seconds.
-            print("No incoming client connection in 30 seconds. "
-                    + "Ignore in server side.");
-            return;
-        }
-        print("Server accepted connection");
-
-        // handle the connection
-        try {
-            // Is it the expected client connection?
-            //
-            // Naughty test cases or third party routines may try to
-            // connection to this server port unintentionally.  In
-            // order to mitigate the impact of unexpected client
-            // connections and avoid intermittent failure, it should
-            // be checked that the accepted connection is really linked
-            // to the expected client.
-            boolean clientIsReady = test.waitForClientSignal();
-
-            if (clientIsReady) {
-                // Run the application in server side.
-                print("Run server application");
-                test.getServerApplication().run(sslSocket, test);
-            } else {    // Otherwise, ignore
-                // We don't actually care about plain socket connections
-                // for TLS communication testing generally.  Just ignore
-                // the test if the accepted connection is not linked to
-                // the expected client or the client connection timeout
-                // in 30 seconds.
-                print("The client is not the expected one or timeout. "
-                        + "Ignore in server side.");
-            }
-        } finally {
-            sslSocket.close();
-            sslServerSocket.close();
-        }
-
-        test.signalServerDone();
-    }
-
-    /*
-     * Define the server side application of the test for the specified socket.
-     */
-    private static void runServerApplication(SSLSocket socket)
-            throws Exception {
-
-        // here comes the test logic
-        InputStream sslIS = socket.getInputStream();
-        OutputStream sslOS = socket.getOutputStream();
-
-        sslIS.read();
-        sslOS.write(85);
-        sslOS.flush();
-    }
-
-    /*
-     * Define the client side of the test.
-     */
-    private static void doClientSide(SSLTest test) throws Exception {
-
-        // Wait for server to get started.
-        //
-        // The server side takes care of the issue if the server cannot
-        // get started in 90 seconds.  The client side would just ignore
-        // the test case if the serer is not ready.
-        boolean serverIsReady = test.waitForServerSignal();
-        if (!serverIsReady) {
-            print("The server is not ready yet in 90 seconds. "
-                    + "Ignore in client side.");
-            return;
-        }
-
-        SSLSocketFactory sslsf = test.getSSLSocketFactory();
-        try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) {
-            try {
-                sslSocket.connect(
-                        new InetSocketAddress("localhost",
-                                test.getServerPort()), CLIENT_TIMEOUT);
-                print("Client connected to server");
-            } catch (IOException ioe) {
-                // The server side may be impacted by naughty test cases or
-                // third party routines, and cannot accept connections.
-                //
-                // Just ignore the test if the connection cannot be
-                // established.
-                print("Cannot make a connection in 15 seconds. "
-                        + "Ignore in client side.", ioe);
-                return;
-            }
-
-            // OK, here the client and server get connected.
-
-            // Signal the server, the client is ready to communicate.
-            test.signalClientReady();
-
-            // There is still a chance in theory that the server thread may
-            // wait client-ready timeout and then quit.  The chance should
-            // be really rare so we don't consider it until it becomes a
-            // real problem.
-
-            // Run the application in client side.
-            print("Run client application");
-            test.getClientApplication().run(sslSocket, test);
-        }
-
-        test.signalClientDone();
-    }
-
-    /*
-     * Define the client side application of the test for the specified socket.
-     */
-    private static void runClientApplication(SSLSocket socket)
-            throws Exception {
-
-        InputStream sslIS = socket.getInputStream();
-        OutputStream sslOS = socket.getOutputStream();
-
-        sslOS.write(280);
-        sslOS.flush();
-        sslIS.read();
-    }
-
-    private void startServer(boolean newThread, SSLTest test) throws Exception {
-        if (newThread) {
-            serverThread = new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        serverPeer.run(test);
-                    } catch (Exception e) {
-                        /*
-                         * Our server thread just died.
-                         *
-                         * Release the client, if not active already...
-                         */
-                        print("Server died ...", e);
-                        serverException = e;
-                    }
-                }
-            };
-            serverThread.start();
-        } else {
-            try {
-                serverPeer.run(test);
-            } catch (Exception e) {
-                print("Server failed ...", e);
-                serverException = e;
-            }
-        }
-    }
-
-    private void startClient(boolean newThread, SSLTest test) throws Exception {
-        if (newThread) {
-            clientThread = new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        clientPeer.run(test);
-                    } catch (Exception e) {
-                        /*
-                         * Our client thread just died.
-                         */
-                        print("Client died ...", e);
-                        clientException = e;
-                    }
-                }
-            };
-            clientThread.start();
-        } else {
-            try {
-                clientPeer.run(test);
-            } catch (Exception e) {
-                print("Client failed ...", e);
-                clientException = e;
-            }
-        }
-    }
-}
--- a/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -27,6 +27,8 @@
  * @key intermittent
  * @summary test RMI-IIOP with value object return
  * @modules java.corba
+ *          java.naming
+ *          java.rmi
  * @library /lib/testlibrary
  * @build jdk.testlibrary.*
  * @compile Test.java Test3.java Test4.java
--- a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -27,6 +27,8 @@
  * @summary test RMI-IIOP call with ConcurrentHashMap as an argument
  * @library /lib/testlibrary
  * @modules java.corba
+ *          java.naming
+ *          java.rmi
  * @build jdk.testlibrary.*
  * @compile Test.java HelloInterface.java HelloServer.java HelloClient.java
  *    HelloImpl.java _HelloImpl_Tie.java _HelloInterface_Stub.java ConcurrentHashMapTest.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/AudioFileFormat/TypeEqualsToNull.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.sound.sampled.AudioFileFormat;
+
+/**
+ * @test
+ * @bug 8168998
+ */
+public final class TypeEqualsToNull {
+
+    public static void main(final String[] args) {
+        final AudioFileFormat.Type type;
+        try {
+            type = new AudioFileFormat.Type(null, null);
+        } catch (final Exception ignored) {
+            // behaviour of null is not specified so ignore possible exceptions
+            return;
+        }
+        final Object stub = new Object() {
+            @Override
+            public String toString() {
+                return null;
+            }
+        };
+        if (stub.equals(type) || type.equals(stub)) {
+            throw new RuntimeException("Should not be equal");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/AudioFormat/EncodingEqualsToNull.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.sound.sampled.AudioFormat;
+
+/**
+ * @test
+ * @bug 8168998
+ */
+public final class EncodingEqualsToNull {
+
+    public static void main(final String[] args) {
+        final AudioFormat.Encoding enc;
+        try {
+            enc = new AudioFormat.Encoding(null);
+        } catch (final Exception ignored) {
+            // behaviour of null is not specified so ignore possible exceptions
+            return;
+        }
+        final Object stub = new Object() {
+            @Override
+            public String toString() {
+                return null;
+            }
+        };
+        if (stub.equals(enc) || enc.equals(stub)) {
+            throw new RuntimeException("Should not be equal");
+        }
+    }
+}
--- a/jdk/test/javax/sound/sampled/Clip/OpenNonIntegralNumberOfSampleframes.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/javax/sound/sampled/Clip/OpenNonIntegralNumberOfSampleframes.java	Wed Jul 05 22:30:23 2017 +0200
@@ -97,7 +97,8 @@
                 System.err.println("af = " + af);
                 System.err.println("bufferSize = " + bufferSize);
                 throw new RuntimeException("Expected exception is not thrown");
-            } catch (final LineUnavailableException ignored) {
+            } catch (IllegalArgumentException
+                    | LineUnavailableException ignored) {
                 // the test is not applicable
             }
         }
--- a/jdk/test/javax/swing/JEditorPane/8080972/TestJEditor.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/javax/swing/JEditorPane/8080972/TestJEditor.java	Wed Jul 05 22:30:23 2017 +0200
@@ -36,7 +36,7 @@
 
 /*
  * @test
- * @bug 8080972
+ * @bug 8080972 8169887
  * @summary Audit Core Reflection in module java.desktop for places that will
  *          require changes to work with modules
  * @author Alexander Scherbatiy
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JViewport/8164032/JViewPortBackingStoreImageTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.HashMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextPane;
+import javax.swing.JViewport;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultStyledDocument;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyleContext;
+
+/*
+ * @test
+ * @bug 8164032 8156217
+ * @summary JViewport backing store image is not scaled on HiDPI display
+ * @run main/manual JViewPortBackingStoreImageTest
+ */
+public class JViewPortBackingStoreImageTest {
+
+    private static volatile boolean testResult = false;
+    private static volatile CountDownLatch countDownLatch;
+    private static final String INSTRUCTIONS = "INSTRUCTIONS:\n\n"
+            + "Verify text is drawn with high resolution and text selection "
+            + "is not shifted when JViewPort is used on HiDPI display.\n\n"
+            + "If the display does not support HiDPI mode press PASS.\n\n"
+            + "1. Check that the text does not have low resolution.\n"
+            + "If no, press FAIL.\n\n"
+            + "2. Select the current text from the end to the beginning.\n"
+            + "\n"
+            + "If the text is slightly shiftted from one side to another\n"
+            + "and back during selection press Fail.\n"
+            + "Otherwise, press Pass.";
+
+    private static DefaultStyledDocument doc;
+    private static StyleContext styles;
+    private static HashMap<String, Style> contentAttributes;
+
+    public static void main(String args[]) throws Exception {
+        countDownLatch = new CountDownLatch(1);
+
+        SwingUtilities.invokeLater(JViewPortBackingStoreImageTest::createUI);
+        countDownLatch.await(15, TimeUnit.MINUTES);
+
+        if (!testResult) {
+            throw new RuntimeException("Test fails!");
+        }
+    }
+
+    private static void createUI() {
+
+        try {
+            UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+        final JFrame mainFrame = new JFrame();
+        GridBagLayout layout = new GridBagLayout();
+        JPanel mainControlPanel = new JPanel(layout);
+        JPanel resultButtonPanel = new JPanel(layout);
+
+        GridBagConstraints gbc = new GridBagConstraints();
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        gbc.insets = new Insets(5, 15, 5, 15);
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(createComponent(), gbc);
+
+        JTextArea instructionTextArea = new JTextArea();
+        instructionTextArea.setText(INSTRUCTIONS);
+        instructionTextArea.setEditable(false);
+        instructionTextArea.setBackground(Color.white);
+
+        gbc.gridx = 0;
+        gbc.gridy = 1;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(instructionTextArea, gbc);
+
+        JButton passButton = new JButton("Pass");
+        passButton.setActionCommand("Pass");
+        passButton.addActionListener((ActionEvent e) -> {
+            testResult = true;
+            mainFrame.dispose();
+            countDownLatch.countDown();
+
+        });
+
+        JButton failButton = new JButton("Fail");
+        failButton.setActionCommand("Fail");
+        failButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                mainFrame.dispose();
+                countDownLatch.countDown();
+            }
+        });
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+
+        resultButtonPanel.add(passButton, gbc);
+
+        gbc.gridx = 1;
+        gbc.gridy = 0;
+        resultButtonPanel.add(failButton, gbc);
+
+        gbc.gridx = 0;
+        gbc.gridy = 2;
+        mainControlPanel.add(resultButtonPanel, gbc);
+
+        mainFrame.add(mainControlPanel);
+        mainFrame.pack();
+
+        mainFrame.addWindowListener(new WindowAdapter() {
+
+            @Override
+            public void windowClosing(WindowEvent e) {
+                mainFrame.dispose();
+                countDownLatch.countDown();
+            }
+        });
+        mainFrame.setVisible(true);
+    }
+
+    private static JComponent createComponent() {
+        createStyles();
+        for (int i = 0; i < data.length; i++) {
+            Paragraph p = data[i];
+            addParagraph(p);
+        }
+
+        JTextPane textPane = new JTextPane(doc);
+
+        JScrollPane scroller = new JScrollPane();
+        JViewport port = scroller.getViewport();
+        port.setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
+        port.add(textPane);
+
+        return scroller;
+    }
+
+    static void createStyles() {
+        styles = new StyleContext();
+        doc = new DefaultStyledDocument(styles);
+        contentAttributes = new HashMap<>();
+
+        // no attributes defined
+        Style s = styles.addStyle(null, null);
+        contentAttributes.put("none", s);
+
+        Style def = styles.getStyle(StyleContext.DEFAULT_STYLE);
+
+        Style heading = styles.addStyle("heading", def);
+        StyleConstants.setFontFamily(heading, "SansSerif");
+        StyleConstants.setBold(heading, true);
+        StyleConstants.setAlignment(heading, StyleConstants.ALIGN_CENTER);
+        StyleConstants.setSpaceAbove(heading, 10);
+        StyleConstants.setSpaceBelow(heading, 10);
+        StyleConstants.setFontSize(heading, 18);
+
+        // Title
+        Style sty = styles.addStyle("title", heading);
+        StyleConstants.setFontSize(sty, 32);
+
+        // author
+        sty = styles.addStyle("author", heading);
+        StyleConstants.setItalic(sty, true);
+        StyleConstants.setSpaceBelow(sty, 25);
+    }
+
+    static void addParagraph(Paragraph p) {
+        try {
+            Style s = null;
+            for (int i = 0; i < p.data.length; i++) {
+                AttributedContent run = p.data[i];
+                s = contentAttributes.get(run.attr);
+                doc.insertString(doc.getLength(), run.content, s);
+            }
+
+            Style ls = styles.getStyle(p.logical);
+            doc.setLogicalStyle(doc.getLength() - 1, ls);
+            doc.insertString(doc.getLength(), "\n", null);
+        } catch (BadLocationException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static Paragraph[] data = new Paragraph[]{
+        new Paragraph("title", new AttributedContent[]{
+            new AttributedContent("none", "ALICE'S ADVENTURES IN WONDERLAND")
+        }),
+        new Paragraph("author", new AttributedContent[]{
+            new AttributedContent("none", "Lewis Carroll")
+        }),
+        new Paragraph("heading", new AttributedContent[]{
+            new AttributedContent("alice", " ")
+        })};
+
+    static class Paragraph {
+
+        Paragraph(String logical, AttributedContent[] data) {
+            this.logical = logical;
+            this.data = data;
+        }
+        String logical;
+        AttributedContent[] data;
+    }
+
+    static class AttributedContent {
+
+        AttributedContent(String attr, String content) {
+            this.attr = attr;
+            this.content = content;
+        }
+        String attr;
+        String content;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/basic/BasicGraphicsUtils/8132119/bug8132119.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,339 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.font.FontRenderContext;
+import java.awt.font.NumericShaper;
+import java.awt.font.TextAttribute;
+import java.awt.font.TextLayout;
+import java.awt.image.BufferedImage;
+import java.util.HashMap;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.basic.BasicGraphicsUtils;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * @test
+ * @bug 8132119 8168992
+ * @author Alexandr Scherbatiy
+ * @summary Provide public API for text related methods in SwingBasicGraphicsUtils2
+ */
+public class bug8132119 {
+
+    private static final int WIDTH = 50;
+    private static final int HEIGHT = 50;
+    private static final Color DRAW_COLOR = Color.RED;
+    private static final Color BACKGROUND_COLOR = Color.GREEN;
+    private static final NumericShaper NUMERIC_SHAPER = NumericShaper.getShaper(
+            NumericShaper.ARABIC);
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(bug8132119::testStringMethods);
+    }
+
+    private static void testStringMethods() {
+        setMetalLAF();
+        testStringWidth();
+        testStringClip();
+        testDrawEmptyString();
+        testDrawString(false);
+        testDrawString(true);
+        checkNullArguments();
+    }
+
+    private static void testStringWidth() {
+
+        String str = "12345678910\u036F";
+        JComponent comp = createComponent(str);
+        Font font = comp.getFont();
+        FontMetrics fontMetrics = comp.getFontMetrics(font);
+        float stringWidth = BasicGraphicsUtils.getStringWidth(comp, fontMetrics, str);
+
+        if (stringWidth == fontMetrics.stringWidth(str)) {
+            throw new RuntimeException("Numeric shaper is not used!");
+        }
+
+        if (stringWidth != getLayoutWidth(str, font, NUMERIC_SHAPER)) {
+            throw new RuntimeException("Wrong text width!");
+        }
+    }
+
+    private static void testStringClip() {
+
+        String str = "1234567890";
+        JComponent comp = createComponent(str);
+        FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont());
+
+        int width = (int) BasicGraphicsUtils.getStringWidth(comp, fontMetrics, str);
+
+        String clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics, str, width);
+        checkClippedString(str, clip, str);
+
+        clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics, str, width + 1);
+        checkClippedString(str, clip, str);
+
+        clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics, str, -1);
+        checkClippedString(str, clip, "...");
+
+        clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics, str, 0);
+        checkClippedString(str, clip, "...");
+
+        clip = BasicGraphicsUtils.getClippedString(comp, fontMetrics,
+                str, width - width / str.length());
+        int endIndex = str.length() - 3;
+        checkClippedString(str, clip, str.substring(0, endIndex) + "...");
+    }
+
+    private static void checkClippedString(String str, String res, String golden) {
+        if (!golden.equals(res)) {
+            throw new RuntimeException(String.format("The string '%s' is not "
+                    + "properly clipped. The result is '%s' instead of '%s'",
+                    str, res, golden));
+        }
+    }
+
+    private static void testDrawEmptyString() {
+        JLabel label = new JLabel();
+        BufferedImage buffImage = createBufferedImage(50, 50);
+        Graphics2D g2 = buffImage.createGraphics();
+        g2.setColor(DRAW_COLOR);
+        BasicGraphicsUtils.drawString(null, g2, null, 0, 0);
+        BasicGraphicsUtils.drawString(label, g2, null, 0, 0);
+        BasicGraphicsUtils.drawString(null, g2, "", 0, 0);
+        BasicGraphicsUtils.drawString(label, g2, "", 0, 0);
+        BasicGraphicsUtils.drawStringUnderlineCharAt(null, g2, null, 3, 0, 0);
+        BasicGraphicsUtils.drawStringUnderlineCharAt(label, g2, null, 3, 0, 0);
+        BasicGraphicsUtils.drawStringUnderlineCharAt(null, g2, "", 3, 0, 0);
+        BasicGraphicsUtils.drawStringUnderlineCharAt(label, g2, "", 3, 0, 0);
+        g2.dispose();
+        checkImageIsEmpty(buffImage);
+    }
+
+    private static void testDrawString(boolean underlined) {
+        String str = "AOB";
+        JComponent comp = createComponent(str);
+
+        BufferedImage buffImage = createBufferedImage(WIDTH, HEIGHT);
+        Graphics2D g2 = buffImage.createGraphics();
+
+        g2.setColor(DRAW_COLOR);
+        g2.setFont(comp.getFont());
+
+        FontMetrics fontMetrices = comp.getFontMetrics(comp.getFont());
+        float width = BasicGraphicsUtils.getStringWidth(comp, fontMetrices, str);
+        float x = (WIDTH - width) / 2;
+        int y = 3 * HEIGHT / 4;
+
+        if (underlined) {
+            BasicGraphicsUtils.drawStringUnderlineCharAt(comp, g2, str, 1, x, y);
+        } else {
+            BasicGraphicsUtils.drawString(comp, g2, str, x, y);
+        }
+        g2.dispose();
+
+        float xx = (WIDTH - width / 8) / 2;
+        checkImageContainsSymbol(buffImage, (int) xx, underlined ? 3 : 2);
+    }
+
+    private static void checkNullArguments() {
+
+        Graphics2D g = null;
+        try {
+            String text = "Test";
+            JComponent component = new JLabel(text);
+            BufferedImage img = createBufferedImage(100, 100);
+            g = img.createGraphics();
+            checkNullArguments(component, g, text);
+        } finally {
+            g.dispose();
+        }
+    }
+
+    private static void checkNullArguments(JComponent comp, Graphics2D g,
+            String text) {
+
+        checkNullArgumentsDrawString(comp, g, text);
+        checkNullArgumentsDrawStringUnderlineCharAt(comp, g, text);
+        checkNullArgumentsGetClippedString(comp, text);
+        checkNullArgumentsGetStringWidth(comp, text);
+    }
+
+    private static void checkNullArgumentsDrawString(JComponent comp, Graphics2D g,
+            String text) {
+
+        float x = 50;
+        float y = 50;
+        BasicGraphicsUtils.drawString(null, g, text, x, y);
+        BasicGraphicsUtils.drawString(comp, g, null, x, y);
+
+        try {
+            BasicGraphicsUtils.drawString(comp, null, text, x, y);
+        } catch (NullPointerException e) {
+            return;
+        }
+
+        throw new RuntimeException("NPE is not thrown");
+    }
+
+    private static void checkNullArgumentsDrawStringUnderlineCharAt(
+            JComponent comp, Graphics2D g, String text) {
+
+        int x = 50;
+        int y = 50;
+        BasicGraphicsUtils.drawStringUnderlineCharAt(null, g, text, 1, x, y);
+        BasicGraphicsUtils.drawStringUnderlineCharAt(comp, g, null, 1, x, y);
+
+        try {
+            BasicGraphicsUtils.drawStringUnderlineCharAt(comp, null, text, 1, x, y);
+        } catch (NullPointerException e) {
+            return;
+        }
+
+        throw new RuntimeException("NPE is not thrown");
+    }
+
+    private static void checkNullArgumentsGetClippedString(
+            JComponent comp, String text) {
+
+        FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont());
+
+        BasicGraphicsUtils.getClippedString(null, fontMetrics, text, 1);
+        String result = BasicGraphicsUtils.getClippedString(comp, fontMetrics, null, 1);
+        if (!"".equals(result)) {
+            throw new RuntimeException("Empty string is not returned!");
+        }
+
+        try {
+            BasicGraphicsUtils.getClippedString(comp, null, text, 1);
+        } catch (NullPointerException e) {
+            return;
+        }
+
+        throw new RuntimeException("NPE is not thrown");
+    }
+
+    private static void checkNullArgumentsGetStringWidth(JComponent comp,
+            String text) {
+
+        FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont());
+        BasicGraphicsUtils.getStringWidth(null, fontMetrics, text);
+        float result = BasicGraphicsUtils.getStringWidth(comp, fontMetrics, null);
+
+        if (result != 0) {
+            throw new RuntimeException("The string length is not 0");
+        }
+
+        try {
+            BasicGraphicsUtils.getStringWidth(comp, null, text);
+        } catch (NullPointerException e) {
+            return;
+        }
+
+        throw new RuntimeException("NPE is not thrown");
+    }
+
+    private static void setMetalLAF() {
+        try {
+            UIManager.setLookAndFeel(new MetalLookAndFeel());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static JComponent createComponent(String str) {
+        JComponent comp = new JLabel(str);
+        comp.setSize(WIDTH, HEIGHT);
+        comp.putClientProperty(TextAttribute.NUMERIC_SHAPING, NUMERIC_SHAPER);
+        comp.setFont(getFont());
+        return comp;
+    }
+
+    private static Font getFont() {
+        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+        String[] fontNames = ge.getAvailableFontFamilyNames();
+        String fontName = fontNames[0];
+        for (String name : fontNames) {
+            if ("Arial".equals(name)) {
+                fontName = name;
+                break;
+            }
+        }
+        return new Font(fontName, Font.PLAIN, 28);
+    }
+
+    private static float getLayoutWidth(String text, Font font, NumericShaper shaper) {
+        HashMap map = new HashMap();
+        map.put(TextAttribute.FONT, font);
+        map.put(TextAttribute.NUMERIC_SHAPING, shaper);
+        FontRenderContext frc = new FontRenderContext(null, false, false);
+        TextLayout layout = new TextLayout(text, map, frc);
+        return layout.getAdvance();
+    }
+
+    private static void checkImageIsEmpty(BufferedImage buffImage) {
+        int background = BACKGROUND_COLOR.getRGB();
+
+        for (int i = 0; i < buffImage.getWidth(); i++) {
+            for (int j = 0; j < buffImage.getHeight(); j++) {
+                if (background != buffImage.getRGB(i, j)) {
+                    throw new RuntimeException("Image is not empty!");
+                }
+            }
+        }
+    }
+
+    private static void checkImageContainsSymbol(BufferedImage buffImage,
+            int x, int intersections) {
+        int background = BACKGROUND_COLOR.getRGB();
+        boolean isBackground = true;
+        int backgroundChangesCount = 0;
+
+        for (int y = 0; y < buffImage.getHeight(); y++) {
+            if (!(isBackground ^ (background != buffImage.getRGB(x, y)))) {
+                isBackground = !isBackground;
+                backgroundChangesCount++;
+            }
+        }
+        if (backgroundChangesCount != intersections * 2) {
+            throw new RuntimeException("String is not properly drawn!");
+        }
+    }
+
+    private static BufferedImage createBufferedImage(int width, int height) {
+        BufferedImage bufffImage = new BufferedImage(width, height,
+                BufferedImage.TYPE_INT_RGB);
+
+        Graphics2D g = bufffImage.createGraphics();
+        g.setColor(BACKGROUND_COLOR);
+        g.fillRect(0, 0, width, height);
+        g.dispose();
+        return bufffImage;
+    }
+}
--- a/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java	Wed Jul 05 22:30:23 2017 +0200
@@ -23,11 +23,11 @@
  */
 
 /* @test
-   @bug 6427244 8144240
+   @bug 6427244 8144240 8166003
    @summary Test that pressing HOME correctly moves caret in I18N document.
    @author Sergey Groznyh
    @library ../../../regtesthelpers
-   @build JRobot Util TestCase
+   @build JRobot
    @run main bug6427244
 */
 
@@ -36,12 +36,13 @@
 import java.awt.Point;
 import java.awt.Shape;
 import java.awt.event.KeyEvent;
+import javax.swing.JComponent;
 import javax.swing.JFrame;
 import javax.swing.JTextPane;
 import javax.swing.SwingUtilities;
 import javax.swing.text.Position;
 
-public class bug6427244 extends TestCase {
+public class bug6427244 {
     private static final JRobot ROBOT = JRobot.getRobot();
 
     final static int TP_SIZE = 200;
@@ -105,13 +106,25 @@
                     dim = c.getSize();
                 }
             });
-            Util.blockTillDisplayed(tp);
+            blockTillDisplayed(tp);
             ROBOT.waitForIdle();
         } catch (Exception ex) {
             throw new RuntimeException(ex);
         }
     }
 
+    void blockTillDisplayed(JComponent comp) {
+        if(comp != null) {
+            while (!comp.isVisible()) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ie) {
+                    /* No-op */
+                }
+            }
+        }
+    }
+
     public void testCaretPosition() {
         Point p = tp.getLocationOnScreen();
         // the right-top corner position
@@ -122,7 +135,9 @@
         ROBOT.hitKey(KeyEvent.VK_HOME);
         ROBOT.waitForIdle();
         // this will fail if caret moves out of the 1st line.
-        assertEquals(0, getCaretOrdinate());
+        if (getCaretOrdinate() != 0) {
+            throw new RuntimeException("Test Failed.");
+        }
     }
 
     int getCaretOrdinate() {
--- a/jdk/test/javax/swing/text/View/8080972/TestObjectView.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/javax/swing/text/View/8080972/TestObjectView.java	Wed Jul 05 22:30:23 2017 +0200
@@ -32,7 +32,7 @@
 import javax.swing.text.html.ObjectView;
 /*
  * @test
- * @bug 8080972
+ * @bug 8080972 8169887
  * @summary Audit Core Reflection in module java.desktop for places that will
  *          require changes to work with modules
  * @author Alexander Scherbatiy
--- a/jdk/test/sun/net/www/protocol/https/HttpsClient/ProxyAuthTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/sun/net/www/protocol/https/HttpsClient/ProxyAuthTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -63,7 +63,7 @@
  * authentication proxy
  */
 
-public class ProxyAuthTest {
+public class ProxyAuthTest extends SSLSocketTemplate {
     /*
      * Where do we find the keystores?
      */
@@ -96,13 +96,13 @@
         expectSuccess = args[0].equals("succeed");
 
         String keyFilename =
-            SSLTest.TEST_SRC + "/" + pathToStores + "/" + keyStoreFile;
+            TEST_SRC + "/" + pathToStores + "/" + keyStoreFile;
         String trustFilename =
-            SSLTest.TEST_SRC + "/" + pathToStores + "/" + trustStoreFile;
+            TEST_SRC + "/" + pathToStores + "/" + trustStoreFile;
 
-        SSLTest.setup(keyFilename, trustFilename, passwd);
+        setup(keyFilename, trustFilename, passwd);
 
-        new SSLTest()
+        new SSLSocketTemplate()
             .setServerApplication((socket, test) -> {
                 DataOutputStream out = new DataOutputStream(
                         socket.getOutputStream());
@@ -164,7 +164,7 @@
             .runTest();
     }
 
-    static void doClientSide(SSLTest test) throws IOException {
+    static void doClientSide(SSLSocketTemplate test) throws IOException {
 
         // Wait for server to get started.
         //
--- a/jdk/test/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -45,20 +45,20 @@
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.SSLContext;
 
-public class ServerIdentityTest {
+public class ServerIdentityTest extends SSLSocketTemplate {
 
     private static final String PASSWORD = "changeit";
 
     public static void main(String[] args) throws Exception {
         final String keystore = args[0];
-        String keystoreFilename = SSLTest.TEST_SRC + "/" + keystore;
+        String keystoreFilename = TEST_SRC + "/" + keystore;
 
-        SSLTest.setup(keystoreFilename, keystoreFilename, PASSWORD);
+        setup(keystoreFilename, keystoreFilename, PASSWORD);
 
         SSLContext context = SSLContext.getInstance("SSL");
 
         KeyManager[] kms = new KeyManager[1];
-        KeyStore ks = SSLTest.loadJksKeyStore(keystoreFilename, PASSWORD);
+        KeyStore ks = loadJksKeyStore(keystoreFilename, PASSWORD);
         KeyManager km = new MyKeyManager(ks, PASSWORD.toCharArray());
         kms[0] = km;
         context.init(kms, null, null);
@@ -70,7 +70,7 @@
          */
         System.out.println("Testing " + keystore);
 
-        new SSLTest()
+        new SSLSocketTemplate()
             .setSSLContext(context)
             .setServerApplication((socket, test) -> {
                 BufferedWriter bw = new BufferedWriter(
@@ -79,12 +79,12 @@
                 bw.flush();
                 Thread.sleep(2000);
                 socket.getSession().invalidate();
-                SSLTest.print("Server application is done");
+                print("Server application is done");
             })
             .setClientPeer((test) -> {
                 boolean serverIsReady = test.waitForServerSignal();
                 if (!serverIsReady) {
-                    SSLTest.print(
+                    print(
                             "The server is not ready, ignore on client side.");
                     return;
                 }
@@ -100,7 +100,7 @@
                 ((HttpURLConnection) url.openConnection())
                         .getInputStream().close();
 
-                SSLTest.print("Client is done");
+                print("Client is done");
             }).runTest();
     }
 }
--- a/jdk/test/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java	Wed Jul 05 22:30:23 2017 +0200
@@ -42,7 +42,7 @@
 import javax.net.ssl.SSLServerSocketFactory;
 import javax.net.ssl.SSLSocket;
 
-public class AnonCipherWithWantClientAuth {
+public class AnonCipherWithWantClientAuth extends SSLSocketTemplate {
 
     /*
      * Where do we find the keystores?
@@ -62,16 +62,16 @@
         String trustFilename =
             System.getProperty("test.src", "./") + "/" + pathToStores +
                 "/" + trustStoreFile;
-        SSLTest.setup(keyFilename, trustFilename, passwd);
+        setup(keyFilename, trustFilename, passwd);
 
-        new SSLTest()
+        new SSLSocketTemplate()
             .setServerPeer(test -> {
                 SSLServerSocketFactory sslssf =
                         (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
                 SSLServerSocket sslServerSocket =
-                        (SSLServerSocket) sslssf.createServerSocket(SSLTest.FREE_PORT);
+                        (SSLServerSocket) sslssf.createServerSocket(FREE_PORT);
                 test.setServerPort(sslServerSocket.getLocalPort());
-                SSLTest.print("Server is listening on port "
+                print("Server is listening on port "
                         + test.getServerPort());
 
                 String ciphers[] = {
@@ -85,14 +85,14 @@
                 test.signalServerReady();
 
                 // Try to accept a connection in 30 seconds.
-                SSLSocket sslSocket = SSLTest.accept(sslServerSocket);
+                SSLSocket sslSocket = accept(sslServerSocket);
                 if (sslSocket == null) {
                     // Ignore the test case if no connection within 30 seconds.
-                    SSLTest.print("No incoming client connection in 30 seconds."
+                    print("No incoming client connection in 30 seconds."
                             + " Ignore in server side.");
                     return;
                 }
-                SSLTest.print("Server accepted connection");
+                print("Server accepted connection");
 
                 // handle the connection
                 try {
@@ -108,7 +108,7 @@
 
                     if (clientIsReady) {
                         // Run the application in server side.
-                        SSLTest.print("Run server application");
+                        print("Run server application");
 
                         InputStream sslIS = sslSocket.getInputStream();
                         OutputStream sslOS = sslSocket.getOutputStream();
--- a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java	Wed Jul 05 22:30:23 2017 +0200
@@ -58,7 +58,7 @@
 
 /*
  * @test
- * @bug 6543842 6543440 6939248 8009636 8024302 8163304
+ * @bug 6543842 6543440 6939248 8009636 8024302 8163304 8169911
  * @summary checking response of timestamp
  * @modules java.base/sun.security.pkcs
  *          java.base/sun.security.timestamp
@@ -349,6 +349,18 @@
                         .shouldMatch("MD5withRSA.*-sigalg.*risk");
                 checkWeak("weak.jar");
 
+                signWithAliasAndTsa("halfWeak", "old.jar", "old", "-digestalg", "MD5")
+                        .shouldHaveExitValue(0);
+                checkHalfWeak("halfWeak.jar");
+
+                // sign with DSA key
+                signWithAliasAndTsa("sign1", "old.jar", "dsakey")
+                        .shouldHaveExitValue(0);
+                // sign with RSAkeysize < 1024
+                signWithAliasAndTsa("sign2", "sign1.jar", "weakkeysize")
+                        .shouldHaveExitValue(0);
+                checkMultiple("sign2.jar");
+
                 // When .SF or .RSA is missing or invalid
                 checkMissingOrInvalidFiles("normal.jar");
             } else {                        // Run as a standalone server
@@ -447,6 +459,37 @@
                 .shouldMatch("SignatureException:.*Disabled");
     }
 
+    static void checkHalfWeak(String file) throws Throwable {
+        verify(file)
+                .shouldHaveExitValue(0)
+                .shouldContain("treated as unsigned")
+                .shouldMatch("weak algorithm that is now disabled.")
+                .shouldMatch("Re-run jarsigner with the -verbose option for more details");
+        verify(file, "-verbose")
+                .shouldHaveExitValue(0)
+                .shouldContain("treated as unsigned")
+                .shouldMatch("weak algorithm that is now disabled by")
+                .shouldMatch("Digest algorithm: .*weak")
+                .shouldNotMatch("Signature algorithm: .*weak")
+                .shouldNotMatch("Timestamp digest algorithm: .*weak")
+                .shouldNotMatch("Timestamp signature algorithm: .*weak.*weak")
+                .shouldNotMatch("Timestamp signature algorithm: .*key.*weak");
+     }
+
+    static void checkMultiple(String file) throws Throwable {
+        verify(file)
+                .shouldHaveExitValue(0)
+                .shouldContain("jar verified");
+        verify(file, "-verbose", "-certs")
+                .shouldHaveExitValue(0)
+                .shouldContain("jar verified")
+                .shouldMatch("X.509.*CN=dsakey")
+                .shouldNotMatch("X.509.*CN=weakkeysize")
+                .shouldMatch("Signed by .*CN=dsakey")
+                .shouldMatch("Signed by .*CN=weakkeysize")
+                .shouldMatch("Signature algorithm: .*key.*weak");
+     }
+
     static void checkTimestamp(String file, String policyId, String digestAlg)
             throws Exception {
         try (JarFile jf = new JarFile(file)) {
@@ -480,11 +523,16 @@
      */
     static OutputAnalyzer sign(String path, String... extra)
             throws Throwable {
+        String alias = path.equals("badku") ? "badku" : "old";
+        return signWithAliasAndTsa(path, "old.jar", alias, extra);
+    }
+
+    static OutputAnalyzer signWithAliasAndTsa (String path, String jar,
+            String alias, String...extra) throws Throwable {
         which++;
         System.err.println("\n>> Test #" + which + ": " + Arrays.toString(extra));
         List<String> args = List.of("-J-Djava.security.egd=file:/dev/./urandom",
-                "-debug", "-signedjar", path + ".jar", "old.jar",
-                path.equals("badku") ? "badku" : "old");
+                "-debug", "-signedjar", path + ".jar", jar, alias);
         args = new ArrayList<>(args);
         if (!path.equals("none") && !path.equals("badku")) {
             args.add("-tsa");
@@ -499,6 +547,8 @@
         Files.deleteIfExists(Paths.get("tsks"));
         keytool("-alias ca -genkeypair -ext bc -dname CN=CA");
         keytool("-alias old -genkeypair -dname CN=old");
+        keytool("-alias dsakey -genkeypair -keyalg DSA -dname CN=dsakey");
+        keytool("-alias weakkeysize -genkeypair -keysize 512 -dname CN=weakkeysize");
         keytool("-alias badku -genkeypair -dname CN=badku");
         keytool("-alias ts -genkeypair -dname CN=ts");
         keytool("-alias tsweak -genkeypair -keysize 512 -dname CN=tsbad1");
@@ -507,6 +557,8 @@
         keytool("-alias tsbad3 -genkeypair -dname CN=tsbad3");
 
         gencert("old");
+        gencert("dsakey");
+        gencert("weakkeysize");
         gencert("badku", "-ext ku:critical=keyAgreement");
         gencert("ts", "-ext eku:critical=ts");
         gencert("tsweak", "-ext eku:critical=ts");
--- a/jdk/test/sun/util/locale/provider/Bug8038436.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/sun/util/locale/provider/Bug8038436.java	Wed Jul 05 22:30:23 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8038436 8158504
+ * @bug 8038436 8158504 8065555
  * @summary Test for changes in 8038436
  * @modules java.base/sun.util.locale.provider
  *          java.base/sun.util.spi
@@ -136,7 +136,7 @@
     static final String[] nfpLocs = ("ar, ar-AE, ar-BH, ar-DZ, ar-EG, ar-IQ, " +
         "ar-JO, ar-KW, ar-LB, ar-LY, ar-MA, ar-OM, ar-QA, ar-SA, ar-SD, ar-SY, " +
         "ar-TN, ar-YE, be, be-BY, bg, bg-BG, ca, ca-ES, cs, cs-CZ, da, da-DK, " +
-        "de, de-AT, de-CH, de-DE, de-GR, de-LU, el, el-CY, el-GR, en, en-AU, " +
+        "de, de-AT, de-CH, de-DE, de-LU, el, el-CY, el-GR, en, en-AU, " +
         "en-CA, en-GB, en-IE, en-IN, en-MT, en-NZ, en-PH, en-SG, en-US, en-ZA, " +
         "es, es-AR, es-BO, es-CL, es-CO, es-CR, es-CU, es-DO, es-EC, es-ES, " +
         "es-GT, es-HN, es-MX, es-NI, es-PA, es-PE, es-PR, es-PY, es-SV, es-US, " +
@@ -154,7 +154,7 @@
     static final String[] currencynpLocs = ("ar-AE, ar-BH, ar-DZ, ar-EG, ar-IQ, " +
         "ar-JO, ar-KW, ar-LB, ar-LY, ar-MA, ar-OM, ar-QA, ar-SA, ar-SD, ar-SY, " +
         "ar-TN, ar-YE, be-BY, bg-BG, ca-ES, cs-CZ, da-DK, de, de-AT, de-CH, " +
-        "de-DE, de-GR, de-LU, el-CY, el-GR, en-AU, en-CA, en-GB, en-IE, en-IN, " +
+        "de-DE, de-LU, el-CY, el-GR, en-AU, en-CA, en-GB, en-IE, en-IN, " +
         "en-MT, en-NZ, en-PH, en-SG, en-US, en-ZA, es, es-AR, es-BO, es-CL, " +
         "es-CO, es-CR, es-CU, es-DO, es-EC, es-ES, es-GT, es-HN, es-MX, es-NI, " +
         "es-PA, es-PE, es-PR, es-PY, es-SV, es-US, es-UY, es-VE, et-EE, fi-FI, " +
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jimage/JImageBasicsTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests to verify jimage basic options, i.e. --version, -h
+ * @library /test/lib
+ * @modules jdk.jlink/jdk.tools.jimage
+ * @build jdk.test.lib.Asserts
+ * @run main JImageBasicsTest
+ */
+
+import static jdk.test.lib.Asserts.assertTrue;
+
+public class JImageBasicsTest extends JImageCliTest {
+
+    public void testVersion() {
+        jimage("--version")
+                .assertSuccess()
+                .resultChecker(r -> {
+                    assertTrue(r.output.contains(System.getProperty("java.version")), "Contains java version.");
+                });
+    }
+
+    public void testFullVersion() {
+        jimage("--full-version")
+                .assertSuccess()
+                .resultChecker(r -> {
+                    assertTrue(r.output.contains(System.getProperty("java.version")), "Contains java version.");
+                });
+    }
+
+    public void testHelp() {
+        jimage("--help")
+                .assertSuccess()
+                .resultChecker(r -> verifyHelpOutput(r.output));
+    }
+
+    public void testShortHelp() {
+        jimage("-h")
+                .assertSuccess()
+                .resultChecker(r -> verifyHelpOutput(r.output));
+    }
+
+    public void testUnknownAction() {
+        jimage("unknown")
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testUnknownOption() {
+        jimage("--unknown")
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    private void verifyHelpOutput(String output) {
+        assertTrue(output.startsWith("Usage: jimage"), "Usage is printed.");
+        assertTrue(output.contains("extract"), "Option 'extract' is found.");
+        assertTrue(output.contains("info"), "Option 'info' is found.");
+        assertTrue(output.contains("list"), "Option 'list' is found.");
+        assertTrue(output.contains("verify"), "Option 'verify' is found.");
+    }
+
+    public static void main(String[] args) throws Throwable {
+        new JImageBasicsTest().runTests();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jimage/JImageCliTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.function.Consumer;
+import java.util.regex.Pattern;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static jdk.test.lib.Asserts.assertFalse;
+import static jdk.test.lib.Asserts.assertTrue;
+import static jdk.test.lib.Asserts.fail;
+
+/**
+ * This class is intended to be a base class for classes which are about to test
+ * command line interface of jimage.
+ */
+public class JImageCliTest {
+
+    private String bootImagePath;
+
+    public JImageCliTest() {
+        Path imagePath = Paths.get(System.getProperty("java.home"), "lib", "modules");
+        if (Files.exists(imagePath)) {
+            this.bootImagePath = imagePath.toAbsolutePath().toString();
+        }
+    }
+
+    public void assertMatches(String regex, String output) {
+        Pattern pattern = Pattern.compile(regex);
+        if (!pattern.matcher(output).find()) {
+            fail(String.format("Expected to find a string match for [%s] in output \n[\n%s\n]\n.",
+                    pattern, output));
+        }
+    }
+
+    /**
+     * Returns a path to a tested image to share it across tests. By default it returns a path to the boot image
+     * of tested JDK. This behavior can be redefined by descendants.
+     */
+    public String getImagePath() {
+        return bootImagePath;
+    }
+
+    /**
+     * Runs jimage task with the supplied arguments.
+     */
+    protected static JImageResult jimage(String... args) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        PrintStream ps = new PrintStream(baos);
+        System.out.println("jimage " + Arrays.asList(args));
+        int exitCode = jdk.tools.jimage.Main.run(args, new PrintWriter(ps));
+        return new JImageResult(exitCode, new String(baos.toByteArray(), UTF_8));
+    }
+
+    protected static class JImageResult {
+        final int exitCode;
+        final String output;
+
+        JImageResult(int exitCode, String output) {
+            this.exitCode = exitCode;
+            this.output = output;
+        }
+
+        JImageResult assertSuccess() { assertTrue(exitCode == 0, output); return this; }
+        JImageResult assertFailure() { assertFalse(exitCode == 0, output); return this; }
+
+        // a helper to ensure the error output doesn't exhibit implementation details
+        JImageResult assertShowsError() {
+            assertTrue(output.contains("Error"),
+                    String.format("Output contains error, output=[%s]\n", output));
+            assertFalse(output.contains("Exception"),
+                    String.format("Output doesn't contain a stacktrace, output=[%s]\n", output));
+            return this;
+        }
+
+        JImageResult resultChecker(Consumer<JImageResult> r) { r.accept(this); return this; }
+    }
+
+    protected final void runTests() throws Throwable {
+        if (getImagePath() != null) {
+            for (Method m : getClass().getDeclaredMethods()) {
+                if (m.getName().startsWith("test")) {
+                    System.out.printf("Invoking %s\n", m.getName());
+                    m.invoke(this);
+                }
+            }
+        } else {
+            System.out.println("This is not an image build. Skipping.");
+        }
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jimage/JImageExtractTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests to verify jimage 'extract' action
+ * @library /test/lib
+ * @modules jdk.jlink/jdk.tools.jimage
+ * @build jdk.test.lib.Asserts
+ * @run main/othervm JImageExtractTest
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.PosixFilePermission;
+import java.nio.file.attribute.PosixFilePermissions;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static jdk.test.lib.Asserts.assertEquals;
+import static jdk.test.lib.Asserts.assertTrue;
+
+public class JImageExtractTest extends JImageCliTest {
+    public void testExtract() throws IOException {
+        jimage("extract", getImagePath())
+                .assertSuccess()
+                .resultChecker(r -> {
+                    assertTrue(r.output.isEmpty(), "Output is not expected");
+                });
+        verifyExplodedImage(Paths.get("."));
+    }
+
+    public void testExtractHelp() {
+        for (String opt : Arrays.asList("-h", "--help")) {
+            jimage("extract", "--help")
+                    .assertSuccess()
+                    .resultChecker(r -> {
+                        // extract  -  descriptive text
+                        assertMatches("\\s+extract\\s+-\\s+.*", r.output);
+                    });
+        }
+    }
+
+    public void testExtractToDir() throws IOException {
+        Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName());
+        jimage("extract", "--dir", tmp.toString(), getImagePath())
+                .assertSuccess()
+                .resultChecker(r -> {
+                    assertTrue(r.output.isEmpty(), "Output is not expected");
+                });
+        verifyExplodedImage(tmp);
+    }
+
+    public void testExtractNoImageSpecified() {
+        jimage("extract", "")
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testExtractNotAnImage() throws IOException {
+        Path tmp = Files.createTempFile(Paths.get("."), getClass().getName(), "not_an_image");
+        jimage("extract", tmp.toString())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testExtractNotExistingImage() throws IOException {
+        Path tmp = Paths.get(".", "not_existing_image");
+        Files.deleteIfExists(tmp);
+        jimage("extract", tmp.toString())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testExtractToUnspecifiedDir() {
+        jimage("extract", "--dir", "--", getImagePath())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testExtractToNotExistingDir() throws IOException {
+        Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName());
+        Files.delete(tmp);
+        jimage("extract", "--dir", tmp.toString(), getImagePath())
+                .assertSuccess()
+                .resultChecker(r -> {
+                    assertTrue(r.output.isEmpty(), "Output is not expected");
+                });
+        verifyExplodedImage(tmp);
+    }
+
+    public void testExtractFromDir() {
+        Path imagePath = Paths.get(getImagePath());
+        Path imageDirPath = imagePath.subpath(0, imagePath.getNameCount() - 1);
+        jimage("extract", imageDirPath.toString())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testExtractToDirBySymlink() throws IOException {
+        Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName());
+        try {
+            Path symlink = Files.createSymbolicLink(Paths.get(".", "symlink"), tmp);
+            jimage("extract", "--dir", symlink.toString(), getImagePath())
+                    .assertSuccess()
+                    .resultChecker(r -> {
+                        assertTrue(r.output.isEmpty(), "Output is not expected");
+                    });
+            verifyExplodedImage(tmp);
+        } catch (UnsupportedOperationException e) {
+            // symlinks are not supported
+            // nothing to test
+        }
+    }
+
+    public void testExtractToReadOnlyDir() throws IOException {
+        Set<PosixFilePermission> perms = PosixFilePermissions.fromString("r-xr--r--");
+        FileAttribute<Set<PosixFilePermission>> atts = PosixFilePermissions.asFileAttribute(perms);
+        Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName(), atts);
+        jimage("extract", "--dir", tmp.toString(), getImagePath())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testExtractToNotEmptyDir() throws IOException {
+        Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName());
+        Files.createFile(Paths.get(tmp.toString(), ".not_empty"));
+        jimage("extract", "--dir", tmp.toString(), getImagePath())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testExtractToFile() throws IOException {
+        Path tmp = Files.createTempFile(Paths.get("."), getClass().getName(), "not_a_dir");
+        jimage("extract", "--dir", tmp.toString(), getImagePath())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    private void verifyExplodedImage(Path imagePath) throws IOException {
+        Set<Path> allModules = Files.walk(imagePath, 1).collect(Collectors.toSet());
+        assertTrue(allModules.stream().anyMatch(p -> "java.base".equals(p.getFileName().toString())),
+                "Exploded image contains java.base module.");
+
+        Set<Path> badModules = allModules.stream()
+                .filter(p -> !Files.exists(p.resolve("module-info.class")))
+                .collect(Collectors.toSet());
+        assertEquals(badModules, new HashSet<Path>() {{ add(imagePath); }},
+                "There are no exploded modules with missing 'module-info.class'");
+    }
+
+    public static void main(String[] args) throws Throwable {
+        new JImageExtractTest().runTests();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jimage/JImageInfoTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests to verify jimage 'info' action
+ * @library /test/lib
+ * @modules jdk.jlink/jdk.tools.jimage
+ * @build jdk.test.lib.Asserts
+ * @run main JImageInfoTest
+ */
+
+import java.util.Arrays;
+
+public class JImageInfoTest extends JImageCliTest {
+    public void testInfo() {
+        jimage("info", getImagePath())
+                .assertSuccess()
+                .resultChecker(r -> {
+                    assertMatches("(?m)^\\s+Major Version: +[1-9]\\d*$.*", r.output);
+                    assertMatches("(?m)^\\s+Minor Version: +\\d+$.*", r.output);
+                    assertMatches("(?m)^\\s+Flags: +\\d+$.*", r.output);
+                    assertMatches("(?m)^\\s+Resource Count: +\\d+$.*", r.output);
+                    assertMatches("(?m)^\\s+Table Length: +\\d+$.*", r.output);
+                    assertMatches("(?m)^\\s+Offsets Size: +\\d+$.*", r.output);
+                    assertMatches("(?m)^\\s+Redirects Size: +\\d+$.*", r.output);
+                    assertMatches("(?m)^\\s+Locations Size: +\\d+$.*", r.output);
+                    assertMatches("(?m)^\\s+Strings Size: +\\d+$.*", r.output);
+                    assertMatches("(?m)^\\s+Index Size: +\\d+$.*", r.output);
+                });
+    }
+
+    public void testInfoHelp() {
+        for (String opt : Arrays.asList("-h", "--help")) {
+            jimage("info", opt)
+                    .assertSuccess()
+                    .resultChecker(r -> {
+                        // info  -  descriptive text
+                        assertMatches("\\s+info\\s+-\\s+.*", r.output);
+                    });
+        }
+    }
+
+    public void testInfoUnknownOption() {
+        jimage("info", "--unknown")
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public static void main(String[] args) throws Throwable {
+        new JImageInfoTest().runTests();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jimage/JImageListTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests to verify jimage 'list' action
+ * @library /test/lib
+ * @modules jdk.jlink/jdk.tools.jimage
+ * @build jdk.test.lib.Asserts
+ * @run main JImageListTest
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static jdk.test.lib.Asserts.assertEquals;
+import static jdk.test.lib.Asserts.assertFalse;
+import static jdk.test.lib.Asserts.assertTrue;
+
+public class JImageListTest extends JImageCliTest {
+    public void testList() {
+        jimage("list", getImagePath())
+                .assertSuccess()
+                .resultChecker(r -> {
+                    String[] lines = r.output.split(System.lineSeparator());
+                    assertTrue(lines.length > 0, "Option --list has output.");
+                    assertTrue(lines[0].startsWith("jimage: " + getImagePath()),
+                            "Output should start with jimage path.");
+
+                    List<String> modules = Stream.of(lines)
+                            .filter(s -> s.startsWith("Module: "))
+                            .map(s -> s.substring(s.indexOf(':') + 1).trim())
+                            .collect(Collectors.toList());
+                    assertTrue(modules.size() > 0, "Image contains at least one module.");
+                    assertTrue(modules.indexOf("java.base") > 0, "Module java.base found.");
+                });
+    }
+
+    public void testListHelp() {
+        for (String opt : Arrays.asList("-h", "--help")) {
+            jimage("list", opt)
+                    .assertSuccess()
+                    .resultChecker(r -> {
+                        // list  -  descriptive text
+                        assertMatches("\\s+list\\s+-\\s+.*", r.output);
+                    });
+        }
+    }
+
+    public void testListVerbose() {
+        jimage("list", "--verbose", getImagePath())
+                .assertSuccess()
+                .resultChecker(r -> {
+                    assertMatches("Offset\\s+Size\\s+Compressed\\s+Entry", r.output);
+
+                    String[] lines = r.output.split("[" + System.lineSeparator() + "]+");
+                    assertTrue(lines.length > 0, "Option --list has output.");
+                    assertTrue(lines[0].startsWith("jimage: " + getImagePath()),
+                            "Output should start with jimage path.");
+
+                    List<String> modules = Stream.of(lines)
+                            .filter(s -> s.startsWith("Module: "))
+                            .map(s -> s.substring(s.indexOf(':') + 1).trim())
+                            .collect(Collectors.toList());
+                    assertTrue(modules.size() > 0, "Image contains at least one module.");
+                    assertTrue(modules.indexOf("java.base") > 0, "Module java.base found.");
+
+                    Set<String> entries = Stream.of(lines)
+                            .filter(s -> { return !s.startsWith("Module: ") && !s.startsWith("Offset"); })
+                            // Offset \d+  Size \d+  Compressed \d+ Entry \.*
+                            .filter(s -> !s.matches("\\s+\\d+\\s+\\d+\\s+\\d+\\s+.*"))
+                            .collect(Collectors.toSet());
+                    assertEquals(entries, new HashSet<>() {{ add("jimage: " + getImagePath()); }},
+                            "All entries should be in format: Offset Size Compressed Entry");
+                });
+    }
+
+    public void testListIncludeAllWithGlob() {
+        JImageResult listAll = jimage("list", getImagePath()).assertSuccess();
+        JImageResult listAllGlob = jimage("list", "--include", "**", getImagePath()).assertSuccess();
+        assertEquals(listAllGlob.output, listAll.output, "--include ** should produce the same output");
+    }
+
+    public void testListIncludeWithGlob() {
+        JImageResult listAll = jimage("list", getImagePath()).assertSuccess();
+        Set<String> expected = Stream.of(listAll.output.split("[" + System.lineSeparator() + "]+"))
+                .map(String::trim)
+                .filter(s -> s.startsWith("java/util/zip"))
+                .collect(Collectors.toSet());
+
+        JImageResult listJavaUtil = jimage("list", "--include", "/java.base/java/util/zip/**", getImagePath()).assertSuccess();
+        Set<String> actual = Stream.of(listJavaUtil.output.split("[" + System.lineSeparator() + "]+"))
+                .map(String::trim)
+                .filter(s -> !s.startsWith("jimage:") && !s.startsWith("Module:"))
+                .collect(Collectors.toSet());
+        assertEquals(actual, expected, "All java.util.zip classes are listed");
+    }
+
+    public void testListIncludeNoMatchWithGlob() {
+        JImageResult listNotMatching = jimage("list", "--include", "not_matching", getImagePath()).assertSuccess();
+        Set<String> entries = Stream.of(listNotMatching.output.split("["+ System.lineSeparator() + "]+"))
+                .map(String::trim)
+                .filter(s -> !s.startsWith("jimage:") && !s.startsWith("Module:"))
+                .collect(Collectors.toSet());
+        assertEquals(entries, Collections.emptySet(), "No java.util classes are listed");
+    }
+
+    public void testListIncludeAllWithExplicitGlob() {
+        JImageResult listAll = jimage("list", getImagePath()).assertSuccess();
+        JImageResult listAllGlob = jimage("list", "--include", "glob:**", getImagePath()).assertSuccess();
+        assertEquals(listAllGlob.output, listAll.output, "--include glob:** should produce the same output");
+    }
+
+    public void testListIncludeAllWithRegex() {
+        JImageResult listAll = jimage("list", getImagePath()).assertSuccess();
+        JImageResult listAllRegex = jimage("list", "--include", "regex:.*", getImagePath()).assertSuccess();
+        assertEquals(listAllRegex.output, listAll.output, "--include regex:.* should produce the same output");
+    }
+
+    public void testListIncludeWithRegex() {
+        JImageResult listAll = jimage("list", getImagePath()).assertSuccess();
+        Set<String> expected = Stream.of(listAll.output.split("[" + System.lineSeparator() + "]+"))
+                .map(String::trim)
+                .filter(s -> s.startsWith("java/text/"))
+                .collect(Collectors.toSet());
+        assertFalse(expected.isEmpty(), "There should be classes from java.text package");
+
+        JImageResult listJavaText = jimage("list", "--include", "regex:/java.base/java/text/.*", getImagePath()).assertSuccess();
+        Set<String> actual = Stream.of(listJavaText.output.split("[" + System.lineSeparator() + "]+"))
+                .map(String::trim)
+                .filter(s -> !s.startsWith("jimage:") && !s.startsWith("Module:"))
+                .collect(Collectors.toSet());
+
+        assertEquals(actual, expected, "All java.text classes are listed");
+    }
+
+    public void testListIncludeNoMatchWithRegex() {
+        JImageResult listNotMatching = jimage("list", "--include", "regex:not_matching",
+                getImagePath()).assertSuccess();
+        Set<String> entries = Stream.of(listNotMatching.output.split("[" + System.lineSeparator() + "]+"))
+                .map(String::trim)
+                .filter(s -> !s.startsWith("jimage:") && !s.startsWith("Module:"))
+                .collect(Collectors.toSet());
+        assertEquals(entries, Collections.emptySet(), "No classes are listed");
+    }
+
+    public void testListIncludeMultiplePatterns() throws IOException {
+        JImageResult listAll = jimage("list", getImagePath()).assertSuccess();
+        Set<String> expected = Stream.of(listAll.output.split("[" + System.lineSeparator() + "]+"))
+                .map(String::trim)
+                .filter(s -> s.startsWith("java/time/") || s.startsWith("java/util/zip"))
+                .collect(Collectors.toSet());
+        assertFalse(expected.isEmpty(), "There should be classes from java.time and java.io packages");
+
+        JImageResult listMatched = jimage("list", "--include", "glob:/java.base/java/time/**,regex:/java.base/java/util/zip/.*",
+                getImagePath()).assertSuccess();
+        Set<String> actual = Stream.of(listMatched.output.split("[" + System.lineSeparator() + "]+"))
+                .map(String::trim)
+                .filter(s -> !s.startsWith("jimage:") && !s.startsWith("Module:"))
+                .collect(Collectors.toSet());
+
+        assertEquals(actual, expected, "All java.time and java.util.zip classes are listed");
+    }
+
+    public void testListNoImageSpecified() {
+        jimage("list", "")
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testListEmptyFile() throws IOException {
+        Path tmp = Files.createTempFile(Paths.get("."), getClass().getName(), "empty_file");
+        jimage("list", tmp.toString())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testListNotAnImage() throws IOException {
+        Path tmp = Files.createTempFile(Paths.get("."), getClass().getName(), "not_an_image");
+        Files.write(tmp, "This is not an image".getBytes());
+        jimage("list", tmp.toString())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testListNotExistingImage() throws IOException {
+        Path tmp = Paths.get(".", "not_existing_image");
+        Files.deleteIfExists(tmp);
+        jimage("list", tmp.toString())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testListWithUnknownOption() {
+        jimage("list", "--unknown")
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public static void main(String[] args) throws Throwable {
+        new JImageListTest().runTests();
+    }
+}
+
--- a/jdk/test/tools/jimage/JImageToolTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/tools/jimage/JImageToolTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,8 @@
 /*
  * @test
  * @library /lib/testlibrary
- * @build jdk.testlibrary.*
- * @summary Test to see if jimage tool extracts and recreates correctly.
+ * @build jdk.testlibrary.ProcessTools
+ * @summary Test to check if jimage tool exists and is working
  * @run main/timeout=360 JImageToolTest
  */
 
@@ -42,7 +42,7 @@
 public class JImageToolTest {
     private static void jimage(String... jimageArgs) throws Exception {
         ArrayList<String> args = new ArrayList<>();
-        args.add("-ms8m");
+        args.add("-ms64m");
         args.add("jdk.tools.jimage.Main");
         args.addAll(Arrays.asList(jimageArgs));
 
@@ -61,11 +61,7 @@
 
         if (Files.exists(jimagePath) && Files.exists(modulesimagePath)) {
             String jimage = jimagePath.toAbsolutePath().toString();
-            String bootimage = modulesimagePath.toAbsolutePath().toString();
-            String extractDir = Paths.get(".", "extract").toAbsolutePath().toString();
-            jimage("list", bootimage);
-            jimage("verify", bootimage);
-            jimage("extract", "--dir", extractDir, bootimage);
+            jimage("--version");
             System.out.println("Test successful");
          } else {
             System.out.println("Test skipped, not an images build");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jimage/JImageVerifyTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests to verify jimage 'verify' action
+ * @library /test/lib
+ * @modules jdk.jlink/jdk.tools.jimage
+ * @build jdk.test.lib.Asserts
+ * @run main JImageVerifyTest
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+import static jdk.test.lib.Asserts.assertTrue;
+
+public class JImageVerifyTest extends JImageCliTest {
+
+    public void testVerify() {
+        jimage("verify", getImagePath())
+                .assertSuccess()
+                .resultChecker(r -> {
+                    assertTrue(r.output.startsWith("jimage: " + getImagePath()),
+                            "Contains verified image's path");
+                });
+    }
+
+    public void testVerifyHelp() {
+        for (String opt : Arrays.asList("-h", "--help")) {
+            jimage("verify", opt)
+                    .assertSuccess()
+                    .resultChecker(r -> {
+                        // verify  -  descriptive text
+                        assertMatches("\\s+verify\\s+-\\s+.*", r.output);
+                    });
+        }
+    }
+
+    public void testVerifyImageNotSpecified() {
+        jimage("verify", "")
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testVerifyNotAnImage() throws IOException {
+        Path tmp = Files.createTempFile(Paths.get("."), getClass().getName(), "not_an_image");
+        jimage("verify", tmp.toString())
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testVerifyNotExistingImage() throws IOException {
+        Path tmp = Paths.get(".", "not_existing_image");
+        Files.deleteIfExists(tmp);
+        jimage("verify", "")
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public void testVerifyWithUnknownOption() {
+        jimage("verify", "--unknown")
+                .assertFailure()
+                .assertShowsError();
+    }
+
+    public static void main(String[] args) throws Throwable {
+        new JImageVerifyTest().runTests();
+    }
+
+}
--- a/jdk/test/tools/jlink/JLinkSigningTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/tools/jlink/JLinkSigningTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -26,24 +26,31 @@
  * @bug 8159393
  * @summary Test signed jars involved in image creation
  * @modules java.base/jdk.internal.jimage
- *          jdk.jlink/jdk.tools.jlink.internal
+ *          java.base/sun.security.tools.keytool
  *          jdk.compiler/com.sun.tools.javac
- *          java.base/sun.security.tools.keytool
  *          jdk.jartool/sun.security.tools.jarsigner
  *          jdk.jartool/sun.tools.jar
+ *          jdk.jlink/jdk.tools.jlink.internal
  * @run main/othervm JLinkSigningTest
  */
 
 
 import java.io.File;
 import java.io.IOException;
-import java.io.PrintWriter;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
+import java.util.spi.ToolProvider;
 
 public class JLinkSigningTest {
+    private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+            .orElseThrow(() -> new RuntimeException("jar tool not found"));
+    private static final ToolProvider JAVAC_TOOL = ToolProvider.findFirst("javac")
+            .orElseThrow(() -> new RuntimeException("javac tool not found"));
+    private static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
+            .orElseThrow(() -> new RuntimeException("jlink tool not found"));
+
     static final String[] MODULE_INFO = {
         "module test {",
         "}",
@@ -61,22 +68,29 @@
         System.out.println(command + " " + String.join(" ", Arrays.asList(args)));
     }
 
-    static void javac(String[] args) {
-        report("javac", args);
-        com.sun.tools.javac.Main javac = new com.sun.tools.javac.Main();
+    static void jar(String[] args) {
+        report("jar", args);
+        JAR_TOOL.run(System.out, System.err, args);
+    }
 
-        if (javac.compile(args) != 0) {
-            throw new RuntimeException("javac failed");
+    static void jarsigner(String[] args) {
+        report("jarsigner", args);
+
+        try {
+            sun.security.tools.jarsigner.Main.main(args);
+        } catch (Exception ex) {
+            throw new RuntimeException("jarsigner not found");
         }
     }
 
-    static void jar(String[] args) {
-        report("jar", args);
-        sun.tools.jar.Main jar = new sun.tools.jar.Main(System.out, System.err, "jar");
+    static void javac(String[] args) {
+        report("javac", args);
+        JAVAC_TOOL.run(System.out, System.err, args);
+    }
 
-        if (!jar.run(args)) {
-            throw new RuntimeException("jar failed");
-        }
+    static void jlink(String[] args) {
+        report("jlink", args);
+        JLINK_TOOL.run(System.out, System.err, args);
     }
 
     static void keytool(String[] args) {
@@ -89,28 +103,6 @@
         }
     }
 
-    static void jarsigner(String[] args) {
-        report("jarsigner", args);
-
-        try {
-            sun.security.tools.jarsigner.Main.main(args);
-        } catch (Exception ex) {
-            throw new RuntimeException("jarsigner failed");
-        }
-    }
-
-    static void jlink(String[] args) {
-        report("jlink", args);
-
-        try {
-            jdk.tools.jlink.internal.Main.run(new PrintWriter(System.out, true),
-                                              new PrintWriter(System.err, true),
-                                              args);
-        } catch (Exception ex) {
-            throw new RuntimeException("jlink failed");
-        }
-    }
-
     public static void main(String[] args) {
         final String JAVA_HOME = System.getProperty("java.home");
         Path moduleInfoJavaPath = Paths.get("module-info.java");
--- a/jdk/test/tools/launcher/modules/classpath/JavaClassPathTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/tools/launcher/modules/classpath/JavaClassPathTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -21,12 +21,14 @@
  * questions.
  */
 
+import java.io.BufferedWriter;
 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.Map;
+import java.util.spi.ToolProvider;
 
 import jdk.testlibrary.OutputAnalyzer;
 import org.testng.annotations.BeforeTest;
@@ -42,6 +44,7 @@
  * @summary Test the default class path if -Djava.class.path is set
  * @library /lib/testlibrary
  * @modules jdk.compiler
+ *          jdk.jartool
  * @build CompilerUtils jdk.testlibrary.*
  * @run testng JavaClassPathTest
  */
@@ -50,6 +53,7 @@
     private static final Path SRC_DIR = Paths.get(System.getProperty("test.src"),
                                                   "src");
     private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path LIB_DIR = Paths.get("lib");
     private static final String TEST_MODULE = "m";
     private static final String TEST_MAIN = "jdk.test.Main";
 
@@ -66,27 +70,47 @@
 
         Path res = Paths.get("jdk/test/res.properties");
         Files.createFile(res);
+
+        ToolProvider jartool = ToolProvider.findFirst("jar").orElseThrow(
+            () -> new RuntimeException("jar tool not found")
+        );
+
+        Path jarfile = LIB_DIR.resolve("m.jar");
+        Files.createDirectories(LIB_DIR);
+        assertTrue(jartool.run(System.out, System.err, "cfe",
+                               jarfile.toString(), TEST_MAIN,
+                               file.toString()) == 0);
+
+        Path manifest = LIB_DIR.resolve("manifest");
+        try (BufferedWriter writer = Files.newBufferedWriter(manifest)) {
+            writer.write("CLASS-PATH: lib/m.jar");
+        }
+        jarfile = LIB_DIR.resolve("m1.jar");
+        assertTrue(jartool.run(System.out, System.err, "cfme",
+                               jarfile.toString(), manifest.toString(), TEST_MAIN,
+                               file.toString()) == 0);
     }
 
     @DataProvider(name = "classpath")
     public Object[][] classpath() {
         return new Object[][]{
             // true indicates that class path default to current working directory
-            { "",                              true  },
-            { "-Djava.class.path",             true  },
-            { "-Djava.class.path=",            true  },
-            { "-Djava.class.path=.",           true  },
+            { "",                              "."  },
+            { "-Djava.class.path",             "."  },
+            { "-Djava.class.path=",            ""  },
+            { "-Djava.class.path=.",           "."  },
         };
     }
 
     @Test(dataProvider = "classpath")
-    public void testUnnamedModule(String option, boolean expected) throws Throwable {
+    public void testUnnamedModule(String option, String expected) throws Throwable {
         List<String> args = new ArrayList<>();
         if (!option.isEmpty()) {
             args.add(option);
         }
         args.add(TEST_MAIN);
-        args.add(Boolean.toString(expected));
+        args.add(Boolean.toString(true));
+        args.add(expected);
 
         assertTrue(execute(args).getExitValue() == 0);
     }
@@ -95,15 +119,14 @@
     public Object[][] moduleAndClassPath() {
         return new Object[][]{
             // true indicates that class path default to current working directory
-            { "",                              false  },
-            { "-Djava.class.path",             false  },
-            { "-Djava.class.path=",            false  },
-            { "-Djava.class.path=.",           true   },
+            { "",                              ""  },
+            { "-Djava.class.path",             ""  },
+            { "-Djava.class.path=",            ""  },
         };
     }
 
     @Test(dataProvider = "moduleAndClassPath")
-    public void testNamedModule(String option, boolean expected) throws Throwable {
+    public void testNamedModule(String option, String expected) throws Throwable {
         List<String> args = new ArrayList<>();
         if (!option.isEmpty()) {
             args.add(option);
@@ -112,7 +135,61 @@
         args.add(MODS_DIR.toString());
         args.add("-m");
         args.add(TEST_MODULE + "/" + TEST_MAIN);
-        args.add(Boolean.toString(expected));
+        // not default to CWD
+        args.add(Boolean.toString(false));
+        args.add(expected);
+
+
+        assertTrue(execute(args).getExitValue() == 0);
+    }
+
+    @Test
+    public void testClassPath() throws Throwable {
+        List<String> args = new ArrayList<>();
+        args.add("-Djava.class.path=.");
+        args.add("--module-path");
+        args.add(MODS_DIR.toString());
+        args.add("-m");
+        args.add(TEST_MODULE + "/" + TEST_MAIN);
+        args.add(Boolean.toString(true));
+        args.add(".");
+
+        assertTrue(execute(args).getExitValue() == 0);
+    }
+
+    @Test
+    public void testJAR() throws Throwable {
+        String jarfile = LIB_DIR.resolve("m.jar").toString();
+        List<String> args = new ArrayList<>();
+        args.add("-jar");
+        args.add(jarfile);
+        args.add(Boolean.toString(false));
+        args.add(jarfile);
+
+        assertTrue(execute(args).getExitValue() == 0);
+    }
+
+    /*
+     * Test CLASS-PATH attribute in manifest
+     */
+    @Test
+    public void testClassPathAttribute() throws Throwable {
+        String jarfile = LIB_DIR.resolve("m1.jar").toString();
+
+        List<String> args = new ArrayList<>();
+        args.add("-jar");
+        args.add(jarfile);
+        args.add(Boolean.toString(false));
+        args.add(jarfile);
+
+        assertTrue(execute(args).getExitValue() == 0);
+
+        args.clear();
+        args.add("-cp");
+        args.add(jarfile);
+        args.add(TEST_MAIN);
+        args.add(Boolean.toString(false));
+        args.add(jarfile);
 
         assertTrue(execute(args).getExitValue() == 0);
     }
--- a/jdk/test/tools/launcher/modules/classpath/src/m/jdk/test/Main.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/jdk/test/tools/launcher/modules/classpath/src/m/jdk/test/Main.java	Wed Jul 05 22:30:23 2017 +0200
@@ -29,13 +29,14 @@
     static final String JAVA_CLASS_PATH = "java.class.path";
 
     public static void main(String[] args) throws Exception {
+        boolean expected = args[0].equals("true");
+        String cpath = args.length > 1 ? args[1] : "";
         String value = System.getProperty(JAVA_CLASS_PATH);
-        if (value == null) {
-            throw new RuntimeException(JAVA_CLASS_PATH + " is expected non-null" +
-                " for compatibility");
+        if (!value.equals(cpath)) {
+            throw new RuntimeException(JAVA_CLASS_PATH + "=" + value +
+                " expected=" + cpath);
         }
 
-        boolean expected = args[0].equals("true");
         ClassLoader loader = ClassLoader.getSystemClassLoader();
         URL url = loader.getResource("jdk/test/res.properties");
         if ((expected && url == null) || (!expected && url != null)) {
--- a/make/Bundles.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/Bundles.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -101,7 +101,7 @@
 	          ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) $$($1_SUBDIR) $(TAR_IGNORE_EXIT_VALUE) ) \
 	          | $(GZIP) > $$@
             else ifeq ($$($1_TYPE), zip)
-	      $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && $(ZIP) -qr $$@ .
+	      $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && $(ZIPEXE) -qr $$@ .
             endif
           endif
         else
@@ -113,7 +113,7 @@
 	        | $(GZIP) > $$@
           else ifeq ($$($1_TYPE), zip)
 	    $(CD) $$($1_BASE_DIR) \
-	        && $(ZIP) -qr $$@ . -i@$(SUPPORT_OUTPUTDIR)/bundles/_$1_files
+	        && $(ZIPEXE) -qr $$@ . -i@$(SUPPORT_OUTPUTDIR)/bundles/_$1_files
           endif
         endif
 
--- a/make/CompileJavaModules.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/CompileJavaModules.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -95,7 +95,7 @@
 ################################################################################
 
 java.desktop_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference \
-    '-Xdoclint/package:java.*,javax.*' -Xlint:-deprecation,exports
+    '-Xdoclint/package:java.*,javax.*' -Xlint:exports
 java.desktop_COPY := .gif .png .wav .txt .xml .css .pf
 java.desktop_CLEAN := iio-plugin.properties cursors.properties
 
--- a/make/Images.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/Images.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -131,7 +131,7 @@
     $(JLINK_JLI_CLASSES) \
     #
 
-JLINK_JRE_EXTRA_OPTS := --no-man-pages --no-header-files
+JLINK_JRE_EXTRA_OPTS := --no-man-pages --no-header-files --strip-debug
 
 ifeq ($(JLINK_KEEP_PACKAGED_MODULES), true)
   JLINK_JDK_EXTRA_OPTS := --keep-packaged-modules $(JDK_IMAGE_DIR)/jmods
--- a/make/Javadoc.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/Javadoc.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -50,17 +50,6 @@
 # Should we use -Xdocrootparent? Allow custom to overwrite.
 DOCROOTPARENT_FLAG = TRUE
 
-# The core api index file is the target for the core api javadocs rule
-# and needs to be defined early so that all other javadoc rules may
-# depend on it.
-CORE_INDEX_FILE := $(JAVADOC_OUTPUTDIR)/api/index.html
-
-# Symbols
-TRADEMARK := &trade;
-COPYRIGHT_SYMBOL := &$(HASH)x00a9;
-COPYRIGHT_TEXT := Copyright
-ALL_RIGHTS_RESERVED := All rights reserved.
-
 # URLs
 JAVADOC_BASE_URL := http://docs.oracle.com/javase/$(VERSION_SPECIFICATION)/docs
 BUG_SUBMIT_URL := http://bugreport.java.com/bugreport/
@@ -69,79 +58,131 @@
 # Text snippets
 
 FULL_COMPANY_NAME := Oracle and/or its affiliates
-COMPANY_ADDRESS := 500 Oracle Parkway<br>Redwood Shores, CA 94065 USA.
+COMPANY_ADDRESS := 500 Oracle Parkway<br>Redwood Shores, CA 94065 USA
 BUG_SUBMIT_LINE := <a href="$(BUG_SUBMIT_URL)">Submit a bug or feature</a>
-JAVA_TRADEMARK_LINE := Java is a trademark or registered trademark of \
-    $(FULL_COMPANY_NAME) in the US and other countries.
 
-COMMON_BOTTOM_ADDRESS := $(COMPANY_ADDRESS)
-COMMON_BOTTOM_TEXT := $(BUG_SUBMIT_LINE)<br>$(JAVA_TRADEMARK_LINE)
+COMMON_BOTTOM_TEXT := $(BUG_SUBMIT_LINE)<br> Java is a trademark or registered \
+    trademark of $(FULL_COMPANY_NAME) in the US and other countries.
 
 CORE_BOTTOM_COPYRIGHT_URL := {@docroot}/../legal/cpyr.html
-CORE_BOTTOM_TEXT := $(BUG_SUBMIT_LINE)\
-<br>For further API reference and developer documentation, \
-see <a href="$(JAVADOC_BASE_URL)/index.html" target="_blank">Java SE \
-Documentation</a>. That documentation contains more detailed, \
-developer-targeted descriptions, with conceptual overviews, definitions of \
-terms, workarounds, and working code examples.
+CORE_BOTTOM_TEXT := \
+    $(BUG_SUBMIT_LINE) \
+    <br>For further API reference and developer documentation, see \
+    <a href="$(JAVADOC_BASE_URL)/index.html" target="_blank">Java SE \
+    Documentation</a>. That documentation contains more detailed, \
+    developer-targeted descriptions, with conceptual overviews, definitions of \
+    terms, workarounds, and working code examples.
 
 ifeq ($(VERSION_IS_GA), true)
-  DRAFT_HEADER :=
-  DRAFT_BOTTOM :=
-  DRAFT_WINTITLE :=
-  CORE_TOP_EARLYACCESS :=
+  DRAFT_MARKER :=
+  DRAFT_WINDOW_TITLE_MARKER :=
+  EARLYACCESS_TOP :=
 else
   # We need a draft format when not building the GA version.
-  DRAFT_HEADER := <br><strong>DRAFT&nbsp;$(VERSION_STRING)</strong>
-  DRAFT_BOTTOM := <br><strong>DRAFT&nbsp;$(VERSION_STRING)</strong>
-  DRAFT_WINTITLE := $(VERSION_BUILD)
-  CORE_TOP_EARLYACCESS := \
-<div style="background-color: $$(HASH)EEEEEE"> \
-<div style="padding: 6px; margin-top: 2px; margin-bottom: 6px; \
-margin-left: 6px; margin-right: 6px; text-align: justify; \
-font-size: 80%; font-family: Helvetica, Arial, sans-serif; \
-font-weight: normal;"> \
-Please note that the specifications and other information \
-contained herein are not final and are subject to change. \
-The information is being made available to you solely for purpose of \
-evaluation. \
-</div> </div>
+  DRAFT_MARKER := <br><strong>DRAFT&nbsp;$(VERSION_STRING)</strong>
+  ifeq ($(VERSION_BUILD), 0)
+    DRAFT_WINDOW_TITLE_MARKER := $(SPACE)[ad-hoc build]
+  else
+    DRAFT_WINDOW_TITLE_MARKER := $(SPACE)[build $(VERSION_BUILD)]
+  endif
+  EARLYACCESS_TOP := \
+      <div style="background-color: $$(HASH)EEEEEE"><div style="padding: 6px; \
+      margin-top: 2px; margin-bottom: 6px; margin-left: 6px; margin-right: \
+      6px; text-align: justify; font-size: 80%; font-family: Helvetica, Arial, \
+      sans-serif; font-weight: normal;">Please note that the specifications \
+      and other information contained herein are not final and are subject to \
+      change. The information is being made available to you solely for \
+      purpose of evaluation.</div></div>
 endif
 
 ################################################################################
+# Special treatment for the core package list. All separate "small" javadoc
+# invocation needs to be able to see the core package list.
+
+ALL_PKG_DIRS := $(dir $(filter %.java, $(call CacheFind, \
+    $(wildcard $(JAVADOC_SOURCE_DIRS)))))
+ALL_SRC_PREFIXES := $(addsuffix /%, $(wildcard $(JAVADOC_SOURCE_DIRS)))
+ALL_PKG_DIRNAMES := $(foreach prefix, $(ALL_SRC_PREFIXES), \
+    $(patsubst $(prefix),%, $(filter $(prefix), $(ALL_PKG_DIRS))))
+ALL_PACKAGES := $(sort $(subst /,., $(patsubst %/, %, $(ALL_PKG_DIRNAMES))))
+
+# Core packages are all packages beginning with java, javax or org, except a few
+# excludes.
+JAVA_PACKAGES := $(filter java.%, $(ALL_PACKAGES))
+JAVAX_PACKAGES := $(filter javax.%, $(ALL_PACKAGES))
+ORG_PACKAGES := $(filter org.%, $(ALL_PACKAGES))
+
+# Allow custom makefile to add more excluded packages
+CORE_EXCLUDED_PACKAGES += \
+    java.awt.dnd.peer \
+    java.awt.peer \
+    javax.smartcardio \
+    org.jcp.xml.dsig.internal% \
+    org.w3c.dom.css \
+    org.w3c.dom.html \
+    org.w3c.dom.stylesheets \
+    org.w3c.dom.xpath \
+    #
+
+CORE_PACKAGES := $(filter-out $(CORE_EXCLUDED_PACKAGES), \
+    $(JAVA_PACKAGES) $(JAVAX_PACKAGES) $(ORG_PACKAGES))
+
+CORE_PACKAGES_LIST_DIR := $(SUPPORT_OUTPUTDIR)/docs/core-packages
+CORE_PACKAGES_LIST_FILE := $(CORE_PACKAGES_LIST_DIR)/package-list
+
+CORE_PACKAGES_VARDEPS_FILE := $(call DependOnVariable, CORE_PACKAGES, \
+    $(CORE_PACKAGES_LIST_FILE).vardeps)
+
+$(CORE_PACKAGES_LIST_FILE): $(CORE_PACKAGES_VARDEPS_FILE)
+	$(call MakeDir, $(@D))
+	$(eval $(call ListPathsSafely, CORE_PACKAGES, $@))
+
+################################################################################
 # Support functions for SetupJavadocGeneration
 
-# Print an option line to the target file
-# Arguments:
-# arg 1: the option name
-# arg 2-3: optional arguments to the option
-define AddOption
-	$(PRINTF) "%s$(if $(strip $2), '%s',)$(if $(strip $3), '%s',)\n" \
-	    "$(strip $1)"$(if $(strip $2), '$(strip $2)',)$(if $(strip $3), \
-	    '$(strip $3)',) >> $@
-endef
-
-# This function goes to great pains to exactly mimic the old behavior
-# in all details, including whitespace.
+# Generate the text used in the -bottom argument.
 # Note that COPYRIGHT_YEAR is the current year (from spec.gmk)
 # Arguments:
 # arg 1: first copyright year
 # arg 2: copyright url (optional)
-# arg 3: company address (optional)
-# arg 4: free-form text snippet (optional)
+# arg 3: free-form text snippet (optional)
 define GenerateBottom
-  <font size="-1">$(if $(strip $4), $(strip $4))<br> $(if \
-      $(strip $2),<a href="$(strip $2)">$(COPYRIGHT_TEXT)</a>,$(COPYRIGHT_TEXT)) \
-      $(COPYRIGHT_SYMBOL) $(strip $1), $(COPYRIGHT_YEAR), \
-      $(FULL_COMPANY_NAME). $(strip $3) \
-      $(ALL_RIGHTS_RESERVED)$(if $(strip $4), )</font>
+  <font size="-1">$(if $(strip $3), $(strip $3))<br> $(if \
+      $(strip $2),<a href="$(strip $2)">Copyright</a>,Copyright) \
+      &copy; $(strip $1), $(COPYRIGHT_YEAR), $(FULL_COMPANY_NAME). \
+      $(COMPANY_ADDRESS). All rights reserved.</font>
 endef
 
 # Speed up finding by filling cache
 $(eval $(call FillCacheFind, $(wildcard $(JAVADOC_SOURCE_DIRS))))
 
-# Prevent # from expanding
-EscapeHash = $(subst $(HASH),{hash},$(strip $1))
+# In order to get a specific ordering it's necessary to specify the total
+# ordering of tags as the tags are otherwise ordered in order of definition.
+DEFAULT_JAVADOC_TAGS := \
+    -tag beaninfo:X \
+    -tag revised:X \
+    -tag since.unbundled:X \
+    -tag spec:X \
+    -tag specdefault:X \
+    -tag Note:X \
+    -tag ToDo:X \
+    -tag 'apiNote:a:API Note:' \
+    -tag 'implSpec:a:Implementation Requirements:' \
+    -tag 'implNote:a:Implementation Note:' \
+    -tag param \
+    -tag return \
+    -tag throws \
+    -tag since \
+    -tag version \
+    -tag serialData \
+    -tag factory \
+    -tag see \
+    -tag 'jvms:a:See <cite>The Java&trade; Virtual Machine Specification</cite>:' \
+    -tag 'jls:a:See <cite>The Java&trade; Language Specification</cite>:' \
+    #
+
+DEFAULT_JAVADOC_OPTIONS := -XDignore.symbol.file=true -use -keywords -notimestamp \
+    -serialwarn -encoding ISO-8859-1 -breakiterator --system none
 
 ################################################################################
 # Setup make rules for running javadoc.
@@ -154,7 +195,6 @@
 # Remaining parameters are named arguments. These include:
 #   MODULES - Modules to include
 #   PACKAGES - Packages to include
-#   PACKAGE_FILTER - Filter for packages
 #   IS_CORE - Set to TRUE for the Core API package which needs special treatment
 #   API_ROOT - Where to base the documentation (jre or jdk)
 #   DEST_DIR - A directory relative to the API root
@@ -164,15 +204,10 @@
 #   HEADER_TITLE - Title to use in -header. Computed from TITLE if empty.
 #   DOC_TITLE - Title to use in -doctitle. Computed from TITLE if empty.
 #   FIRST_COPYRIGHT_YEAR - First year this bundle was introduced
-#   DOCLINT - Doclint level. Defaults to "all".
+#   DISABLED_DOCLINT - Doclint warnings to exclude.
 #   DOCLINT_PACKAGES - Optional -Xdoclint/package value
-#   ENCODING - Change character encoding (defaults to 'ascii')
-#   SPLIT_INDEX - Enable -splitIndex
-#   BREAKITERATOR - Enable -breakiterator
-#   NODEPRECATEDLIST - Enable nodeprecatedlist
-#   NOINDEX - Enable -noindex and -nonavbar
+#   SPLIT_INDEX - Enable -splitIndex (split index-all.html if it is too large)
 #   BOTTOM_COPYRIGHT_URL - Copyright URL to use in -bottom
-#   BOTTOM_ADDRESS - Company address to use in -bottom
 #   BOTTOM_TEXT - Extra text to use in -bottom
 #   EXTRA_TOP - Additional -top data
 #
@@ -185,181 +220,104 @@
     $1_JAVA := $$(JAVA_SMALL)
     $1_OUTPUT_DIRNAME := $$($1_API_ROOT)/api/$$($1_DEST_DIR)
 
-    ifeq ($$($1_RELATIVE_CORE_DIR),)
-      # Compute a relative path to core root.
-      # The non-core api javadocs need to be able to access the root of the core
-      # api directory, so for jdk/api or jre/api to get to the core api/
-      # directory we would use this
-      # NOTE: Need to be able to override for broken old code in JShell
-      $1_RELATIVE_CORE_DIR := $$(strip $$(subst $$(call DirToDotDot, \
-          $$(JAVADOC_OUTPUTDIR))/,, $$(call DirToDotDot, \
-          $$(JAVADOC_OUTPUTDIR)/$$($1_OUTPUT_DIRNAME))))
-    endif
+    # Compute a relative path to core root.
+    # The non-core api javadocs need to be able to access the root of the core
+    # api directory, so for jdk/api or jre/api to get to the core api/
+    # directory we would use this
+    $1_RELATIVE_CORE_DIR := $$(call DirToDotDot, $$($1_OUTPUT_DIRNAME))/api
 
-    $1_DEPS += $(CORE_INDEX_FILE)
+    # We need to tell javadoc the directory in which to find the core package-list
+    $1_OPTIONS += -linkoffline $$($1_RELATIVE_CORE_DIR) $$(CORE_PACKAGES_LIST_DIR)
+
+    $1_DEPS += $(CORE_PACKAGES_LIST_FILE)
   endif
 
-  ifneq ($$($1_OVERVIEW), )
-    $1_DEPS +=  $$($1_OVERVIEW)
+  $1_OPTIONS += --add-modules $$(call CommaList, $$($1_MODULES))
+
+  ifneq ($$(LOG_LEVEL), trace)
+    $1_OPTIONS += -quiet
   endif
 
-  ifeq ($$($1_ENCODING), )
-    $1_ENCODING := ascii
+  ifneq ($$($1_DISABLED_DOCLINT), )
+    # Create a string like ",-syntax,-html"
+    $1_DOCLINT_EXCEPTIONS := ,$$(call CommaList, $$(addprefix -, $$($1_DISABLED_DOCLINT)))
   endif
+  $1_OPTIONS += -Xdoclint:all$$($1_DOCLINT_EXCEPTIONS)
 
-  ifeq ($$($1_DOCLINT), )
-    $1_DOCLINT := all
+  ifneq ($$($1_DOCLINT_PACKAGES), )
+    $1_OPTIONS += -Xdoclint/package:$$(call CommaList, $$($1_DOCLINT_PACKAGES))
   endif
 
   ifeq ($$($1_DOC_TITLE), )
     $1_DOC_TITLE := $$($1_TITLE)
   endif
+  $1_OPTIONS += -doctitle '$$($1_DOC_TITLE)'
 
   ifeq ($$($1_WINDOW_TITLE), )
-    $1_WINDOW_TITLE := $$(strip $$(subst $$(TRADEMARK),, $$($1_TITLE)))
+    $1_WINDOW_TITLE := $$(strip $$(subst &trade;,, $$($1_TITLE)))
   endif
+  $1_OPTIONS += -windowtitle '$$($1_WINDOW_TITLE)$$(DRAFT_WINDOW_TITLE_MARKER)'
 
   ifeq ($$($1_HEADER_TITLE), )
-    $1_HEADER_TITLE := $$(strip $$(subst $$(TRADEMARK),, $$($1_TITLE)))
+    $1_HEADER_TITLE := $$(strip $$(subst &trade;,, $$($1_TITLE)))
   endif
-  $1_HEADER := <strong>$$($1_HEADER_TITLE)</strong>
-
-  $1_BOTTOM := $$(call GenerateBottom, $$($1_FIRST_COPYRIGHT_YEAR), \
-      $$($1_BOTTOM_COPYRIGHT_URL), $$($1_BOTTOM_ADDRESS), $$($1_BOTTOM_TEXT))
-
-  # The index.html, options, and packages files
-  $1_INDEX_FILE := $$(JAVADOC_OUTPUTDIR)/$$($1_OUTPUT_DIRNAME)/index.html
-  $1_OPTIONS_FILE := $$(SUPPORT_OUTPUTDIR)/docs/$1.options
-  $1_PACKAGES_FILE := $$(SUPPORT_OUTPUTDIR)/docs/$1.packages
-
-  $1_PACKAGES_VARDEPS := $$($1_PACKAGES) $$($1_PACKAGES_SINGLE_CLASS)
-  $1_PACKAGES_VARDEPS_FILE := $$(call DependOnVariable, $1_PACKAGES_VARDEPS, \
-       $$($1_PACKAGES_FILE).vardeps)
+  $1_OPTIONS += -header '<strong>$$($1_HEADER_TITLE)</strong>$$(DRAFT_MARKER)'
 
-  # Rule for creating a file with the package names in it
-  $$($1_PACKAGES_FILE): $$($1_PACKAGES_VARDEPS_FILE)
-	$$(call LogInfo, Creating Javadoc package file for $1)
-	$$(call MakeDir, $$(@D))
-        ifeq ($$($1_PACKAGES_SINGLE_CLASS), )
-	  $$(ECHO) $$($1_PACKAGES) | $$(TR) ' ' '\n' > $$@
-        else
-          # NOTE: This is for backwards compatibility for taglet
-	  $$(ECHO) $$($1_PACKAGES_SINGLE_CLASS) > $$@
-        endif
+  ifneq ($$($1_EXTRA_TOP), )
+    $1_OPTIONS += -top '$$($1_EXTRA_TOP)'
+  endif
 
-  # NOTE: Not including $$($1_EXTRA_TOP) due to $$(HASH)
-  $1_OPTIONS_VARDEPS := $$(call EscapeHash, \
-      $$($DOCROOTPARENT_FLAG) $$(JAVADOC_BASE_URL) $$($1_NO_COMMON_TAGS) \
-      $$($1_DOCLINT) $$($1_DOCLINT_PACKAGES) $$(JAVADOC_SOURCE_DIRS) \
-      $$($1_MODULES) $$($1_ENCODING) $$($1_NODEPRECATEDLIST) \
-      $$($1_BREAKITERATOR) $$($1_SPLIT_INDEX) $$($1_OVERVIEW) \
-      $$($1_DOC_TITLE) $$($1_WINDOW_TITLE) $$(DRAFT_WINTITLE) \
-      $$($1_HEADER) $$(DRAFT_HEADER) $$($1_NOINDEX) $$($1_EXTRA_TOP_2) \
-      $$($1_BOTTOM) $$(DRAFT_BOTTOM)) $$($1_PACKAGE_FILTER) $$($1_RELATIVE_CORE_DIR) \
-      $$(JAVADOC_OUTPUTDIR) \
-  )
-  $1_OPTIONS_VARDEPS_FILE := $$(call DependOnVariable, $1_OPTIONS_VARDEPS, \
-       $$($1_OPTIONS_FILE).vardeps)
+  ifeq ($$($1_BOTTOM_TEXT), )
+    $1_BOTTOM_TEXT := $(COMMON_BOTTOM_TEXT)
+  endif
+  $1_BOTTOM := $$(call GenerateBottom, $$($1_FIRST_COPYRIGHT_YEAR), \
+      $$($1_BOTTOM_COPYRIGHT_URL), $$($1_BOTTOM_TEXT))
+  $1_OPTIONS += -bottom '$$($1_BOTTOM)$$(DRAFT_MARKER)'
 
-  # Rule for creating a file with javadoc options in it
-  $$($1_OPTIONS_FILE): $$($1_OPTIONS_VARDEPS_FILE)
-	$$(call LogInfo, Creating Javadoc options file for $1)
-	$$(call MakeDir, $$(@D))
-	$$(RM) $$@
-	$$(call AddOption, -XDignore.symbol.file=true)
-        ifneq ($$(LOG_LEVEL), trace)
-	  $$(call AddOption, -quiet)
-        endif
-	$$(call AddOption, -use)
-	$$(call AddOption, -keywords)
-        ifneq ($$($DOCROOTPARENT_FLAG), )
-          # NOTE: Argument to -Xdocrootparent is not quoted to keep backwards compatibility.
-	  $$(call AddOption, -Xdocrootparent $(JAVADOC_BASE_URL))
-        endif
-        ifneq ($$($1_NO_COMMON_TAGS), TRUE)
-          # In order to get a specific ordering it's necessary to specify the total
-          # ordering of tags as the tags are otherwise ordered in order of definition.
-	  $$(call AddOption, -tag, beaninfo:X)
-	  $$(call AddOption, -tag, revised:X)
-	  $$(call AddOption, -tag, since.unbundled:X)
-	  $$(call AddOption, -tag, spec:X)
-	  $$(call AddOption, -tag, specdefault:X)
-	  $$(call AddOption, -tag, Note:X)
-	  $$(call AddOption, -tag, ToDo:X)
-	  $$(call AddOption, -tag, apiNote:a:API Note:)
-	  $$(call AddOption, -tag, implSpec:a:Implementation Requirements:)
-	  $$(call AddOption, -tag, implNote:a:Implementation Note:)
-	  $$(call AddOption, -tag, param)
-	  $$(call AddOption, -tag, return)
-	  $$(call AddOption, -tag, throws)
-	  $$(call AddOption, -tag, since)
-	  $$(call AddOption, -tag, version)
-	  $$(call AddOption, -tag, serialData)
-	  $$(call AddOption, -tag, factory)
-	  $$(call AddOption, -tag, see)
-	  $$(call AddOption, -tag, \
-              jvms:a:See <cite> The Java&trade; Virtual Machine Specification</cite>:)
-	  $$(call AddOption, -tag, \
-              jls:a:See <cite> The Java&trade; Language Specification</cite>:)
-        endif
-	$$(call AddOption, -Xdoclint:$$($1_DOCLINT))
-        ifneq ($$($1_DOCLINT_PACKAGES), )
-	  $$(call AddOption, -Xdoclint/package:$$(call CommaList, $$($1_DOCLINT_PACKAGES)))
-        endif
-	$$(call AddOption, --system, none)
-	$$(call AddOption, --module-source-path, $$(subst ",, $$(call PathList, $$(JAVADOC_SOURCE_DIRS))))
-	$$(call AddOption, --add-modules, $$(call CommaList, $$($1_MODULES)))
-	$$(call AddOption, -encoding, $$($1_ENCODING))
-        ifneq ($$($1_NODEPRECATEDLIST), )
-	  $$(call AddOption, -nodeprecatedlist)
-        endif
-        ifneq ($$($1_BREAKITERATOR), )
-	  $$(call AddOption, -breakiterator)
-        endif
-        ifneq ($$($1_SPLIT_INDEX), )
-	  $$(call AddOption, -splitIndex)
-        endif
-        ifneq ($$($1_OVERVIEW), )
-	  $$(call AddOption, -overview, $$($1_OVERVIEW))
-        endif
-	$$(call AddOption, -doctitle, $$($1_DOC_TITLE))
-	$$(call AddOption, -windowtitle, $$($1_WINDOW_TITLE) $$(DRAFT_WINTITLE))
-	$$(call AddOption, -header, $$($1_HEADER)$$(DRAFT_HEADER))
-        ifneq ($$($1_NOINDEX), )
-	  $$(call AddOption, -nonavbar)
-	  $$(call AddOption, -noindex)
-        endif
-        ifneq ($$($1_EXTRA_TOP_2), )
-	  $$(call AddOption, -top,$$($1_EXTRA_TOP_2))
-        endif
-	$$(call AddOption, -bottom, $$($1_BOTTOM)$$(DRAFT_BOTTOM))
-        ifneq ($$($1_PACKAGE_FILTER), )
-	  $$(call AddOption, -group, Packages, $$($1_PACKAGE_FILTER))
-        endif
-        ifneq ($$($1_RELATIVE_CORE_DIR), )
-	  $$(call AddOption, -linkoffline, $$($1_RELATIVE_CORE_DIR)/api, $$(JAVADOC_OUTPUTDIR)/api/)
-        endif
-        ifneq ($$($1_EXTRA_TOP), )
-	  $$(call AddOption, -top, $$($1_EXTRA_TOP))
-        endif
+  ifneq ($$($1_OVERVIEW), )
+    $1_OPTIONS += -overview $$($1_OVERVIEW)
+    $1_DEPS +=  $$($1_OVERVIEW)
+  endif
+
+  ifneq ($$($1_SPLIT_INDEX), )
+    $1_OPTIONS += -splitIndex
+  endif
+
+  ifneq ($$($DOCROOTPARENT_FLAG), )
+    $1_OPTIONS += -Xdocrootparent $(JAVADOC_BASE_URL)
+  endif
+
+  $1_VARDEPS := $$($1_OPTIONS) $$($1_PACKAGES)
+  $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
+       $$(SUPPORT_OUTPUTDIR)/docs/$1.vardeps)
 
   $1_PACKAGE_DEPS := $$(call CacheFind, $$(wildcard $$(foreach p, \
       $$(subst .,/,$$(strip $$($1_PACKAGES))), \
       $$(addsuffix /$$p, $$(wildcard $$(JAVADOC_SOURCE_DIRS))))))
 
+  # If there are many packages, use an @-file...
+  ifneq ($$(word 17, $$($1_PACKAGES)), )
+    $1_PACKAGES_FILE := $$(SUPPORT_OUTPUTDIR)/docs/$1.packages
+    $1_PACKAGES_ARG := @$$($1_PACKAGES_FILE)
+  else
+    $1_PACKAGES_ARG := $$($1_PACKAGES)
+  endif
+
+  # The index.html which is a marker for all the output from javadoc.
+  $1_INDEX_FILE := $$(JAVADOC_OUTPUTDIR)/$$($1_OUTPUT_DIRNAME)/index.html
+
   # Rule for actually running javadoc
-  $$($1_INDEX_FILE): $$($1_OPTIONS_FILE) $$($1_PACKAGES_FILE) \
-    $$($1_PACKAGE_DEPS) $$($1_DEPS)
-	$$(call LogWarn, Generating Javadoc for $$($1_OUTPUT_DIRNAME))
+  $$($1_INDEX_FILE): $$($1_VARDEPS_FILE) $$($1_PACKAGE_DEPS) $$($1_DEPS)
+	$$(call LogWarn, Generating Javadoc from $$(words $$($1_PACKAGES)) package(s) for $$($1_OUTPUT_DIRNAME))
 	$$(call MakeDir, $$(@D))
-        ifneq ($$(findstring $$(LOG_LEVEL), debug trace),)
-	  $$(ECHO) "Contents of $$($1_OPTIONS_FILE):" `$$(CAT) $$($1_OPTIONS_FILE)`
-	  $$(ECHO) "Contents of $$($1_PACKAGES_FILE):" `$$(CAT) $$($1_PACKAGES_FILE)`
+        ifneq ($$($1_PACKAGES_FILE), )
+	  $$(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_OPTIONS_FILE) @$$($1_PACKAGES_FILE))
-	$$(TOUCH) $$($1_INDEX_FILE)
+	        $$(DEFAULT_JAVADOC_TAGS) $$(DEFAULT_JAVADOC_OPTIONS) \
+	        --module-source-path $$(call PathList, $$(JAVADOC_SOURCE_DIRS)) \
+	        $$($1_OPTIONS) $$($1_PACKAGES_ARG))
 
   # The output returned will be the index.html file
   $1 := $$($1_INDEX_FILE)
@@ -367,250 +325,22 @@
 
 ################################################################################
 
-CORE_PACKAGES := \
-    java.applet \
-    java.awt \
-    java.awt.color \
-    java.awt.datatransfer \
-    java.awt.desktop \
-    java.awt.dnd \
-    java.awt.event \
-    java.awt.font \
-    java.awt.geom \
-    java.awt.im \
-    java.awt.im.spi \
-    java.awt.image \
-    java.awt.image.renderable \
-    java.awt.print \
-    java.beans \
-    java.beans.beancontext \
-    java.io \
-    java.lang \
-    java.lang.annotation \
-    java.lang.instrument \
-    java.lang.invoke \
-    java.lang.management \
-    java.lang.module \
-    java.lang.ref \
-    java.lang.reflect \
-    java.math \
-    java.net \
-    java.net.http \
-    java.net.spi \
-    java.nio \
-    java.nio.channels \
-    java.nio.channels.spi \
-    java.nio.charset \
-    java.nio.charset.spi \
-    java.nio.file \
-    java.nio.file.attribute \
-    java.nio.file.spi \
-    java.rmi \
-    java.rmi.activation \
-    java.rmi.dgc \
-    java.rmi.registry \
-    java.rmi.server \
-    java.security \
-    java.security.acl \
-    java.security.cert \
-    java.security.interfaces \
-    java.security.spec \
-    java.sql \
-    java.text \
-    java.text.spi \
-    java.time \
-    java.time.chrono \
-    java.time.format \
-    java.time.temporal \
-    java.time.zone \
-    java.util \
-    java.util.concurrent \
-    java.util.concurrent.atomic \
-    java.util.concurrent.locks \
-    java.util.function \
-    java.util.jar \
-    java.util.logging \
-    java.util.prefs \
-    java.util.regex \
-    java.util.spi \
-    java.util.stream \
-    java.util.zip \
-    javax.accessibility \
-    javax.activation \
-    javax.activity \
-    javax.annotation \
-    javax.annotation.processing \
-    javax.crypto \
-    javax.crypto.interfaces \
-    javax.crypto.spec \
-    javax.imageio \
-    javax.imageio.event \
-    javax.imageio.metadata \
-    javax.imageio.plugins.jpeg \
-    javax.imageio.plugins.bmp \
-    javax.imageio.plugins.tiff \
-    javax.imageio.spi \
-    javax.imageio.stream \
-    javax.jws \
-    javax.jws.soap \
-    javax.lang.model \
-    javax.lang.model.element \
-    javax.lang.model.type \
-    javax.lang.model.util \
-    javax.management \
-    javax.management.loading \
-    javax.management.monitor \
-    javax.management.relation \
-    javax.management.openmbean \
-    javax.management.timer \
-    javax.management.modelmbean \
-    javax.management.remote \
-    javax.management.remote.rmi \
-    javax.naming \
-    javax.naming.directory \
-    javax.naming.event \
-    javax.naming.ldap \
-    javax.naming.spi \
-    javax.net \
-    javax.net.ssl \
-    javax.print \
-    javax.print.attribute \
-    javax.print.attribute.standard \
-    javax.print.event \
-    javax.rmi \
-    javax.rmi.CORBA \
-    javax.rmi.ssl \
-    javax.script \
-    javax.security.auth \
-    javax.security.auth.callback \
-    javax.security.auth.kerberos \
-    javax.security.auth.login \
-    javax.security.auth.spi \
-    javax.security.auth.x500 \
-    javax.security.cert \
-    javax.security.sasl \
-    javax.sound.sampled \
-    javax.sound.sampled.spi \
-    javax.sound.midi \
-    javax.sound.midi.spi \
-    javax.sql \
-    javax.sql.rowset \
-    javax.sql.rowset.serial \
-    javax.sql.rowset.spi \
-    javax.swing \
-    javax.swing.border \
-    javax.swing.colorchooser \
-    javax.swing.filechooser \
-    javax.swing.event \
-    javax.swing.table \
-    javax.swing.text \
-    javax.swing.text.html \
-    javax.swing.text.html.parser \
-    javax.swing.text.rtf \
-    javax.swing.tree \
-    javax.swing.undo \
-    javax.swing.plaf \
-    javax.swing.plaf.basic \
-    javax.swing.plaf.metal \
-    javax.swing.plaf.multi \
-    javax.swing.plaf.nimbus \
-    javax.swing.plaf.synth \
-    javax.tools \
-    javax.transaction \
-    javax.transaction.xa \
-    javax.xml.catalog \
-    javax.xml.parsers \
-    javax.xml.bind \
-    javax.xml.bind.annotation \
-    javax.xml.bind.annotation.adapters \
-    javax.xml.bind.attachment \
-    javax.xml.bind.helpers \
-    javax.xml.bind.util \
-    javax.xml.soap \
-    javax.xml.ws \
-    javax.xml.ws.handler \
-    javax.xml.ws.handler.soap \
-    javax.xml.ws.http \
-    javax.xml.ws.soap \
-    javax.xml.ws.spi \
-    javax.xml.ws.spi.http \
-    javax.xml.ws.wsaddressing \
-    javax.xml.transform \
-    javax.xml.transform.sax \
-    javax.xml.transform.dom \
-    javax.xml.transform.stax \
-    javax.xml.transform.stream \
-    javax.xml \
-    javax.xml.crypto \
-    javax.xml.crypto.dom \
-    javax.xml.crypto.dsig \
-    javax.xml.crypto.dsig.dom \
-    javax.xml.crypto.dsig.keyinfo \
-    javax.xml.crypto.dsig.spec \
-    javax.xml.datatype \
-    javax.xml.validation \
-    javax.xml.namespace \
-    javax.xml.xpath \
-    javax.xml.stream \
-    javax.xml.stream.events \
-    javax.xml.stream.util \
-    org.ietf.jgss \
-    org.omg.CORBA \
-    org.omg.CORBA.DynAnyPackage \
-    org.omg.CORBA.ORBPackage \
-    org.omg.CORBA.TypeCodePackage \
-    org.omg.stub.java.rmi \
-    org.omg.CORBA.portable \
-    org.omg.CORBA_2_3 \
-    org.omg.CORBA_2_3.portable \
-    org.omg.CosNaming \
-    org.omg.CosNaming.NamingContextExtPackage \
-    org.omg.CosNaming.NamingContextPackage \
-    org.omg.SendingContext \
-    org.omg.PortableServer \
-    org.omg.PortableServer.CurrentPackage \
-    org.omg.PortableServer.POAPackage \
-    org.omg.PortableServer.POAManagerPackage \
-    org.omg.PortableServer.ServantLocatorPackage \
-    org.omg.PortableServer.portable \
-    org.omg.PortableInterceptor \
-    org.omg.PortableInterceptor.ORBInitInfoPackage \
-    org.omg.Messaging \
-    org.omg.IOP \
-    org.omg.IOP.CodecFactoryPackage \
-    org.omg.IOP.CodecPackage \
-    org.omg.Dynamic \
-    org.omg.DynamicAny \
-    org.omg.DynamicAny.DynAnyPackage \
-    org.omg.DynamicAny.DynAnyFactoryPackage \
-    org.w3c.dom \
-    org.w3c.dom.events \
-    org.w3c.dom.bootstrap \
-    org.w3c.dom.ls \
-    org.w3c.dom.ranges \
-    org.w3c.dom.traversal \
-    org.w3c.dom.views \
-    org.xml.sax \
-    org.xml.sax.ext \
-    org.xml.sax.helpers
-
 $(eval $(call SetupJavadocGeneration, coredocs, \
     MODULES := java.se.ee, \
     PACKAGES := $(CORE_PACKAGES), \
     IS_CORE := TRUE, \
     OVERVIEW := $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html, \
     WINDOW_TITLE := Java Platform SE $(VERSION_SPECIFICATION), \
-    HEADER_TITLE := Java$(TRADEMARK)&nbsp;Platform<br>Standard&nbsp;Ed.&nbsp;$(VERSION_SPECIFICATION), \
-    DOC_TITLE := Java$(TRADEMARK) Platform$(COMMA) Standard Edition \
+    HEADER_TITLE := Java&trade;&nbsp;Platform<br>Standard&nbsp;Ed.&nbsp;$(VERSION_SPECIFICATION), \
+    DOC_TITLE := Java&trade; Platform$(COMMA) Standard Edition \
       $(VERSION_SPECIFICATION)<br>API Specification, \
     FIRST_COPYRIGHT_YEAR := 1993, \
-    DOCLINT := reference, \
+    DISABLED_DOCLINT := accessibility html missing syntax, \
     DOCLINT_PACKAGES := -org.omg.* jdk.internal.logging.*, \
-    ENCODING := ISO-8859-1, \
     SPLIT_INDEX := TRUE, \
     BOTTOM_COPYRIGHT_URL := $(CORE_BOTTOM_COPYRIGHT_URL), \
     BOTTOM_TEXT := $(CORE_BOTTOM_TEXT), \
-    EXTRA_TOP := $(CORE_TOP_EARLYACCESS), \
+    EXTRA_TOP := $(EARLYACCESS_TOP), \
 ))
 
 TARGETS += $(coredocs)
@@ -623,14 +353,10 @@
         jdk.javadoc.doclet \
         jdk.javadoc.doclet.taglet \
         jdk.javadoc.doclets, \
-    PACKAGE_FILTER := jdk.javadoc.doclet*, \
     API_ROOT := jdk, \
     DEST_DIR := javadoc/doclet, \
     TITLE := Doclet API, \
     FIRST_COPYRIGHT_YEAR := 1993, \
-    BREAKITERATOR := TRUE, \
-    BOTTOM_ADDRESS := $(COMMON_BOTTOM_ADDRESS), \
-    BOTTOM_TEXT := $(COMMON_BOTTOM_TEXT), \
 ))
 
 TARGETS += $(docletapi)
@@ -640,36 +366,23 @@
 $(eval $(call SetupJavadocGeneration, old-docletapi, \
     MODULES := jdk.javadoc, \
     PACKAGES := com.sun.javadoc, \
-    PACKAGE_FILTER := com.sun.javadoc, \
     API_ROOT := jdk, \
     DEST_DIR := javadoc/old/doclet, \
     TITLE := Doclet API, \
     FIRST_COPYRIGHT_YEAR := 1993, \
-    BREAKITERATOR := TRUE, \
-    BOTTOM_ADDRESS := $(COMMON_BOTTOM_ADDRESS), \
-    BOTTOM_TEXT := $(COMMON_BOTTOM_TEXT), \
 ))
 
 TARGETS += $(old-docletapi)
 
 ################################################################################
 
-# Specify a single class instead of a package
-TAGLET_PACKAGE_SINGLE_CLASS := com/sun/tools/doclets/Taglet.java
-TAGLET_PACKAGE_DIR := $(LANGTOOLS_TOPDIR)/src/jdk.javadoc/share/classes
-
 $(eval $(call SetupJavadocGeneration, tagletapi, \
     MODULES := jdk.javadoc, \
     PACKAGES := com.sun.tools.doclets, \
-    PACKAGES_SINGLE_CLASS := $(TAGLET_PACKAGE_DIR)/$(TAGLET_PACKAGE_SINGLE_CLASS), \
     API_ROOT := jdk, \
     DEST_DIR := javadoc/old/taglet, \
     TITLE := Taglet API, \
     FIRST_COPYRIGHT_YEAR := 1993, \
-    BREAKITERATOR := TRUE, \
-    NOINDEX := TRUE, \
-    BOTTOM_ADDRESS := $(COMMON_BOTTOM_ADDRESS), \
-    BOTTOM_TEXT := $(COMMON_BOTTOM_TEXT), \
 ))
 
 TARGETS += $(tagletapi)
@@ -691,15 +404,12 @@
         org.w3c.dom.css \
         org.w3c.dom.events \
         org.w3c.dom.views, \
-    PACKAGE_FILTER := org.w3c.dom*, \
     API_ROOT := jre, \
     DEST_DIR := plugin/dom, \
     TITLE := Common DOM API, \
     FIRST_COPYRIGHT_YEAR := 2005, \
-    DOCLINT := none, \
+    DISABLED_DOCLINT := accessibility html missing, \
     SPLIT_INDEX := TRUE, \
-    BOTTOM_ADDRESS := $(COMMON_BOTTOM_ADDRESS), \
-    BOTTOM_TEXT := $(COMMON_BOTTOM_TEXT), \
 ))
 
 TARGETS += $(domapi)
@@ -717,9 +427,10 @@
     API_ROOT := jdk, \
     DEST_DIR := jpda/jdi, \
     OVERVIEW := $(JDK_TOPDIR)/src/jdk.jdi/share/classes/jdi-overview.html, \
-    TITLE := Java$(TRADEMARK) Debug Interface, \
+    TITLE := Java&trade; Debug Interface, \
     FIRST_COPYRIGHT_YEAR := 1999, \
-    DOCLINT := none, \
+    DISABLED_DOCLINT := accessibility missing syntax, \
+    SPLIT_INDEX := TRUE, \
 ))
 
 TARGETS += $(jdi)
@@ -736,9 +447,9 @@
     API_ROOT := jre, \
     DEST_DIR := security/jaas/spec, \
     OVERVIEW := $(JDK_TOPDIR)/src/jdk.security.auth/share/classes/jaas-overview.html, \
-    TITLE := Java$(TRADEMARK) Authentication and Authorization Service, \
+    TITLE := Java&trade; Authentication and Authorization Service, \
     FIRST_COPYRIGHT_YEAR := 1998, \
-    DOCLINT := none, \
+    DISABLED_DOCLINT := missing, \
 ))
 
 TARGETS += $(jaas)
@@ -751,10 +462,8 @@
     API_ROOT := jre, \
     DEST_DIR := security/jgss/spec, \
     OVERVIEW := $(JDK_TOPDIR)/src/java.security.jgss/share/classes/jgss-overview.html, \
-    TITLE := Java$(TRADEMARK) GSS-API Utilities, \
+    TITLE := Java&trade; GSS-API Utilities, \
     FIRST_COPYRIGHT_YEAR := 2000, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
 ))
 
 TARGETS += $(jgss)
@@ -766,10 +475,8 @@
     PACKAGES := javax.smartcardio, \
     API_ROOT := jre, \
     DEST_DIR := security/smartcardio/spec, \
-    TITLE := Java$(TRADEMARK) Smart Card I/O, \
+    TITLE := Java&trade; Smart Card I/O, \
     FIRST_COPYRIGHT_YEAR := 2005, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
 ))
 
 TARGETS += $(smartcardio)
@@ -783,10 +490,9 @@
         com.sun.net.httpserver.spi, \
     API_ROOT := jre, \
     DEST_DIR := net/httpserver/spec, \
-    TITLE := Java$(TRADEMARK) HTTP Server, \
+    TITLE := Java&trade; HTTP Server, \
     FIRST_COPYRIGHT_YEAR := 2005, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
+    DISABLED_DOCLINT := accessibility missing syntax, \
 ))
 
 TARGETS += $(httpserver)
@@ -799,9 +505,7 @@
     API_ROOT := jre, \
     DEST_DIR := plugin/jsobject, \
     FIRST_COPYRIGHT_YEAR := 1993, \
-    TITLE := Java$(TRADEMARK) JSObject Doc, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
+    TITLE := Java&trade; JSObject Doc, \
 ))
 
 TARGETS += $(jsobject)
@@ -814,10 +518,9 @@
     API_ROOT := jre, \
     DEST_DIR := management/extension, \
     OVERVIEW := $(JDK_TOPDIR)/src/java.management/share/classes/mgmt-overview.html, \
-    TITLE := Monitoring and Management Interface for the Java$(TRADEMARK) Platform, \
+    TITLE := Monitoring and Management Interface for the Java&trade; Platform, \
     FIRST_COPYRIGHT_YEAR := 2003, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
+    DISABLED_DOCLINT := accessibility missing reference, \
 ))
 
 TARGETS += $(mgmt)
@@ -833,8 +536,7 @@
     DEST_DIR := attach/spec, \
     TITLE := Attach API, \
     FIRST_COPYRIGHT_YEAR := 2005, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
+    DISABLED_DOCLINT := reference, \
 ))
 
 TARGETS += $(attach)
@@ -848,15 +550,12 @@
     DEST_DIR := jconsole/spec, \
     TITLE := JConsole API, \
     FIRST_COPYRIGHT_YEAR := 2006, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
 ))
 
 TARGETS += $(jconsole)
 
 ################################################################################
 
-# NOTE: Need to override RELATIVE_CORE_DIR to be bug compatible with old code.
 $(eval $(call SetupJavadocGeneration, jshellapi, \
     MODULES := jdk.jshell, \
     PACKAGES := \
@@ -865,10 +564,8 @@
         jdk.jshell.execution, \
     API_ROOT := jdk, \
     DEST_DIR := jshell, \
-    RELATIVE_CORE_DIR := ../../../.., \
     OVERVIEW := $(LANGTOOLS_TOPDIR)/src/jdk.jshell/share/classes/jdk/jshell/overview.html, \
     TITLE := JShell API, \
-    HEADER_TITLE := JSHELL API, \
     FIRST_COPYRIGHT_YEAR := 2015, \
 ))
 
@@ -882,11 +579,11 @@
         com.sun.source.doctree \
         com.sun.source.tree \
         com.sun.source.util, \
-    PACKAGE_FILTER := com.sun.source.*, \
     API_ROOT := jdk, \
     DEST_DIR := javac/tree, \
     TITLE := Compiler Tree API, \
     FIRST_COPYRIGHT_YEAR := 2005, \
+    SPLIT_INDEX := TRUE, \
 ))
 
 TARGETS += $(treeapi)
@@ -898,11 +595,11 @@
     PACKAGES := \
         jdk.nashorn.api.scripting \
         jdk.nashorn.api.tree, \
-    PACKAGE_FILTER := jdk.nashorn.api.*, \
     API_ROOT := jdk, \
     DEST_DIR := nashorn, \
     TITLE := Nashorn API, \
     FIRST_COPYRIGHT_YEAR := 2014, \
+    SPLIT_INDEX := TRUE, \
 ))
 
 TARGETS += $(nashornapi)
@@ -934,8 +631,6 @@
     DEST_DIR := nio/sctp/spec, \
     TITLE := SCTP API, \
     FIRST_COPYRIGHT_YEAR := 2009, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
 ))
 
 TARGETS += $(sctp)
@@ -949,7 +644,6 @@
     DEST_DIR := accessibility/jaccess/spec, \
     TITLE := JACCESS API, \
     FIRST_COPYRIGHT_YEAR := 2002, \
-    NODEPRECATEDLIST := TRUE, \
 ))
 
 TARGETS += $(jaccess)
@@ -963,8 +657,7 @@
     DEST_DIR := net/socketoptions/spec, \
     TITLE := jdk.net API, \
     FIRST_COPYRIGHT_YEAR := 2014, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
+    DISABLED_DOCLINT := missing, \
 ))
 
 TARGETS += $(jdknet)
@@ -980,8 +673,7 @@
     DEST_DIR := jlink, \
     TITLE := JLink Plugin API - EXPERIMENTAL, \
     FIRST_COPYRIGHT_YEAR := 2015, \
-    DOCLINT := none, \
-    NODEPRECATEDLIST := TRUE, \
+    DISABLED_DOCLINT := html missing syntax, \
 ))
 
 TARGETS += $(jlinkplugins)
@@ -1014,19 +706,13 @@
 
 ################################################################################
 # Optional target which bundles all generated javadocs into a zip archive.
-# The dependency on docs is handled in Main.gmk.
-
-# Add the core docs as prerequisite to the archive to trigger a rebuild
-# if the core docs were rebuilt. Ideally any doc rebuild should trigger
-# this, but the way prerequisites are currently setup in this file, that
-# is hard to achieve.
 
 JAVADOC_ARCHIVE_NAME := jdk-$(VERSION_STRING)-docs.zip
 JAVADOC_ARCHIVE_ASSEMBLY_DIR := $(SUPPORT_OUTPUTDIR)/docs/zip-docs
 JAVADOC_ARCHIVE_DIR := $(OUTPUT_ROOT)/bundles
 JAVADOC_ARCHIVE := $(JAVADOC_ARCHIVE_DIR)/$(JAVADOC_ARCHIVE_NAME)
 
-$(JAVADOC_ARCHIVE): $(CORE_INDEX_FILE)
+$(JAVADOC_ARCHIVE): $(TARGETS) $(COPY_TARGETS)
 	$(call LogInfo, Compressing javadoc to single $(JAVADOC_ARCHIVE_NAME))
 	$(MKDIR) -p $(JAVADOC_ARCHIVE_DIR)
 	$(RM) -r $(JAVADOC_ARCHIVE_ASSEMBLY_DIR)
@@ -1038,7 +724,7 @@
 	  name=`$(ECHO) $${target_dir} | $(SED) "s;/spec;;" | $(SED) "s;.*/;;"`; \
 	  $(LN) -s $${target_dir}  $${name}; \
 	done; \
-	$(ZIP) -q -r $(JAVADOC_ARCHIVE) * ; \
+	$(ZIPEXE) -q -r $(JAVADOC_ARCHIVE) * ; \
 	popd ;
 
 ZIP_TARGETS += $(JAVADOC_ARCHIVE)
--- a/make/Jprt.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/Jprt.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -71,11 +71,11 @@
   # This target must be called in the context of a SPEC file
   $(JPRT_ARCHIVE_BUNDLE): product-images
 	$(call MakeDir, $(@D))
-	$(CD) $(SRC_JDK_IMAGE_DIR) && $(ZIP) -y -q -r $@ .
+	$(CD) $(SRC_JDK_IMAGE_DIR) && $(ZIPEXE) -y -q -r $@ .
 
   $(JPRT_ARCHIVE_TEST_BUNDLE): test-image
 	$(call MakeDir, $(@D))
-	$(CD) $(SRC_TEST_IMAGE_DIR) && $(ZIP) -y -q -r $@ .
+	$(CD) $(SRC_TEST_IMAGE_DIR) && $(ZIPEXE) -y -q -r $@ .
 
   ##############################################################################
   # Optional symbols bundle
@@ -85,7 +85,7 @@
 
     $(JPRT_ARCHIVE_SYMBOLS_BUNDLE): product-images
 	$(call MakeDir, $(@D))
-	$(CD) $(SYMBOLS_IMAGE_DIR) && $(ZIP) -y -q -r $@ .
+	$(CD) $(SYMBOLS_IMAGE_DIR) && $(ZIPEXE) -y -q -r $@ .
 
   endif
 
--- a/make/common/CORE_PKGS.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,305 +0,0 @@
-#
-# Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  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.
-#
-
-# EXCLUDE_PKGS is the list of packages to exclude from the
-# Java API Specification. Do not add these to CORE_PKGS.
-# The concatenation of EXCLUDE_PKGS and CORE_PKGS
-# should make up the list of all packages under the
-# src/shared/classes directory of the JDK source tree.
-#
-EXCLUDE_PKGS = \
-    java.awt.peer \
-    java.awt.dnd.peer \
-    sun.* \
-    com.sun.* \
-    org.apache.* \
-    org.jcp.* \
-    org.w3c.dom.css \
-    org.w3c.dom.html \
-    org.w3c.dom.stylesheets \
-    org.omg.stub.javax.management.remote.rmi
-
-#
-# ACTIVE_JSR_PKGS are packages that are part of an active JSR process--
-# one that is doing its own review. These packages are not included when
-# creating diff pages for the platform's JCP process.
-#
-# (see /java/pubs/apisrc/jdk/6.0/beta/make/docs/active_jsr_pkgs)
-# Note:
-# This is a list of regular expressions. So foo.* matches "foo" and "foo.bar".
-#
-ACTIVE_JSR_PKGS= \
-    java.lang.invoke \
-    java.sql \
-    javax.activation \
-    javax.annotation.* \
-    javax.jws.* \
-    javax.lang.* \
-    javax.management.* \
-    javax.script \
-    javax.sql.* \
-    javax.tools.* \
-    javax.xml.* \
-    org.w3c.* \
-    org.xml.sax
-
-#
-# CORE_PKGS is the list of packages that form the
-# Java API Specification.
-#
-### ***IMPORTANT NOTE***
-### There is also a "REGEXP" variable in the docs/makefile that
-### determines which table the packages go in on the main page.
-### Currently, there is only table ("Platform Packages") and
-### everything goes in it, so REGEXP is "*". But if that policy
-### changes, packages added will need to be reflected in that
-### list of wildcard expressions, as well.
-###
-CORE_PKGS = \
-    java.applet \
-    java.awt \
-    java.awt.color \
-    java.awt.datatransfer \
-    java.awt.desktop \
-    java.awt.dnd \
-    java.awt.event \
-    java.awt.font \
-    java.awt.geom \
-    java.awt.im \
-    java.awt.im.spi \
-    java.awt.image \
-    java.awt.image.renderable \
-    java.awt.print \
-    java.beans \
-    java.beans.beancontext \
-    java.io \
-    java.lang \
-    java.lang.annotation \
-    java.lang.instrument \
-    java.lang.invoke \
-    java.lang.management \
-    java.lang.module \
-    java.lang.ref \
-    java.lang.reflect \
-    java.math \
-    java.net \
-    java.net.http \
-    java.net.spi \
-    java.nio \
-    java.nio.channels \
-    java.nio.channels.spi \
-    java.nio.charset \
-    java.nio.charset.spi \
-    java.nio.file \
-    java.nio.file.attribute \
-    java.nio.file.spi \
-    java.rmi \
-    java.rmi.activation \
-    java.rmi.dgc \
-    java.rmi.registry \
-    java.rmi.server \
-    java.security \
-    java.security.acl \
-    java.security.cert \
-    java.security.interfaces \
-    java.security.spec \
-    java.sql \
-    java.text \
-    java.text.spi \
-    java.time \
-    java.time.chrono \
-    java.time.format \
-    java.time.temporal \
-    java.time.zone \
-    java.util \
-    java.util.concurrent \
-    java.util.concurrent.atomic \
-    java.util.concurrent.locks \
-    java.util.function \
-    java.util.jar \
-    java.util.logging \
-    java.util.prefs \
-    java.util.regex \
-    java.util.spi \
-    java.util.stream \
-    java.util.zip \
-    javax.accessibility \
-    javax.activation \
-    javax.activity \
-    javax.annotation \
-    javax.annotation.processing \
-    javax.crypto \
-    javax.crypto.interfaces \
-    javax.crypto.spec \
-    javax.imageio \
-    javax.imageio.event \
-    javax.imageio.metadata \
-    javax.imageio.plugins.jpeg \
-    javax.imageio.plugins.bmp \
-    javax.imageio.plugins.tiff \
-    javax.imageio.spi \
-    javax.imageio.stream \
-    javax.jws \
-    javax.jws.soap \
-    javax.lang.model \
-    javax.lang.model.element \
-    javax.lang.model.type \
-    javax.lang.model.util \
-    javax.management \
-    javax.management.loading \
-    javax.management.monitor \
-    javax.management.relation \
-    javax.management.openmbean \
-    javax.management.timer \
-    javax.management.modelmbean \
-    javax.management.remote \
-    javax.management.remote.rmi \
-    javax.naming \
-    javax.naming.directory \
-    javax.naming.event \
-    javax.naming.ldap \
-    javax.naming.spi \
-    javax.net \
-    javax.net.ssl \
-    javax.print \
-    javax.print.attribute \
-    javax.print.attribute.standard \
-    javax.print.event \
-    javax.rmi \
-    javax.rmi.CORBA \
-    javax.rmi.ssl \
-    javax.script \
-    javax.security.auth \
-    javax.security.auth.callback \
-    javax.security.auth.kerberos \
-    javax.security.auth.login \
-    javax.security.auth.spi \
-    javax.security.auth.x500 \
-    javax.security.cert \
-    javax.security.sasl \
-    javax.sound.sampled \
-    javax.sound.sampled.spi \
-    javax.sound.midi \
-    javax.sound.midi.spi \
-    javax.sql \
-    javax.sql.rowset \
-    javax.sql.rowset.serial \
-    javax.sql.rowset.spi \
-    javax.swing \
-    javax.swing.border \
-    javax.swing.colorchooser \
-    javax.swing.filechooser \
-    javax.swing.event \
-    javax.swing.table \
-    javax.swing.text \
-    javax.swing.text.html \
-    javax.swing.text.html.parser \
-    javax.swing.text.rtf \
-    javax.swing.tree \
-    javax.swing.undo \
-    javax.swing.plaf \
-    javax.swing.plaf.basic \
-    javax.swing.plaf.metal \
-    javax.swing.plaf.multi \
-    javax.swing.plaf.nimbus \
-    javax.swing.plaf.synth \
-    javax.tools \
-    javax.transaction \
-    javax.transaction.xa \
-    javax.xml.catalog \
-    javax.xml.parsers \
-    javax.xml.bind \
-    javax.xml.bind.annotation \
-    javax.xml.bind.annotation.adapters \
-    javax.xml.bind.attachment \
-    javax.xml.bind.helpers \
-    javax.xml.bind.util \
-    javax.xml.soap \
-    javax.xml.ws \
-    javax.xml.ws.handler \
-    javax.xml.ws.handler.soap \
-    javax.xml.ws.http \
-    javax.xml.ws.soap \
-    javax.xml.ws.spi \
-    javax.xml.ws.spi.http \
-    javax.xml.ws.wsaddressing \
-    javax.xml.transform \
-    javax.xml.transform.sax \
-    javax.xml.transform.dom \
-    javax.xml.transform.stax \
-    javax.xml.transform.stream \
-    javax.xml \
-    javax.xml.crypto \
-    javax.xml.crypto.dom \
-    javax.xml.crypto.dsig \
-    javax.xml.crypto.dsig.dom \
-    javax.xml.crypto.dsig.keyinfo \
-    javax.xml.crypto.dsig.spec \
-    javax.xml.datatype \
-    javax.xml.validation \
-    javax.xml.namespace \
-    javax.xml.xpath \
-    javax.xml.stream \
-    javax.xml.stream.events \
-    javax.xml.stream.util \
-    org.ietf.jgss \
-    org.omg.CORBA \
-    org.omg.CORBA.DynAnyPackage \
-    org.omg.CORBA.ORBPackage \
-    org.omg.CORBA.TypeCodePackage \
-    org.omg.stub.java.rmi \
-    org.omg.CORBA.portable \
-    org.omg.CORBA_2_3 \
-    org.omg.CORBA_2_3.portable \
-    org.omg.CosNaming \
-    org.omg.CosNaming.NamingContextExtPackage \
-    org.omg.CosNaming.NamingContextPackage \
-    org.omg.SendingContext \
-    org.omg.PortableServer \
-    org.omg.PortableServer.CurrentPackage \
-    org.omg.PortableServer.POAPackage \
-    org.omg.PortableServer.POAManagerPackage \
-    org.omg.PortableServer.ServantLocatorPackage \
-    org.omg.PortableServer.portable \
-    org.omg.PortableInterceptor \
-    org.omg.PortableInterceptor.ORBInitInfoPackage \
-    org.omg.Messaging \
-    org.omg.IOP \
-    org.omg.IOP.CodecFactoryPackage \
-    org.omg.IOP.CodecPackage \
-    org.omg.Dynamic \
-    org.omg.DynamicAny \
-    org.omg.DynamicAny.DynAnyPackage \
-    org.omg.DynamicAny.DynAnyFactoryPackage \
-    org.w3c.dom \
-    org.w3c.dom.events \
-    org.w3c.dom.bootstrap \
-    org.w3c.dom.ls \
-    org.w3c.dom.ranges \
-    org.w3c.dom.traversal \
-    org.w3c.dom.views \
-    org.xml.sax \
-    org.xml.sax.ext \
-    org.xml.sax.helpers
--- a/make/common/JarArchive.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/common/JarArchive.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -264,7 +264,7 @@
 	  $(CAT) $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) $$(NEWLINE) \
 	  if [ -s $$($1_DELETESS_FILE) ]; then \
 	    $(ECHO) "  deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \
-	    $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \
+	    $(ZIPEXE) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \
 	  fi $$(NEWLINE) \
 	  $$($1_UPDATE_CONTENTS) true $$(NEWLINE) \
 	  $$($1_JARINDEX) && true )
--- a/make/common/JavaCompilation.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/common/JavaCompilation.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -172,6 +172,7 @@
 #   KEEP_DUPS:=Do not remove duplicate file names from different source roots.
 #   FAIL_NO_SRC:=Set to false to not fail the build if no source files are found,
 #        default is true.
+#   DEBUG_SYMBOLS:=Set to false to disable generation of debug symbols.
 SetupJavaCompilation = $(NamedParamsMacroTemplate)
 define SetupJavaCompilationBody
 
@@ -183,7 +184,11 @@
   # Extract the info from the java compiler setup.
   $1_JVM := $$($$($1_SETUP)_JVM)
   $1_JAVAC := $$($$($1_SETUP)_JAVAC)
-  $1_FLAGS := $$($$($1_SETUP)_FLAGS) $$($1_ADD_JAVAC_FLAGS) $(JAVAC_FLAGS)
+  $1_FLAGS :=
+  ifneq ($$($1_DEBUG_SYMBOLS), false)
+    $1_FLAGS := -g
+  endif
+  $1_FLAGS += $$($$($1_SETUP)_FLAGS) $$($1_ADD_JAVAC_FLAGS) $(JAVAC_FLAGS)
   ifneq ($$($1_CLASSPATH), )
     $1_FLAGS += -cp $$(call PathList, $$($1_CLASSPATH))
   endif
--- a/make/common/MakeBase.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/common/MakeBase.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -122,6 +122,10 @@
 EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1)))
 
 ################################################################################
+# This macro works just like EscapeDollar above, but for #.
+EscapeHash = $(subst \#,\\\#,$(subst \\\#,\#,$(strip $1)))
+
+################################################################################
 # This macro translates $ into $$ to protect the string from make itself.
 DoubleDollar = $(subst $$,$$$$,$(strip $1))
 
@@ -833,7 +837,7 @@
           $(if $(findstring $(LOG_LEVEL), trace), \
               $(info NewVariable $1: >$(strip $($1))<) \
               $(info OldVariable $1: >$(strip $($1_old))<)) \
-          $(call WriteFile, $1_old:=$(call DoubleDollar,$($1)), \
+          $(call WriteFile, $1_old:=$(call DoubleDollar,$(call EscapeHash,$($1))), \
               $(call DependOnVariableFileName, $1, $2))) \
         $(call DependOnVariableFileName, $1, $2) \
     )
--- a/make/common/NON_CORE_PKGS.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-#
-# Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-#
-# This file contains the package names of all the "non-core"
-# API published in the Java 2 SDK documentation. "Non-core" means
-# it includes all published API outside of the JDK API specification.
-#
-# These environment variables are used by javadoc in
-# make/docs/Makefile and are referenced by the localization
-# team when determining which APIs to extract javadoc
-# comments from.
-
-DOMAPI_PKGS = org.w3c.dom \
-    org.w3c.dom.bootstrap \
-    org.w3c.dom.ls \
-    org.w3c.dom.ranges \
-    org.w3c.dom.traversal \
-    org.w3c.dom.html \
-    org.w3c.dom.stylesheets \
-    org.w3c.dom.css \
-    org.w3c.dom.events \
-    org.w3c.dom.views
-
-JDI_PKGS = com.sun.jdi \
-    com.sun.jdi.event \
-    com.sun.jdi.request \
-    com.sun.jdi.connect \
-    com.sun.jdi.connect.spi
-
-MGMT_PKGS = com.sun.management
-
-JAAS_PKGS = com.sun.security.auth \
-    com.sun.security.auth.callback \
-    com.sun.security.auth.login \
-    com.sun.security.auth.module
-
-JGSS_PKGS = com.sun.security.jgss
-
-OLD_JSSE_PKGS = com.sun.net.ssl
-
-HTTPSERVER_PKGS = com.sun.net.httpserver \
-    com.sun.net.httpserver.spi
-
-NIO_PKGS = com.sun.nio.file
-
-OLD_DOCLETAPI_PKGS = com.sun.javadoc
-
-DOCLETAPI_PKGS = jdk.javadoc.doclet \
-    jdk.javadoc.doclet.taglet \
-    jdk.javadoc.doclets
-
-TAGLETAPI_FILE = com/sun/tools/doclets/Taglet.java
-
-TAGLETAPI_PKGS = com.sun.tools.doclets
-
-ATTACH_PKGS = com.sun.tools.attach \
-    com.sun.tools.attach.spi
-
-JCONSOLE_PKGS = com.sun.tools.jconsole
-
-JSHELLAPI_PKGS = jdk.jshell \
-    jdk.jshell.spi \
-    jdk.jshell.execution
-
-TREEAPI_PKGS = com.sun.source.doctree \
-    com.sun.source.tree \
-    com.sun.source.util
-
-NASHORNAPI_PKGS = jdk.nashorn.api.scripting \
-    jdk.nashorn.api.tree
-   
-DYNALINKAPI_PKGS = jdk.dynalink \
-    jdk.dynalink.beans \
-    jdk.dynalink.linker \
-    jdk.dynalink.linker.support \
-    jdk.dynalink.support
-
-SMARTCARDIO_PKGS = javax.smartcardio
-
-SCTPAPI_PKGS = com.sun.nio.sctp
-
-ifeq ($(PLATFORM), macosx)
-  APPLE_EXT_PKGS = com.apple.eawt \
-      com.apple.eawt.event \
-      com.apple.eio
-endif
-
-JDK_PKGS = jdk \
-      jdk.net \
-      jdk.management.cmm
-
-JACCESSAPI_PKGS = com.sun.java.accessibility.util
-
-JSOBJECT_PKGS = netscape.javascript
-
-# non-core packages in rt.jar
-NON_CORE_PKGS = $(DOMAPI_PKGS) \
-    $(JSOBJECT_PKGS) \
-    $(MGMT_PKGS) \
-    $(JAAS_PKGS) \
-    $(JGSS_PKGS) \
-    $(NIO_PKGS) \
-    $(OLD_JSSE_PKGS) \
-    $(HTTPSERVER_PKGS) \
-    $(SMARTCARDIO_PKGS) \
-    $(SCTPAPI_PKGS) \
-    $(APPLE_EXT_PKGS) \
-    $(JDK_PKGS) \
-    $(JACCESSAPI_PKGS)
--- a/make/common/NativeCompilation.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/common/NativeCompilation.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -875,7 +875,7 @@
           # to be rebuilt properly.
           $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
 		$(CD) $$($1_OUTPUT_DIR) && \
-		    $(ZIP) -q -r $$@ $$(subst $$($1_OUTPUT_DIR)/,, $$($1_DEBUGINFO_FILES))
+		    $(ZIPEXE) -q -r $$@ $$(subst $$($1_OUTPUT_DIR)/,, $$($1_DEBUGINFO_FILES))
 
         endif
        endif # !STATIC_LIBRARY
--- a/make/common/ZipArchive.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/make/common/ZipArchive.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -107,7 +107,7 @@
   $$($1_ZIP) : $$($1_ALL_SRCS) $$($1_EXTRA_DEPS)
 	$(MKDIR) -p $$(@D)
 	$(ECHO) Updating $$($1_NAME)
-	$$(foreach i,$$($1_SRC),(cd $$i && $(ZIP) -qru $$($1_ZIP_OPTIONS) $$@ . $$($1_ZIP_INCLUDES) \
+	$$(foreach i,$$($1_SRC),(cd $$i && $(ZIPEXE) -qru $$($1_ZIP_OPTIONS) $$@ . $$($1_ZIP_INCLUDES) \
 	    $$($1_ZIP_EXCLUDES) -x \*_the.\* \
 	    $$(addprefix -x$(SPACE), $$(patsubst $$i/%,%, $$($1_EXCLUDE_FILES))) \
 	    || test "$$$$?" = "12" )$$(NEWLINE)) true
--- a/nashorn/.hgtags	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/.hgtags	Wed Jul 05 22:30:23 2017 +0200
@@ -379,3 +379,4 @@
 b4e57ead3fae4939b70dd345d1f6744a1dedfa21 jdk-9+143
 a7f21ee6ed30695a6de14e74035d2857a754f62b jdk-9+144
 4a68dd740be8aa0d1a25f94985b3cb2e190ccfce jdk-9+145
+55f5a96988de8237f3ee65a69aa4a48aed9ca8d4 jdk-9+146
--- a/nashorn/make/build.xml	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/make/build.xml	Wed Jul 05 22:30:23 2017 +0200
@@ -524,17 +524,19 @@
   <!-- only to be invoked as dependency of "test" target -->
   <target name="-test-classes-all" depends="jar" unless="test.class">
       <fileset id="test.classes" dir="${build.test.classes.dir}">
+          <include name="**/dynalink/beans/test/*Test.class"/>
+          <include name="**/dynalink/linker/support/test/*Test.class"/>
+          <include name="**/dynalink/support/test/*Test.class"/>
           <include name="**/dynalink/test/*Test.class"/>
-          <include name="**/dynalink/beans/test/*Test.class"/>
           <include name="**/api/javaaccess/test/*Test.class"/>
           <include name="**/api/scripting/test/*Test.class"/>
           <include name="**/api/tree/test/*Test.class"/>
           <include name="**/codegen/test/*Test.class"/>
           <include name="**/parser/test/*Test.class"/>
           <include name="**/runtime/test/*Test.class"/>
+          <include name="**/runtime/doubleconv/test/*Test.class"/>
           <include name="**/runtime/regexp/test/*Test.class"/>
           <include name="**/runtime/regexp/joni/test/*Test.class"/>
-          <include name="**/runtime/doubleconv/test/*Test.class"/>
           <include name="**/framework/*Test.class"/>
      </fileset>
   </target>
@@ -550,6 +552,7 @@
   <target name="-test-nosecurity" unless="test.class">
     <fileset id="test.nosecurity.classes" dir="${build.test.classes.dir}">
       <include name="**/framework/ScriptTest.class"/>
+      <include name="**/runtime/linker/test/*Test.class"/>
     </fileset>
     <testng outputdir="${build.nosecurity.test.results.dir}/${testResultsSubDir}" classfilesetref="test.nosecurity.classes"
        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/ClassString.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/ClassString.java	Wed Jul 05 22:30:23 2017 +0200
@@ -88,6 +88,7 @@
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
 import jdk.dynalink.internal.AccessControlContextFactory;
@@ -149,6 +150,11 @@
         return hashCode;
     }
 
+    @Override
+    public String toString() {
+        return "ClassString[" + Arrays.toString(classes) + "]";
+    }
+
     boolean isVisibleFrom(final ClassLoader classLoader) {
         return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
             @Override
--- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/PackagesHelper.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/PackagesHelper.java	Wed Jul 05 22:30:23 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -163,7 +163,7 @@
         if (fm != null) {
             listPackage(StandardLocation.PLATFORM_CLASS_PATH, pkg, props);
             if (this.modulePathSet) {
-                for (Set<Location> locs : fm.listModuleLocations(StandardLocation.MODULE_PATH)) {
+                for (Set<Location> locs : fm.listLocationsForModules(StandardLocation.MODULE_PATH)) {
                     for (Location loc : locs) {
                         listPackage(loc, pkg, props);
                     }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java	Wed Jul 05 22:30:23 2017 +0200
@@ -31,24 +31,13 @@
 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_VARARGS;
-import static jdk.internal.org.objectweb.asm.Opcodes.AALOAD;
 import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD;
-import static jdk.internal.org.objectweb.asm.Opcodes.ARRAYLENGTH;
 import static jdk.internal.org.objectweb.asm.Opcodes.ASTORE;
 import static jdk.internal.org.objectweb.asm.Opcodes.D2F;
-import static jdk.internal.org.objectweb.asm.Opcodes.GETSTATIC;
-import static jdk.internal.org.objectweb.asm.Opcodes.GOTO;
 import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC;
-import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_0;
-import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPGE;
-import static jdk.internal.org.objectweb.asm.Opcodes.ILOAD;
 import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESPECIAL;
-import static jdk.internal.org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
-import static jdk.internal.org.objectweb.asm.Opcodes.ISTORE;
 import static jdk.internal.org.objectweb.asm.Opcodes.I2B;
 import static jdk.internal.org.objectweb.asm.Opcodes.I2S;
-import static jdk.internal.org.objectweb.asm.Opcodes.POP;
-import static jdk.internal.org.objectweb.asm.Opcodes.PUTSTATIC;
 import static jdk.internal.org.objectweb.asm.Opcodes.RETURN;
 import static jdk.nashorn.internal.codegen.CompilerConstants.interfaceCallNoLookup;
 import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
@@ -66,6 +55,7 @@
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
@@ -73,20 +63,14 @@
 import java.util.List;
 import java.util.Set;
 import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.internal.org.objectweb.asm.FieldVisitor;
-import jdk.internal.org.objectweb.asm.Handle;
-import jdk.internal.org.objectweb.asm.Label;
-import jdk.internal.org.objectweb.asm.MethodVisitor;
-import jdk.internal.org.objectweb.asm.Opcodes;
-import jdk.internal.org.objectweb.asm.Type;
 import jdk.internal.org.objectweb.asm.Handle;
 import jdk.internal.org.objectweb.asm.Label;
 import jdk.internal.org.objectweb.asm.Opcodes;
 import jdk.internal.org.objectweb.asm.Type;
 import jdk.internal.org.objectweb.asm.commons.InstructionAdapter;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.api.scripting.ScriptUtils;
 import jdk.nashorn.internal.codegen.CompilerConstants.Call;
-import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.linker.AdaptationResult.Outcome;
@@ -139,7 +123,8 @@
  * to resemble Java anonymous classes) is actually equivalent to <code>new X(a, b, { ... })</code>.
  * </p><p>
  * It is possible to create two different adapter classes: those that can have class-level overrides, and those that can
- * have instance-level overrides. When {@link JavaAdapterFactory#getAdapterClassFor(Class[], ScriptObject)} is invoked
+ * have instance-level overrides. When {@link JavaAdapterFactory#getAdapterClassFor(Class[], ScriptObject, ProtectionDomain)}
+ * or {@link JavaAdapterFactory#getAdapterClassFor(Class[], ScriptObject, Lookup)} is invoked
  * with non-null {@code classOverrides} parameter, an adapter class is created that can have class-level overrides, and
  * the passed script object will be used as the implementations for its methods, just as in the above case of the
  * constructor taking a script object. Note that in the case of class-level overrides, a new adapter class is created on
@@ -168,6 +153,7 @@
     private static final Type OBJECT_TYPE = Type.getType(Object.class);
     private static final Type SCRIPT_OBJECT_TYPE = Type.getType(ScriptObject.class);
     private static final Type SCRIPT_FUNCTION_TYPE = Type.getType(ScriptFunction.class);
+    private static final Type SCRIPT_OBJECT_MIRROR_TYPE = Type.getType(ScriptObjectMirror.class);
 
     // JavaAdapterServices methods used in generated bytecode
     private static final Call CHECK_FUNCTION = lookupServiceMethod("checkFunction", ScriptFunction.class, Object.class, String.class);
@@ -182,6 +168,7 @@
     private static final Call TO_CHAR_PRIMITIVE = lookupServiceMethod("toCharPrimitive", char.class, Object.class);
     private static final Call UNSUPPORTED = lookupServiceMethod("unsupported", UnsupportedOperationException.class);
     private static final Call WRAP_THROWABLE = lookupServiceMethod("wrapThrowable", RuntimeException.class, Throwable.class);
+    private static final Call UNWRAP_MIRROR = lookupServiceMethod("unwrapMirror", ScriptObject.class, Object.class, boolean.class);
 
     // Other methods invoked by the generated bytecode
     private static final Call UNWRAP = staticCallNoLookup(ScriptUtils.class, "unwrap", Object.class, Object.class);
@@ -216,8 +203,7 @@
     private static final String GET_METHOD_PROPERTY_METHOD_DESCRIPTOR = Type.getMethodDescriptor(OBJECT_TYPE, SCRIPT_OBJECT_TYPE);
     private static final String VOID_METHOD_DESCRIPTOR = Type.getMethodDescriptor(Type.VOID_TYPE);
 
-    static final String ADAPTER_PACKAGE_INTERNAL = "jdk/nashorn/javaadapters/";
-    static final String ADAPTER_PACKAGE = "jdk.nashorn.javaadapters";
+    private static final String ADAPTER_PACKAGE_INTERNAL = "jdk/nashorn/javaadapters/";
     private static final int MAX_GENERATED_TYPE_NAME_LENGTH = 255;
 
     // Method name prefix for invoking super-methods
@@ -265,7 +251,7 @@
      * @throws AdaptationException if the adapter can not be generated for some reason.
      */
     JavaAdapterBytecodeGenerator(final Class<?> superClass, final List<Class<?>> interfaces,
-            final ClassLoader commonLoader, final boolean classOverride) throws AdaptationException {
+                                 final ClassLoader commonLoader, final boolean classOverride) throws AdaptationException {
         assert superClass != null && !superClass.isInterface();
         assert interfaces != null;
 
@@ -369,7 +355,7 @@
             // If the class is a SAM, allow having ScriptFunction passed as class overrides
             mv.dup();
             mv.instanceOf(SCRIPT_FUNCTION_TYPE);
-                    mv.dup();
+            mv.dup();
             mv.putstatic(generatedClassName, IS_FUNCTION_FIELD_NAME, BOOLEAN_TYPE_DESCRIPTOR);
             final Label notFunction = new Label();
             mv.ifeq(notFunction);
@@ -389,9 +375,9 @@
     private void emitInitCallThis(final InstructionAdapter mv) {
         loadField(mv, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);
         GET_CALL_THIS.invoke(mv);
-            if(classOverride) {
+        if(classOverride) {
             mv.putstatic(generatedClassName, CALL_THIS_FIELD_NAME, OBJECT_TYPE_DESCRIPTOR);
-            } else {
+        } else {
             // It is presumed ALOAD 0 was already executed
             mv.putfield(generatedClassName, CALL_THIS_FIELD_NAME, OBJECT_TYPE_DESCRIPTOR);
         }
@@ -427,10 +413,10 @@
 
         if (samName == null) {
             return false;
-                }
-                // If all our abstract methods have a single name, generate an additional constructor, one that takes a
-                // ScriptFunction as its first parameter and assigns it as the implementation for all abstract methods.
-                generateOverridingConstructor(ctor, true);
+        }
+        // If all our abstract methods have a single name, generate an additional constructor, one that takes a
+        // ScriptFunction as its first parameter and assigns it as the implementation for all abstract methods.
+        generateOverridingConstructor(ctor, true);
         // If the original type only has a single abstract method name, as well as a default ctor, then it can
         // be automatically converted from JS function.
         return ctor.getParameterTypes().length == 0;
@@ -456,14 +442,9 @@
      * constructor passed as the argument here, and delegate to it. However, it will take an additional argument of
      * either ScriptObject or ScriptFunction type (based on the value of the "fromFunction" parameter), and initialize
      * all the method handle fields of the adapter instance with functions from the script object (or the script
-     * function itself, if that's what's passed). There is one method handle field in the adapter class for every method
-     * that can be implemented or overridden; the name of every field is same as the name of the method, with a number
-     * suffix that makes it unique in case of overloaded methods. The generated constructor will invoke
-     * {@link #getHandle(ScriptFunction, MethodType, boolean)} or {@link #getHandle(Object, String, MethodType,
-     * boolean)} to obtain the method handles; these methods make sure to add the necessary conversions and arity
-     * adjustments so that the resulting method handles can be invoked from generated methods using {@code invokeExact}.
-     * The constructor that takes a script function will only initialize the methods with the same name as the single
-     * abstract method. The constructor will also store the Nashorn global that was current at the constructor
+     * function itself, if that's what's passed). Additionally, it will create another constructor with an additional
+     * Object type parameter that can be used for ScriptObjectMirror objects.
+     * The constructor will also store the Nashorn global that was current at the constructor
      * invocation time in a field named "global". The generated constructor will be public, regardless of whether the
      * supertype constructor was public or protected. The generated constructor will not be variable arity, even if the
      * supertype constructor was.
@@ -524,14 +505,59 @@
         }
     }
 
-    // Object additional param accepting constructor - generated to handle null and undefined value
-    // for script adapters. This is effectively to throw TypeError on such script adapters. See
-    // JavaAdapterServices.getHandle as well.
+    // Object additional param accepting constructor for handling ScriptObjectMirror objects, which are
+    // unwrapped to work as ScriptObjects or ScriptFunctions. This also handles null and undefined values for
+    // script adapters by throwing TypeError on such script adapters.
     private void generateOverridingConstructorWithObjectParam(final InstructionAdapter mv, final String ctorDescriptor) {
         mv.visitCode();
         final int extraArgOffset = emitSuperConstructorCall(mv, ctorDescriptor);
+
+        // Check for ScriptObjectMirror
+        mv.visitVarInsn(ALOAD, extraArgOffset);
+        mv.instanceOf(SCRIPT_OBJECT_MIRROR_TYPE);
+        final Label notMirror = new Label();
+        mv.ifeq(notMirror);
+
+        mv.visitVarInsn(ALOAD, 0);
+        mv.visitVarInsn(ALOAD, extraArgOffset);
+        mv.iconst(0);
+        UNWRAP_MIRROR.invoke(mv);
+        mv.putfield(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);
+
+        mv.visitVarInsn(ALOAD, 0);
+        mv.visitVarInsn(ALOAD, extraArgOffset);
+        mv.iconst(1);
+        UNWRAP_MIRROR.invoke(mv);
+        mv.putfield(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);
+
+        final Label done = new Label();
+
+        if (samName != null) {
+            mv.visitVarInsn(ALOAD, 0);
+            mv.getfield(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);
+            mv.instanceOf(SCRIPT_FUNCTION_TYPE);
+            mv.ifeq(done);
+
+            // Assign "isFunction = true"
+            mv.visitVarInsn(ALOAD, 0);
+            mv.iconst(1);
+            mv.putfield(generatedClassName, IS_FUNCTION_FIELD_NAME, BOOLEAN_TYPE_DESCRIPTOR);
+
+            mv.visitVarInsn(ALOAD, 0);
+            mv.dup();
+            mv.getfield(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR);
+            mv.checkcast(SCRIPT_FUNCTION_TYPE);
+            emitInitCallThis(mv);
+            mv.goTo(done);
+        }
+
+        mv.visitLabel(notMirror);
+
+        // Throw error if not a ScriptObject
         mv.visitVarInsn(ALOAD, extraArgOffset);
         NOT_AN_OBJECT.invoke(mv);
+
+        mv.visitLabel(done);
         endInitMethod(mv);
     }
 
@@ -678,7 +704,7 @@
                 // stack: [callThis, delegate]
                 mv.goTo(callCallee);
                 mv.visitLabel(notFunction);
-        } else {
+            } else {
                 // If it's not a SAM method, and the delegate is a function,
                 // it'll fall back to default behavior
                 mv.ifne(defaultBehavior);
@@ -818,7 +844,7 @@
         if (isVarArgCall) {
             // Variable arity calls are always (Object callee, Object this, Object[] params)
             callParamTypes = new Class<?>[] { Object.class, Object.class, Object[].class };
-            } else {
+        } else {
             // Adjust invocation type signature for conversions we instituted in
             // convertParam; also, byte and short get passed as ints.
             final Class<?>[] origParamTypes = type.parameterArray();
@@ -868,13 +894,13 @@
 
 
     private void loadField(final InstructionAdapter mv, final String name, final String desc) {
-                if(classOverride) {
+        if(classOverride) {
             mv.getstatic(generatedClassName, name, desc);
-                } else {
-                    mv.visitVarInsn(ALOAD, 0);
+        } else {
+            mv.visitVarInsn(ALOAD, 0);
             mv.getfield(generatedClassName, name, desc);
-                }
-            }
+        }
+    }
 
     private static void convertReturnValue(final InstructionAdapter mv, final Class<?> origReturnType) {
         if (origReturnType == void.class) {
@@ -948,6 +974,7 @@
         }
         return len;
     }
+
     /**
      * Emit code to restore the previous Nashorn Context when needed.
      * @param mv the instruction adapter
@@ -999,9 +1026,9 @@
         }
 
         for (final Class<?> iface : interfaces) {
-             if (cl.isAssignableFrom(iface)) {
-                 return iface;
-             }
+            if (cl.isAssignableFrom(iface)) {
+                return iface;
+            }
         }
 
         // we better that interface that extends the given interface!
@@ -1122,8 +1149,8 @@
                     if (Modifier.isFinal(m) || isCallerSensitive(typeMethod)) {
                         finalMethods.add(mi);
                     } else if (!finalMethods.contains(mi) && methodInfos.add(mi) && Modifier.isAbstract(m)) {
-                            abstractMethodNames.add(mi.getName());
-                        }
+                        abstractMethodNames.add(mi.getName());
+                    }
                 }
             }
         }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Wed Jul 05 22:30:23 2017 +0200
@@ -234,7 +234,7 @@
    /**
      * For a given class, create its adapter class and associated info.
      *
-     * @param type the class for which the adapter is created
+     * @param types the class and interfaces for which the adapter is created
      *
      * @return the adapter info for the class.
      */
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterServices.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterServices.java	Wed Jul 05 22:30:23 2017 +0200
@@ -39,6 +39,7 @@
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.invoke.MethodType;
+import java.lang.reflect.Field;
 import java.security.AccessController;
 import java.security.CodeSigner;
 import java.security.CodeSource;
@@ -51,6 +52,7 @@
 import jdk.internal.org.objectweb.asm.Opcodes;
 import jdk.internal.org.objectweb.asm.Type;
 import jdk.internal.org.objectweb.asm.commons.InstructionAdapter;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.internal.objects.Global;
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.ECMAException;
@@ -176,6 +178,23 @@
     }
 
     /**
+     * Returns the ScriptObject or Global field value from a ScriptObjectMirror using reflection.
+     *
+     * @param mirror the mirror object
+     * @param getGlobal true if we want the global object, false to return the script object
+     * @return the script object or global object
+     */
+    public static ScriptObject unwrapMirror(final Object mirror, final boolean getGlobal) {
+        assert mirror instanceof ScriptObjectMirror;
+        try {
+            final Field field = getGlobal ? MirrorFieldHolder.GLOBAL_FIELD : MirrorFieldHolder.SOBJ_FIELD;
+            return (ScriptObject) field.get(mirror);
+        } catch (final IllegalAccessException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
      * Delegate to {@link Bootstrap#bootstrap(Lookup, String, MethodType, int)}.
      * @param lookup MethodHandle lookup.
      * @param opDesc Dynalink dynamic operation descriptor.
@@ -291,4 +310,24 @@
                 .asCollector(Object[].class, type.parameterCount())
                 .asType(type));
     }
+
+    // Initialization on demand holder for accessible ScriptObjectMirror fields
+    private static class MirrorFieldHolder {
+
+        private static final Field SOBJ_FIELD   = getMirrorField("sobj");
+        private static final Field GLOBAL_FIELD = getMirrorField("global");
+
+        private static Field getMirrorField(final String fieldName) {
+            try {
+                final Field field = ScriptObjectMirror.class.getDeclaredField(fieldName);
+                AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+                    field.setAccessible(true);
+                    return null;
+                });
+                return field;
+            } catch (final NoSuchFieldException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
 }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornLinker.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornLinker.java	Wed Jul 05 22:30:23 2017 +0200
@@ -157,12 +157,17 @@
      */
     private static GuardedInvocation getSamTypeConverter(final Class<?> sourceType, final Class<?> targetType, final Supplier<MethodHandles.Lookup> lookupSupplier) throws Exception {
         // If source type is more generic than ScriptFunction class, we'll need to use a guard
-        final boolean isSourceTypeGeneric = sourceType.isAssignableFrom(ScriptFunction.class);
+        final boolean isSourceTypeGeneric = sourceType.isAssignableFrom(ScriptObject.class);
 
         if ((isSourceTypeGeneric || ScriptFunction.class.isAssignableFrom(sourceType)) && isAutoConvertibleFromFunction(targetType)) {
-            final MethodHandle ctor = JavaAdapterFactory.getConstructor(ScriptFunction.class, targetType, getCurrentLookup(lookupSupplier));
+            final Class<?> paramType = isSourceTypeGeneric ? Object.class : ScriptFunction.class;
+            // Using Object.class as constructor source type means we're getting an overloaded constructor handle,
+            // which is safe but slower than a single constructor handle. If the actual argument is a ScriptFunction it
+            // would be nice if we could change the formal parameter to ScriptFunction.class and add a guard for it
+            // in the main invocation.
+            final MethodHandle ctor = JavaAdapterFactory.getConstructor(paramType, targetType, getCurrentLookup(lookupSupplier));
             assert ctor != null; // if isAutoConvertibleFromFunction() returned true, then ctor must exist.
-            return new GuardedInvocation(ctor, isSourceTypeGeneric ? IS_SCRIPT_FUNCTION : null);
+            return new GuardedInvocation(ctor, isSourceTypeGeneric ? IS_FUNCTION : null);
         }
         return null;
     }
@@ -315,7 +320,7 @@
     }
 
     private static final MethodHandle IS_SCRIPT_OBJECT = Guards.isInstance(ScriptObject.class, MH.type(Boolean.TYPE, Object.class));
-    private static final MethodHandle IS_SCRIPT_FUNCTION = Guards.isInstance(ScriptFunction.class, MH.type(Boolean.TYPE, Object.class));
+    private static final MethodHandle IS_FUNCTION = findOwnMH("isFunction", boolean.class, Object.class);
     private static final MethodHandle IS_NATIVE_ARRAY = Guards.isOfClass(NativeArray.class, MH.type(Boolean.TYPE, Object.class));
 
     private static final MethodHandle IS_NASHORN_OR_UNDEFINED_TYPE = findOwnMH("isNashornTypeOrUndefined", Boolean.TYPE, Object.class);
@@ -348,6 +353,11 @@
         return obj instanceof ScriptObject? ScriptUtils.wrap((ScriptObject)obj) : obj;
     }
 
+    @SuppressWarnings("unused")
+    private static boolean isFunction(final Object obj) {
+        return obj instanceof ScriptFunction || obj instanceof ScriptObjectMirror && ((ScriptObjectMirror) obj).isFunction();
+    }
+
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
         return MH.findStatic(MethodHandles.lookup(), NashornLinker.class, name, MH.type(rtype, types));
     }
--- a/nashorn/test/Makefile	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/test/Makefile	Wed Jul 05 22:30:23 2017 +0200
@@ -55,7 +55,7 @@
 UNAME     = uname
 UNIQ      = uniq
 WC        = wc
-ZIP       = zip
+ZIPEXE    = zip
 
 # Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
 UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
@@ -149,7 +149,7 @@
 ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`     \
 	           && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
 	           && $(CHMOD) -R a+r . \
-	           && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
+	           && $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . )
 
 # important results files
 SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8169886.js	Wed Jul 05 22:30:23 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8169886: Add test for JDK-8162839 that runs with SecurityManager
+ *
+ * @test
+ * @run
+ */
+
+
+var m = new javax.script.ScriptEngineManager();
+var e = m.getEngineByName("nashorn");
+
+e.eval("function f() { return 'ok' }");
+var f = e.get("f");
+
+var c = new java.util.concurrent.Callable(f);
+Assert.assertEquals(c.call(), 'ok');
+
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/linker/test/JavaAdapterTest.java	Fri Nov 25 11:16:51 2016 +0800
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/linker/test/JavaAdapterTest.java	Wed Jul 05 22:30:23 2017 +0200
@@ -29,11 +29,14 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Queue;
+import java.util.function.Function;
 import java.util.function.Supplier;
 import javax.script.Bindings;
+import javax.script.ScriptContext;
 import javax.script.ScriptEngine;
 import javax.script.ScriptException;
 import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.NashornScriptEngine;
 import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
 import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.internal.runtime.Context;
@@ -277,4 +280,37 @@
         Assert.assertEquals(tla.getQueue().peek(), "Queue");
         Assert.assertEquals(tla.getDequeue().peek(), "Dequeue");
     }
+
+    @Test
+    public static void testMirrorAdapter() throws ScriptException {
+        final NashornScriptEngine e = (NashornScriptEngine) createEngine();
+        e.setBindings(e.createBindings(), ScriptContext.GLOBAL_SCOPE); // Null by default
+
+        // Referencing functions from across scopes causes them to be wrapped in ScriptObjectMirrors
+        e.eval("function convertObjectFromEngineScope(){ return new java.util.concurrent.Callable(o).call(); }", e.getBindings(ScriptContext.ENGINE_SCOPE));
+        e.eval("function convertObjectFromGlobalScope(){ return new java.util.concurrent.Callable(o).call(); }", e.getBindings(ScriptContext.GLOBAL_SCOPE));
+        e.eval("function convertFuncFromEngineScope(){ return new java.util.concurrent.Callable(g).call(); }", e.getBindings(ScriptContext.ENGINE_SCOPE));
+        e.eval("function convertFuncFromGlobalScope(){ return new java.util.concurrent.Callable(g).call(); }", e.getBindings(ScriptContext.GLOBAL_SCOPE));
+        e.eval("function convertParamFromEngineScope(){ return Java.type('jdk.nashorn.internal.runtime.linker.test.JavaAdapterTest').m(f);}", e.getBindings(ScriptContext.ENGINE_SCOPE));
+        e.eval("function convertParamFromGlobalScope(){ return Java.type('jdk.nashorn.internal.runtime.linker.test.JavaAdapterTest').m(f);}", e.getBindings(ScriptContext.GLOBAL_SCOPE));
+
+        e.eval("var o = { call: function () { return 'ok from o'; } }", e.getBindings(ScriptContext.ENGINE_SCOPE));
+        e.eval("function g() { return 'ok from g'; }", e.getBindings(ScriptContext.ENGINE_SCOPE));
+        e.eval("function f(a) { return a.toUpperCase(); }", e.getBindings(ScriptContext.ENGINE_SCOPE));
+
+        try {
+            Assert.assertEquals(e.invokeFunction("convertObjectFromEngineScope"), "ok from o");
+            Assert.assertEquals(e.invokeFunction("convertObjectFromGlobalScope"), "ok from o");
+            Assert.assertEquals(e.invokeFunction("convertFuncFromEngineScope"), "ok from g");
+            Assert.assertEquals(e.invokeFunction("convertFuncFromGlobalScope"), "ok from g");
+            Assert.assertEquals(e.invokeFunction("convertParamFromEngineScope"), "OK");
+            Assert.assertEquals(e.invokeFunction("convertParamFromGlobalScope"), "OK");
+        } catch (final NoSuchMethodException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    public static String m(final Function<String, String> f){
+        return f.apply("ok");
+    }
 }
--- a/test/make/TestMakeBase.gmk	Fri Nov 25 11:16:51 2016 +0800
+++ b/test/make/TestMakeBase.gmk	Wed Jul 05 22:30:23 2017 +0200
@@ -226,10 +226,11 @@
     Wrong contents in vardeps file))
 
 # Test with a variable value containing some problematic characters
-VARDEP_TEST_VAR3 := foo '""' "''" bar \$$ORIGIN
+VARDEP_TEST_VAR3 := foo '""' "''" bar \$$ORIGIN &\#x00a9
 VARDEP_VALUE_FILE := $(call DependOnVariable, VARDEP_TEST_VAR3)
 -include $(VARDEP_VALUE_FILE)
-$(eval $(call assert-equals, $(VARDEP_TEST_VAR3_old), $(VARDEP_TEST_VAR3), \
+$(eval $(call assert-equals, $(call EscapeHash,$(VARDEP_TEST_VAR3_old)), \
+    $(call EscapeHash,$(VARDEP_TEST_VAR3)), \
     Wrong contents in vardep file))
 
 TEST_TARGETS += test-vardep