Merge
authorjwilhelm
Tue, 24 Jan 2017 00:30:25 +0100
changeset 43537 fe3858b549c8
parent 43536 8212439a528c (current diff)
parent 43247 8d242299a219 (diff)
child 43538 5b3936afe090
child 43715 6d72cc84759f
child 43716 d5fb222e6151
Merge
jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogInvalidPathTest.java
jdk/src/java.base/share/classes/module-info.java
jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProvider.java
jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProviderImpl.java
jdk/src/linux/doc/man/ja/jvisualvm.1
jdk/src/linux/doc/man/jvisualvm.1
jdk/src/solaris/doc/sun/man/man1/ja/jvisualvm.1
jdk/src/solaris/doc/sun/man/man1/jvisualvm.1
jdk/test/ProblemList.txt
jdk/test/java/lang/SecurityManager/RestrictedPackages.java
jdk/test/java/rmi/registry/readTest/readTest.java
jdk/test/java/rmi/registry/readTest/readTest.sh
jdk/test/lib/security/SecurityTools.java
jdk/test/tools/jar/mmrjar/ConcealedPackage.java
jdk/test/tools/jmod/hashes/src/m1/module-info.java
jdk/test/tools/jmod/hashes/src/m1/org/m1/Main.java
jdk/test/tools/jmod/hashes/src/m2/module-info.java
jdk/test/tools/jmod/hashes/src/m2/org/m2/Util.java
jdk/test/tools/jmod/hashes/src/m3/module-info.java
jdk/test/tools/jmod/hashes/src/m3/org/m3/Name.java
jdk/test/tools/jmod/hashes/src/org.bar/module-info.java
jdk/test/tools/jmod/hashes/src/org.foo/module-info.java
jdk/test/tools/launcher/VersionCheck.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacSourcePosition.java
langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/NotDefAccessClassPackageCantAccess.java
langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/module-info.java
langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/p1/C1.java
langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/module-info.java
langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/p2/C2.java
--- a/.hgtags	Wed Jan 25 15:31:01 2017 +0530
+++ b/.hgtags	Tue Jan 24 00:30:25 2017 +0100
@@ -394,3 +394,5 @@
 cf139f925da04c8bd7efd33270a0315d72b338d3 jdk-9+149
 17469f16fbb406ec9f0dd262ce776ab6efbc38f1 jdk-9+150
 37b95df0042ae0687324e1f7dc4a2519e230e704 jdk-9+151
+ab2c8b03c3284fcbdd157551a66f807e3a182d9b jdk-9+152
+d7034ff7f8e257e81c9f95c7785dd4eaaa3c2afc jdk-9+153
--- a/.hgtags-top-repo	Wed Jan 25 15:31:01 2017 +0530
+++ b/.hgtags-top-repo	Tue Jan 24 00:30:25 2017 +0100
@@ -394,3 +394,5 @@
 b119012d1c2ab2570fe8718633840d0c1f1f441d jdk-9+149
 6234069ff9789f7582e1faa32cb6283cbd1a5a2d jdk-9+150
 71a766d4c18041a7f833ee22823125b02e1a7f1e jdk-9+151
+ef056360ddf3977d7d2ddbeb456a4d612d19ea05 jdk-9+152
+816a6d03a7c44edfbd8780110529f1bdc3964fb9 jdk-9+153
--- a/common/autoconf/basics.m4	Wed Jan 25 15:31:01 2017 +0530
+++ b/common/autoconf/basics.m4	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -1011,6 +1011,8 @@
   # Test which kind of tar was found
   if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then
     TAR_TYPE="gnu"
+  elif test "x$($TAR --version | $GREP "bsdtar")" != "x"; then
+    TAR_TYPE="bsd"
   elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then
     TAR_TYPE="bsd"
   elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
@@ -1038,12 +1040,36 @@
   AC_SUBST(TAR_SUPPORTS_TRANSFORM)
 ])
 
+AC_DEFUN([BASIC_CHECK_GREP],
+[
+  # Test that grep supports -Fx with a list of pattern which includes null pattern.
+  # This is a problem for the grep resident on AIX.
+  AC_MSG_CHECKING([that grep ($GREP) -Fx handles empty lines in the pattern list correctly])
+  # Multiple subsequent spaces..
+  STACK_SPACES='aaa   bbb   ccc'
+  # ..converted to subsequent newlines, causes STACK_LIST to be a list with some empty
+  # patterns in it.
+  STACK_LIST=${STACK_SPACES// /$'\n'}
+  NEEDLE_SPACES='ccc bbb aaa'
+  NEEDLE_LIST=${NEEDLE_SPACES// /$'\n'}
+  RESULT="$($GREP -Fvx "$STACK_LIST" <<< "$NEEDLE_LIST")"
+  if test "x$RESULT" == "x"; then
+    AC_MSG_RESULT([yes])
+  else
+    if test "x$OPENJDK_TARGET_OS" = "xaix"; then
+      ADDINFO="Please make sure you use GNU grep, usually found at /opt/freeware/bin."
+    fi
+    AC_MSG_ERROR([grep does not handle -Fx correctly. ${ADDINFO}])
+  fi
+])
+
 AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
 [
   BASIC_CHECK_GNU_MAKE
 
   BASIC_CHECK_FIND_DELETE
   BASIC_CHECK_TAR
+  BASIC_CHECK_GREP
 
   # These tools might not be installed by default,
   # need hint on how to install them.
--- a/common/autoconf/buildjdk-spec.gmk.in	Wed Jan 25 15:31:01 2017 +0530
+++ b/common/autoconf/buildjdk-spec.gmk.in	Tue Jan 24 00:30:25 2017 +0100
@@ -68,7 +68,6 @@
 CFLAGS_JDKEXE := @OPENJDK_BUILD_CFLAGS_JDKEXE@
 CXXFLAGS_JDKEXE := @OPENJDK_BUILD_CXXFLAGS_JDKEXE@
 LDFLAGS_JDKEXE := @OPENJDK_BUILD_LDFLAGS_JDKEXE@
-OPENJDK_TARGET_CPU_JLI_CFLAGS := @OPENJDK_BUILD_CPU_JLI_CFLAGS@
 
 JVM_CFLAGS := @OPENJDK_BUILD_JVM_CFLAGS@
 JVM_LDFLAGS := @OPENJDK_BUILD_JVM_LDFLAGS@
--- a/common/autoconf/flags.m4	Wed Jan 25 15:31:01 2017 +0530
+++ b/common/autoconf/flags.m4	Tue Jan 24 00:30:25 2017 +0100
@@ -815,11 +815,6 @@
     $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -D__solaris__"
   fi
 
-  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-    $2CFLAGS_JDK="${$2CFLAGS_JDK} -D__solaris__"
-    $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -D__solaris__"
-  fi
-
   $2CFLAGS_JDK="${$2CFLAGS_JDK} ${$2EXTRA_CFLAGS}"
   $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2EXTRA_CXXFLAGS}"
   $2LDFLAGS_JDK="${$2LDFLAGS_JDK} ${$2EXTRA_LDFLAGS}"
--- a/common/autoconf/generated-configure.sh	Wed Jan 25 15:31:01 2017 +0530
+++ b/common/autoconf/generated-configure.sh	Tue Jan 24 00:30:25 2017 +0100
@@ -3564,7 +3564,7 @@
 
 # Include these first...
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -3731,6 +3731,8 @@
 
 
 
+
+
 # Check if build directory is on local disk. If not possible to determine,
 # we prefer to claim it's local.
 # Argument 1: directory to test
@@ -4122,7 +4124,7 @@
 
 
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -4237,6 +4239,17 @@
   esac
 }
 
+brew_help() {
+  case $1 in
+    openjdk)
+      PKGHANDLER_COMMAND="brew cask install java" ;;
+    freetype)
+      PKGHANDLER_COMMAND="brew install freetype" ;;
+    ccache)
+      PKGHANDLER_COMMAND="brew install ccache" ;;
+  esac
+}
+
 port_help() {
   PKGHANDLER_COMMAND=""
 }
@@ -4362,7 +4375,7 @@
 
 
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -4667,7 +4680,7 @@
 
 
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -5167,7 +5180,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1483542685
+DATE_WHEN_GENERATED=1484571183
 
 ###############################################################################
 #
@@ -17544,7 +17557,7 @@
 
 # Must be done before we can call HELP_MSG_MISSING_DEPENDENCY.
 
-  for ac_prog in apt-get yum port pkgutil pkgadd
+  for ac_prog in apt-get yum brew port pkgutil pkgadd
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -21209,6 +21222,8 @@
   # Test which kind of tar was found
   if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then
     TAR_TYPE="gnu"
+  elif test "x$($TAR --version | $GREP "bsdtar")" != "x"; then
+    TAR_TYPE="bsd"
   elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then
     TAR_TYPE="bsd"
   elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
@@ -21238,6 +21253,29 @@
 
 
 
+  # Test that grep supports -Fx with a list of pattern which includes null pattern.
+  # This is a problem for the grep resident on AIX.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking that grep ($GREP) -Fx handles empty lines in the pattern list correctly" >&5
+$as_echo_n "checking that grep ($GREP) -Fx handles empty lines in the pattern list correctly... " >&6; }
+  # Multiple subsequent spaces..
+  STACK_SPACES='aaa   bbb   ccc'
+  # ..converted to subsequent newlines, causes STACK_LIST to be a list with some empty
+  # patterns in it.
+  STACK_LIST=${STACK_SPACES// /$'\n'}
+  NEEDLE_SPACES='ccc bbb aaa'
+  NEEDLE_LIST=${NEEDLE_SPACES// /$'\n'}
+  RESULT="$($GREP -Fvx "$STACK_LIST" <<< "$NEEDLE_LIST")"
+  if test "x$RESULT" == "x"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  else
+    if test "x$OPENJDK_TARGET_OS" = "xaix"; then
+      ADDINFO="Please make sure you use GNU grep, usually found at /opt/freeware/bin."
+    fi
+    as_fn_error $? "grep does not handle -Fx correctly. ${ADDINFO}" "$LINENO" 5
+  fi
+
+
   # These tools might not be installed by default,
   # need hint on how to install them.
 
@@ -24359,15 +24397,13 @@
 fi
 
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if packaged modules are kept" >&5
+$as_echo_n "checking if packaged modules are kept... " >&6; }
   if test "x$enable_keep_packaged_modules" = "xyes"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if packaged modules are kept" >&5
-$as_echo_n "checking if packaged modules are kept... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
     JLINK_KEEP_PACKAGED_MODULES=true
   elif test "x$enable_keep_packaged_modules" = "xno"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if packaged modules are kept" >&5
-$as_echo_n "checking if packaged modules are kept... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
     JLINK_KEEP_PACKAGED_MODULES=false
@@ -24376,6 +24412,8 @@
 $as_echo "yes (default)" >&6; }
     JLINK_KEEP_PACKAGED_MODULES=true
   else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5
+$as_echo "error" >&6; }
     as_fn_error $? "--enable-keep-packaged-modules accepts no argument" "$LINENO" 5
   fi
 
@@ -29942,6 +29980,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -33235,6 +33275,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -34534,6 +34576,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -48601,6 +48645,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -48762,6 +48808,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -49897,11 +49945,6 @@
     CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
   fi
 
-  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-    CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
-    CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
-  fi
-
   CFLAGS_JDK="${CFLAGS_JDK} ${EXTRA_CFLAGS}"
   CXXFLAGS_JDK="${CXXFLAGS_JDK} ${EXTRA_CXXFLAGS}"
   LDFLAGS_JDK="${LDFLAGS_JDK} ${EXTRA_LDFLAGS}"
@@ -50720,11 +50763,6 @@
     OPENJDK_BUILD_CXXFLAGS_JDK="${OPENJDK_BUILD_CXXFLAGS_JDK} -D__solaris__"
   fi
 
-  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-    OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} -D__solaris__"
-    OPENJDK_BUILD_CXXFLAGS_JDK="${OPENJDK_BUILD_CXXFLAGS_JDK} -D__solaris__"
-  fi
-
   OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} ${OPENJDK_BUILD_EXTRA_CFLAGS}"
   OPENJDK_BUILD_CXXFLAGS_JDK="${OPENJDK_BUILD_CXXFLAGS_JDK} ${OPENJDK_BUILD_EXTRA_CXXFLAGS}"
   OPENJDK_BUILD_LDFLAGS_JDK="${OPENJDK_BUILD_LDFLAGS_JDK} ${OPENJDK_BUILD_EXTRA_LDFLAGS}"
@@ -52844,6 +52882,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -56649,6 +56689,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -56721,6 +56763,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -56864,6 +56908,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -60741,6 +60787,345 @@
   fi
 
           fi
+          if test "x$FOUND_FREETYPE" != xyes; then
+            FREETYPE_BASE_DIR="$SYSROOT/usr/local"
+
+  POTENTIAL_FREETYPE_INCLUDE_PATH="$FREETYPE_BASE_DIR/include"
+  POTENTIAL_FREETYPE_LIB_PATH="$FREETYPE_BASE_DIR/lib"
+  METHOD="well-known location"
+
+  # Let's start with an optimistic view of the world :-)
+  FOUND_FREETYPE=yes
+
+  # First look for the canonical freetype main include file ft2build.h.
+  if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
+    # Oh no! Let's try in the freetype2 directory. This is needed at least at Mac OS X Yosemite.
+    POTENTIAL_FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH/freetype2"
+    if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
+      # Fail.
+      FOUND_FREETYPE=no
+    fi
+  fi
+
+  if test "x$FOUND_FREETYPE" = xyes; then
+    # Include file found, let's continue the sanity check.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD" >&5
+$as_echo "$as_me: Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD" >&6;}
+
+    # Reset to default value
+    FREETYPE_BASE_NAME=freetype
+    FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}"
+    if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then
+      if test "x$OPENJDK_TARGET_OS" = xmacosx \
+          && test -s "$POTENTIAL_FREETYPE_LIB_PATH/${LIBRARY_PREFIX}freetype.6${SHARED_LIBRARY_SUFFIX}"; then
+        # On Mac OS X Yosemite, the symlink from libfreetype.dylib to libfreetype.6.dylib disappeared. Check
+        # for the .6 version explicitly.
+        FREETYPE_BASE_NAME=freetype.6
+        FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}"
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Compensating for missing symlink by using version 6 explicitly" >&5
+$as_echo "$as_me: Compensating for missing symlink by using version 6 explicitly" >&6;}
+      else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location." >&5
+$as_echo "$as_me: Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location." >&6;}
+        FOUND_FREETYPE=no
+      fi
+    else
+      if test "x$OPENJDK_TARGET_OS" = xwindows; then
+        # On Windows, we will need both .lib and .dll file.
+        if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location." >&5
+$as_echo "$as_me: Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location." >&6;}
+          FOUND_FREETYPE=no
+        fi
+      elif test "x$OPENJDK_TARGET_OS" = xsolaris \
+          && test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then
+        # Found lib in isa dir, use that instead.
+        POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR"
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting to use $POTENTIAL_FREETYPE_LIB_PATH instead" >&5
+$as_echo "$as_me: Rewriting to use $POTENTIAL_FREETYPE_LIB_PATH instead" >&6;}
+      fi
+    fi
+  fi
+
+  if test "x$FOUND_FREETYPE" = xyes; then
+
+  # Only process if variable expands to non-empty
+
+  if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != x; then
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$POTENTIAL_FREETYPE_INCLUDE_PATH"
+  new_path=`$CYGPATH -u "$path"`
+
+  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+  # "foo.exe" is OK but "foo" is an error.
+  #
+  # This test is therefore slightly more accurate than "test -f" to check for file precense.
+  # It is also a way to make sure we got the proper file name for the real test later on.
+  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+  if test "x$test_shortpath" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of POTENTIAL_FREETYPE_INCLUDE_PATH" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-style (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    POTENTIAL_FREETYPE_INCLUDE_PATH="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&6;}
+  fi
+
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$POTENTIAL_FREETYPE_INCLUDE_PATH"
+  has_colon=`$ECHO $path | $GREP ^.:`
+  new_path="$path"
+  if test "x$has_colon" = x; then
+    # Not in mixed or Windows style, start by that.
+    new_path=`cmd //c echo $path`
+  fi
+
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  fi
+
+
+  windows_path="$new_path"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    new_path="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    new_path="$unix_path"
+  fi
+
+  if test "x$path" != "x$new_path"; then
+    POTENTIAL_FREETYPE_INCLUDE_PATH="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&6;}
+  fi
+
+  # Save the first 10 bytes of this path to the storage, so fixpath can work.
+  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+    else
+      # We're on a unix platform. Hooray! :)
+      path="$POTENTIAL_FREETYPE_INCLUDE_PATH"
+      has_space=`$ECHO "$path" | $GREP " "`
+      if test "x$has_space" != x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&6;}
+        as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+      fi
+
+      # Use eval to expand a potential ~
+      eval path="$path"
+      if test ! -f "$path" && test ! -d "$path"; then
+        as_fn_error $? "The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is not found." "$LINENO" 5
+      fi
+
+      if test -d "$path"; then
+        POTENTIAL_FREETYPE_INCLUDE_PATH="`cd "$path"; $THEPWDCMD -L`"
+      else
+        dir="`$DIRNAME "$path"`"
+        base="`$BASENAME "$path"`"
+        POTENTIAL_FREETYPE_INCLUDE_PATH="`cd "$dir"; $THEPWDCMD -L`/$base"
+      fi
+    fi
+  fi
+
+
+  # Only process if variable expands to non-empty
+
+  if test "x$POTENTIAL_FREETYPE_LIB_PATH" != x; then
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$POTENTIAL_FREETYPE_LIB_PATH"
+  new_path=`$CYGPATH -u "$path"`
+
+  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+  # "foo.exe" is OK but "foo" is an error.
+  #
+  # This test is therefore slightly more accurate than "test -f" to check for file precense.
+  # It is also a way to make sure we got the proper file name for the real test later on.
+  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+  if test "x$test_shortpath" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of POTENTIAL_FREETYPE_LIB_PATH" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-style (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    POTENTIAL_FREETYPE_LIB_PATH="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&6;}
+  fi
+
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$POTENTIAL_FREETYPE_LIB_PATH"
+  has_colon=`$ECHO $path | $GREP ^.:`
+  new_path="$path"
+  if test "x$has_colon" = x; then
+    # Not in mixed or Windows style, start by that.
+    new_path=`cmd //c echo $path`
+  fi
+
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  fi
+
+
+  windows_path="$new_path"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    new_path="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    new_path="$unix_path"
+  fi
+
+  if test "x$path" != "x$new_path"; then
+    POTENTIAL_FREETYPE_LIB_PATH="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&6;}
+  fi
+
+  # Save the first 10 bytes of this path to the storage, so fixpath can work.
+  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+    else
+      # We're on a unix platform. Hooray! :)
+      path="$POTENTIAL_FREETYPE_LIB_PATH"
+      has_space=`$ECHO "$path" | $GREP " "`
+      if test "x$has_space" != x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&6;}
+        as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+      fi
+
+      # Use eval to expand a potential ~
+      eval path="$path"
+      if test ! -f "$path" && test ! -d "$path"; then
+        as_fn_error $? "The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is not found." "$LINENO" 5
+      fi
+
+      if test -d "$path"; then
+        POTENTIAL_FREETYPE_LIB_PATH="`cd "$path"; $THEPWDCMD -L`"
+      else
+        dir="`$DIRNAME "$path"`"
+        base="`$BASENAME "$path"`"
+        POTENTIAL_FREETYPE_LIB_PATH="`cd "$dir"; $THEPWDCMD -L`/$base"
+      fi
+    fi
+  fi
+
+
+    FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype includes" >&5
+$as_echo_n "checking for freetype includes... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE_INCLUDE_PATH" >&5
+$as_echo "$FREETYPE_INCLUDE_PATH" >&6; }
+    FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype libraries" >&5
+$as_echo_n "checking for freetype libraries... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE_LIB_PATH" >&5
+$as_echo "$FREETYPE_LIB_PATH" >&6; }
+  fi
+
+          fi
 
           if test "x$OPENJDK_TARGET_OS" = xmacosx; then
             if test "x$FOUND_FREETYPE" != xyes; then
@@ -62122,6 +62507,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -62477,6 +62864,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -62682,6 +63071,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -62870,6 +63261,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -62949,6 +63342,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -64058,6 +64453,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -64142,6 +64539,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
--- a/common/autoconf/help.m4	Wed Jan 25 15:31:01 2017 +0530
+++ b/common/autoconf/help.m4	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 AC_DEFUN_ONCE([HELP_SETUP_DEPENDENCY_HELP],
 [
-  AC_CHECK_PROGS(PKGHANDLER, apt-get yum port pkgutil pkgadd)
+  AC_CHECK_PROGS(PKGHANDLER, apt-get yum brew port pkgutil pkgadd)
 ])
 
 AC_DEFUN([HELP_MSG_MISSING_DEPENDENCY],
@@ -46,6 +46,8 @@
         apt_help     $MISSING_DEPENDENCY ;;
       yum)
         yum_help     $MISSING_DEPENDENCY ;;
+      brew)
+        brew_help    $MISSING_DEPENDENCY ;;
       port)
         port_help    $MISSING_DEPENDENCY ;;
       pkgutil)
@@ -147,6 +149,17 @@
   esac
 }
 
+brew_help() {
+  case $1 in
+    openjdk)
+      PKGHANDLER_COMMAND="brew cask install java" ;;
+    freetype)
+      PKGHANDLER_COMMAND="brew install freetype" ;;
+    ccache)
+      PKGHANDLER_COMMAND="brew install ccache" ;;
+  esac
+}
+
 port_help() {
   PKGHANDLER_COMMAND=""
 }
--- a/common/autoconf/jdk-options.m4	Wed Jan 25 15:31:01 2017 +0530
+++ b/common/autoconf/jdk-options.m4	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -382,18 +382,18 @@
   AC_ARG_ENABLE([keep-packaged-modules], [AS_HELP_STRING([--disable-keep-packaged-modules],
     [Do not keep packaged modules in jdk image @<:@enable@:>@])])
 
+  AC_MSG_CHECKING([if packaged modules are kept])
   if test "x$enable_keep_packaged_modules" = "xyes"; then
-    AC_MSG_CHECKING([if packaged modules are kept])
     AC_MSG_RESULT([yes])
     JLINK_KEEP_PACKAGED_MODULES=true
   elif test "x$enable_keep_packaged_modules" = "xno"; then
-    AC_MSG_CHECKING([if packaged modules are kept])
     AC_MSG_RESULT([no])
     JLINK_KEEP_PACKAGED_MODULES=false
   elif test "x$enable_keep_packaged_modules" = "x"; then
     AC_MSG_RESULT([yes (default)])
     JLINK_KEEP_PACKAGED_MODULES=true
   else
+    AC_MSG_RESULT([error])
     AC_MSG_ERROR([--enable-keep-packaged-modules accepts no argument])
   fi
 
--- a/common/autoconf/lib-freetype.m4	Wed Jan 25 15:31:01 2017 +0530
+++ b/common/autoconf/lib-freetype.m4	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -348,6 +348,10 @@
             FREETYPE_BASE_DIR="$SYSROOT/usr/X11"
             LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
           fi
+          if test "x$FOUND_FREETYPE" != xyes; then
+            FREETYPE_BASE_DIR="$SYSROOT/usr/local"
+            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
+          fi
 
           if test "x$OPENJDK_TARGET_OS" = xmacosx; then
             if test "x$FOUND_FREETYPE" != xyes; then
--- a/common/autoconf/spec.gmk.in	Wed Jan 25 15:31:01 2017 +0530
+++ b/common/autoconf/spec.gmk.in	Tue Jan 24 00:30:25 2017 +0100
@@ -274,8 +274,6 @@
 CONFIGURESUPPORT_OUTPUTDIR:=@CONFIGURESUPPORT_OUTPUTDIR@
 BUILDJDK_OUTPUTDIR=$(BUILD_OUTPUT)/buildjdk
 
-BUILD_HOTSPOT=@BUILD_HOTSPOT@
-
 BUILD_FAILURE_HANDLER := @BUILD_FAILURE_HANDLER@
 
 ENABLE_GENERATE_CLASSLIST := @ENABLE_GENERATE_CLASSLIST@
@@ -642,7 +640,6 @@
 NICE:=@NICE@
 PATCH:=@PATCH@
 PRINTF:=@PRINTF@
-PWD:=@THEPWDCMD@
 RM:=@RM@
 RMDIR:=@RMDIR@
 SED:=@SED@
@@ -778,11 +775,18 @@
 # Images directory definitions
 JDK_IMAGE_SUBDIR:=jdk
 JRE_IMAGE_SUBDIR:=jre
+JRE_COMPACT1_IMAGE_SUBDIR := jre-compact1
+JRE_COMPACT2_IMAGE_SUBDIR := jre-compact2
+JRE_COMPACT3_IMAGE_SUBDIR := jre-compact3
 
 # Colon left out to be able to override output dir for bootcycle-images
 JDK_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_IMAGE_SUBDIR)
 JRE_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_IMAGE_SUBDIR)
 
+JRE_COMPACT1_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(JRE_COMPACT1_IMAGE_SUBDIR)
+JRE_COMPACT2_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(JRE_COMPACT2_IMAGE_SUBDIR)
+JRE_COMPACT3_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(JRE_COMPACT3_IMAGE_SUBDIR)
+
 # Test image, as above
 TEST_IMAGE_SUBDIR:=test
 TEST_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(TEST_IMAGE_SUBDIR)
@@ -818,6 +822,12 @@
 endif
 JDK_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz
 JRE_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz
+JRE_COMPACT1_BUNDLE_NAME := \
+    jre-$(VERSION_SHORT)+$(VERSION_BUILD)-compact1_$(OPENJDK_TARGET_BUNDLE_PLATFORM)_bin$(DEBUG_PART).tar.gz
+JRE_COMPACT2_BUNDLE_NAME := \
+    jre-$(VERSION_SHORT)+$(VERSION_BUILD)-compact2_$(OPENJDK_TARGET_BUNDLE_PLATFORM)_bin$(DEBUG_PART).tar.gz
+JRE_COMPACT3_BUNDLE_NAME := \
+    jre-$(VERSION_SHORT)+$(VERSION_BUILD)-compact3_$(OPENJDK_TARGET_BUNDLE_PLATFORM)_bin$(DEBUG_PART).tar.gz
 JDK_SYMBOLS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
 JRE_SYMBOLS_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
 ifeq ($(OPENJDK_TARGET_OS), windows)
--- a/common/conf/jib-profiles.js	Wed Jan 25 15:31:01 2017 +0530
+++ b/common/conf/jib-profiles.js	Tue Jan 24 00:30:25 2017 +0100
@@ -501,7 +501,7 @@
     // extra default target.
     var openOnlyProfilesExtra = {
         "linux-x86-open": {
-            default_make_targets: "profiles",
+            default_make_targets: "profiles-bundles",
             configure_args: "--with-jvm-variants=client,server"
         }
     };
@@ -587,6 +587,7 @@
             ],
             work_dir: input.get("src.full", "install_path") + "/test",
             environment: {
+                "JT_JAVA": common.boot_jdk_home,
                 "PRODUCT_HOME": input.get(testedProfile + ".jdk", "home_path"),
                 "TEST_IMAGE_DIR": input.get(testedProfile + ".test", "home_path"),
                 "TEST_OUTPUT_DIR": input.src_top_dir
@@ -710,10 +711,15 @@
                     local: "bundles/\\(jdk.*bin.tar.gz\\)",
                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
                 },
+                jdk_symbols: {
+                    local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
+                    remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
+                },
                 jre: {
-                    local: "bundles/\\(jre.*[0-9]_linux-x86_bin.tar.gz\\)",
+                    // This regexp needs to not match the compact* files below
+                    local: "bundles/\\(jre.*[+][0-9]\\{1,\\}_linux-x86_bin.tar.gz\\)",
                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
-                },/* The build does not create these
+                },
                 jre_compact1: {
                     local: "bundles/\\(jre.*-compact1_linux-x86_bin.tar.gz\\)",
                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
@@ -725,7 +731,7 @@
                 jre_compact3: {
                     local: "bundles/\\(jre.*-compact3_linux-x86_bin.tar.gz\\)",
                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
-                },*/
+                },
             }
         },
 
@@ -864,7 +870,7 @@
         jtreg: {
             server: "javare",
             revision: "4.2",
-            build_number: "b04",
+            build_number: "b05",
             checksum_file: "MD5_VALUES",
             file: "jtreg_bin-4.2.zip",
             environment_name: "JT_HOME",
--- a/corba/.hgtags	Wed Jan 25 15:31:01 2017 +0530
+++ b/corba/.hgtags	Tue Jan 24 00:30:25 2017 +0100
@@ -394,3 +394,5 @@
 00b19338e505690abe93d5995ed74a473d969c2c jdk-9+149
 9205e980062a5c4530b51021c6e274025f4ccbdf jdk-9+150
 77f827f5bbad3ef795664bc675f72d98d156b9f8 jdk-9+151
+ff8cb43c07c069b1debdee44cb88ca22db1ec757 jdk-9+152
+68a8e8658511093b322a46ed04b2a321e1da2a43 jdk-9+153
--- a/hotspot/.hgtags	Wed Jan 25 15:31:01 2017 +0530
+++ b/hotspot/.hgtags	Tue Jan 24 00:30:25 2017 +0100
@@ -554,3 +554,5 @@
 30e1996bd55da36183434f24ed964adebf9ca71e jdk-9+149
 98fe046473c90204cbc9b34c512b9fc10dfb8479 jdk-9+150
 2a2ac7d9f52c8cb2b80077e515b5840b947e640c jdk-9+151
+31f1d26c60df7b2e516a4f84160d76ba017d4e09 jdk-9+152
+217ba81b9a4ce8698200370175aa2db86a39f66c jdk-9+153
--- a/jaxp/.hgtags	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/.hgtags	Tue Jan 24 00:30:25 2017 +0100
@@ -394,3 +394,5 @@
 5978df8bfa3894f2b3d07b7256f25f78dffb1f9c jdk-9+149
 f85154af719f99a3b4d81b67a8b4c18a650d10f9 jdk-9+150
 13c6906bfc861d99dc35a19c80b7a99f0b0ac58d jdk-9+151
+7e3da313b1746578da648155e37dd8526e83153d jdk-9+152
+1384504d2cd0e55c5e0becaeaf40ab05cae959d6 jdk-9+153
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,20 +17,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: DOM2SAX.java,v 1.2.4.1 2005/09/06 11:52:46 pvedula Exp $
- */
-
 
 package com.sun.org.apache.xalan.internal.xsltc.trax;
 
 import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
 import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Stack;
-import java.util.Vector;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.xml.sax.ContentHandler;
@@ -58,7 +54,7 @@
     private ContentHandler _sax = null;
     private LexicalHandler _lex = null;
     private SAXImpl _saxImpl = null;
-    private Map<String, Stack> _nsPrefixes = new HashMap<>();
+    private Map<String, Stack<String>> _nsPrefixes = new HashMap<>();
 
     public DOM2SAX(Node root) {
         _dom = root;
@@ -73,7 +69,7 @@
     {
         _sax = handler;
         if (handler instanceof LexicalHandler) {
-            _lex = (LexicalHandler) handler;
+            _lex = (LexicalHandler)handler;
         }
 
         if (handler instanceof SAXImpl) {
@@ -90,25 +86,22 @@
         throws SAXException
     {
         boolean pushed = true;
-        Stack uriStack = _nsPrefixes.get(prefix);
+        Stack<String> uriStack = _nsPrefixes.get(prefix);
 
         if (uriStack != null) {
             if (uriStack.isEmpty()) {
                 _sax.startPrefixMapping(prefix, uri);
                 uriStack.push(uri);
-            }
-            else {
-                final String lastUri = (String) uriStack.peek();
+            } else {
+                final String lastUri = uriStack.peek();
                 if (!lastUri.equals(uri)) {
                     _sax.startPrefixMapping(prefix, uri);
                     uriStack.push(uri);
-                }
-                else {
+                } else {
                     pushed = false;
                 }
             }
-        }
-        else {
+        } else {
             _sax.startPrefixMapping(prefix, uri);
             _nsPrefixes.put(prefix, uriStack = new Stack());
             uriStack.push(uri);
@@ -123,7 +116,7 @@
     private void endPrefixMapping(String prefix)
         throws SAXException
     {
-        final Stack uriStack = _nsPrefixes.get(prefix);
+        final Stack<String> uriStack = _nsPrefixes.get(prefix);
 
         if (uriStack != null) {
             _sax.endPrefixMapping(prefix);
@@ -131,22 +124,6 @@
         }
     }
 
-    /**
-     * If the DOM was created using a DOM 1.0 API, the local name may be
-     * null. If so, get the local name from the qualified name before
-     * generating the SAX event.
-     */
-    private static String getLocalName(Node node) {
-        final String localName = node.getLocalName();
-
-        if (localName == null) {
-            final String qname = node.getNodeName();
-            final int col = qname.lastIndexOf(':');
-            return (col > 0) ? qname.substring(col + 1) : qname;
-        }
-        return localName;
-    }
-
     public void parse(InputSource unused) throws IOException, SAXException {
         parse(_dom);
     }
@@ -173,8 +150,8 @@
      * declarations.
      */
     private void parse(Node node) throws IOException, SAXException {
-        Node first = null;
-        if (node == null) return;
+        if (node == null)
+            return;
 
         switch (node.getNodeType()) {
         case Node.ATTRIBUTE_NODE:         // handled by ELEMENT_NODE
@@ -198,7 +175,6 @@
                 _sax.characters(cdata.toCharArray(), 0, cdata.length());
             }
             break;
-
         case Node.COMMENT_NODE:           // should be handled!!!
             if (_lex != null) {
                 final String value = node.getNodeValue();
@@ -216,10 +192,9 @@
             }
             _sax.endDocument();
             break;
-
         case Node.ELEMENT_NODE:
             String prefix;
-            Vector pushedPrefixes = new Vector();
+            ArrayList<String> pushedPrefixes = new ArrayList<>();
             final AttributesImpl attrs = new AttributesImpl();
             final NamedNodeMap map = node.getAttributes();
             final int length = map.getLength();
@@ -235,7 +210,7 @@
                     final int colon = qnameAttr.lastIndexOf(':');
                     prefix = (colon > 0) ? qnameAttr.substring(colon + 1) : EMPTYSTRING;
                     if (startPrefixMapping(prefix, uriAttr)) {
-                        pushedPrefixes.addElement(prefix);
+                        pushedPrefixes.add(prefix);
                     }
                 }
             }
@@ -248,27 +223,25 @@
                 // Ignore NS declarations here
                 if (!qnameAttr.startsWith(XMLNS_PREFIX)) {
                     final String uriAttr = attr.getNamespaceURI();
-                    final String localNameAttr = getLocalName(attr);
 
                     // Uri may be implicitly declared
                     if (uriAttr != null) {
                         final int colon = qnameAttr.lastIndexOf(':');
                         if (colon > 0) {
                             prefix = qnameAttr.substring(0, colon);
-                        }
-                        else {
+                        } else {
                             // If no prefix for this attr, we need to create
                             // one because we cannot use the default ns
                             prefix = BasisLibrary.generatePrefix();
                             qnameAttr = prefix + ':' + qnameAttr;
                         }
                         if (startPrefixMapping(prefix, uriAttr)) {
-                            pushedPrefixes.addElement(prefix);
+                            pushedPrefixes.add(prefix);
                         }
                     }
 
                     // Add attribute to list
-                    attrs.addAttribute(attr.getNamespaceURI(), getLocalName(attr),
+                    attrs.addAttribute(attr.getNamespaceURI(), attr.getLocalName(),
                         qnameAttr, "CDATA", attr.getNodeValue());
                 }
             }
@@ -276,22 +249,21 @@
             // Now process the element itself
             final String qname = node.getNodeName();
             final String uri = node.getNamespaceURI();
-            final String localName = getLocalName(node);
+            final String localName = node.getLocalName();
 
-            // Uri may be implicitly declared
+            // URI may be implicitly declared
             if (uri != null) {
                 final int colon = qname.lastIndexOf(':');
                 prefix = (colon > 0) ? qname.substring(0, colon) : EMPTYSTRING;
                 if (startPrefixMapping(prefix, uri)) {
-                    pushedPrefixes.addElement(prefix);
+                    pushedPrefixes.add(prefix);
                 }
             }
 
             // Generate SAX event to start element
             if (_saxImpl != null) {
                 _saxImpl.startElement(uri, localName, qname, attrs, node);
-            }
-            else {
+            } else {
                 _sax.startElement(uri, localName, qname, attrs);
             }
 
@@ -308,15 +280,13 @@
             // Generate endPrefixMapping() for all pushed prefixes
             final int nPushedPrefixes = pushedPrefixes.size();
             for (int i = 0; i < nPushedPrefixes; i++) {
-                endPrefixMapping((String) pushedPrefixes.elementAt(i));
+                endPrefixMapping(pushedPrefixes.get(i));
             }
             break;
-
         case Node.PROCESSING_INSTRUCTION_NODE:
             _sax.processingInstruction(node.getNodeName(),
                                        node.getNodeValue());
             break;
-
         case Node.TEXT_NODE:
             final String data = node.getNodeValue();
             _sax.characters(data.toCharArray(), 0, data.length());
@@ -449,36 +419,4 @@
     public String getSystemId() {
         return null;
     }
-
-    // Debugging
-    private String getNodeTypeFromCode(short code) {
-        String retval = null;
-        switch (code) {
-        case Node.ATTRIBUTE_NODE :
-            retval = "ATTRIBUTE_NODE"; break;
-        case Node.CDATA_SECTION_NODE :
-            retval = "CDATA_SECTION_NODE"; break;
-        case Node.COMMENT_NODE :
-            retval = "COMMENT_NODE"; break;
-        case Node.DOCUMENT_FRAGMENT_NODE :
-            retval = "DOCUMENT_FRAGMENT_NODE"; break;
-        case Node.DOCUMENT_NODE :
-            retval = "DOCUMENT_NODE"; break;
-        case Node.DOCUMENT_TYPE_NODE :
-            retval = "DOCUMENT_TYPE_NODE"; break;
-        case Node.ELEMENT_NODE :
-            retval = "ELEMENT_NODE"; break;
-        case Node.ENTITY_NODE :
-            retval = "ENTITY_NODE"; break;
-        case Node.ENTITY_REFERENCE_NODE :
-            retval = "ENTITY_REFERENCE_NODE"; break;
-        case Node.NOTATION_NODE :
-            retval = "NOTATION_NODE"; break;
-        case Node.PROCESSING_INSTRUCTION_NODE :
-            retval = "PROCESSING_INSTRUCTION_NODE"; break;
-        case Node.TEXT_NODE:
-            retval = "TEXT_NODE"; break;
-        }
-        return retval;
-    }
 }
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,14 +17,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: SAX2DTM.java,v 1.2.4.1 2005/09/15 08:15:11 suresh_emailid Exp $
- */
+
 package com.sun.org.apache.xml.internal.dtm.ref.sax2dtm;
 
-
-import com.sun.org.apache.xml.internal.dtm.*;
-import com.sun.org.apache.xml.internal.dtm.ref.*;
+import com.sun.org.apache.xml.internal.dtm.DTM;
+import com.sun.org.apache.xml.internal.dtm.DTMManager;
+import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBaseIterators;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMStringPool;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMTreeWalker;
+import com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource;
+import com.sun.org.apache.xml.internal.dtm.ref.NodeLocator;
 import com.sun.org.apache.xml.internal.res.XMLErrorResources;
 import com.sun.org.apache.xml.internal.res.XMLMessages;
 import com.sun.org.apache.xml.internal.utils.FastStringBuffer;
@@ -36,13 +40,23 @@
 import com.sun.org.apache.xml.internal.utils.WrappedRuntimeException;
 import com.sun.org.apache.xml.internal.utils.XMLString;
 import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Vector;
 import javax.xml.transform.Source;
 import javax.xml.transform.SourceLocator;
-import org.xml.sax.*;
-import org.xml.sax.ext.*;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.ext.DeclHandler;
+import org.xml.sax.ext.LexicalHandler;
 
 /**
  * This class implements a DTM that tends to be optimized more for speed than
@@ -82,7 +96,6 @@
    *
    * Made protected rather than private so SAX2RTFDTM can access it.
    */
-  //private FastStringBuffer m_chars = new FastStringBuffer(13, 13);
   protected FastStringBuffer m_chars;
 
   /** This vector holds offset and length data.
@@ -102,8 +115,7 @@
   /** Namespace support, only relevent at construction time.
    * Made protected rather than private so SAX2RTFDTM can access it.
    */
-  transient protected java.util.Vector m_prefixMappings =
-    new java.util.Vector();
+  transient protected Vector<String> m_prefixMappings = new Vector<>();
 
   /** Namespace support, only relevent at construction time.
    * Made protected rather than private so SAX2RTFDTM can access it.
@@ -164,7 +176,7 @@
    * Vector of entities.  Each record is composed of four Strings:
    *  publicId, systemID, notationName, and name.
    */
-  private Vector m_entities = null;
+  private ArrayList<String> m_entities = null;
 
   /** m_entities public ID offset. */
   private static final int ENTITY_FIELD_PUBLICID = 0;
@@ -196,13 +208,15 @@
    */
   protected boolean m_useSourceLocationProperty = false;
 
-   /** Made protected for access by SAX2RTFDTM.
+  /** Made protected for access by SAX2RTFDTM.
    */
   protected StringVector m_sourceSystemId;
-   /** Made protected for access by SAX2RTFDTM.
+
+  /** Made protected for access by SAX2RTFDTM.
    */
   protected IntVector m_sourceLine;
-   /** Made protected for access by SAX2RTFDTM.
+
+  /** Made protected for access by SAX2RTFDTM.
    */
   protected IntVector m_sourceColumn;
 
@@ -252,23 +266,19 @@
                  boolean usePrevsib,
                  boolean newNameTable)
   {
-
     super(mgr, source, dtmIdentity, whiteSpaceFilter,
           xstringfactory, doIndexing, blocksize, usePrevsib, newNameTable);
 
     // %OPT% Use smaller sizes for all internal storage units when
     // the blocksize is small. This reduces the cost of creating an RTF.
-    if (blocksize <= 64)
-    {
+    if (blocksize <= 64) {
       m_data = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS_SMALL);
       m_dataOrQName = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS_SMALL);
       m_valuesOrPrefixes = new DTMStringPool(16);
       m_chars = new FastStringBuffer(7, 10);
       m_contextIndexes = new IntStack(4);
       m_parents = new IntStack(4);
-    }
-    else
-    {
+    } else {
       m_data = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS);
       m_dataOrQName = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS);
       m_valuesOrPrefixes = new DTMStringPool();
@@ -289,7 +299,7 @@
     // m_useSourceLocationProperty=com.sun.org.apache.xalan.internal.processor.TransformerFactoryImpl.m_source_location;
     m_useSourceLocationProperty = mgr.getSource_location();
     m_sourceSystemId = (m_useSourceLocationProperty) ? new StringVector() : null;
-        m_sourceLine = (m_useSourceLocationProperty) ?  new IntVector() : null;
+    m_sourceLine = (m_useSourceLocationProperty) ?  new IntVector() : null;
     m_sourceColumn = (m_useSourceLocationProperty) ?  new IntVector() : null;
   }
 
@@ -297,8 +307,7 @@
    * Set whether information about document source location
    * should be maintained or not.
    */
-  public void setUseSourceLocation(boolean useSourceLocation)
-  {
+  public void setUseSourceLocation(boolean useSourceLocation) {
     m_useSourceLocationProperty = useSourceLocation;
   }
 
@@ -309,17 +318,14 @@
    *
    * @return The data or qualified name, or DTM.NULL.
    */
-  protected int _dataOrQName(int identity)
-  {
-
+  protected int _dataOrQName(int identity) {
     if (identity < m_size)
       return m_dataOrQName.elementAt(identity);
 
     // Check to see if the information requested has been processed, and,
     // if not, advance the iterator until we the information has been
     // processed.
-    while (true)
-    {
+    while (true) {
       boolean isMore = nextNode();
 
       if (!isMore)
@@ -332,8 +338,7 @@
   /**
    * Ask the CoRoutine parser to doTerminate and clear the reference.
    */
-  public void clearCoRoutine()
-  {
+  public void clearCoRoutine() {
     clearCoRoutine(true);
   }
 
@@ -344,11 +349,8 @@
    * @param callDoTerminate true of doTerminate should be called on the
    * coRoutine parser.
    */
-  public void clearCoRoutine(boolean callDoTerminate)
-  {
-
-    if (null != m_incrementalSAXSource)
-    {
+  public void clearCoRoutine(boolean callDoTerminate) {
+    if (null != m_incrementalSAXSource) {
       if (callDoTerminate)
         m_incrementalSAXSource.deliverMoreNodes(false);
 
@@ -368,9 +370,7 @@
    * @param incrementalSAXSource The parser that we want to recieve events from
    * on demand.
    */
-  public void setIncrementalSAXSource(IncrementalSAXSource incrementalSAXSource)
-  {
-
+  public void setIncrementalSAXSource(IncrementalSAXSource incrementalSAXSource) {
     // Establish coroutine link so we can request more data
     //
     // Note: It's possible that some versions of IncrementalSAXSource may
@@ -406,11 +406,9 @@
    * Note that IncrementalSAXSource_Filter is package private, hence
    * it can be statically referenced using instanceof (CR 6537912).
    */
-  public ContentHandler getContentHandler()
-  {
-
-    if (m_incrementalSAXSource.getClass()
-        .getName().equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter"))
+  public ContentHandler getContentHandler() {
+    if (m_incrementalSAXSource.getClass().getName()
+        .equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter"))
       return (ContentHandler) m_incrementalSAXSource;
     else
       return this;
@@ -429,11 +427,9 @@
    * Note that IncrementalSAXSource_Filter is package private, hence
    * it can be statically referenced using instanceof (CR 6537912).
    */
-  public LexicalHandler getLexicalHandler()
-  {
-
-    if (m_incrementalSAXSource.getClass()
-        .getName().equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter"))
+  public LexicalHandler getLexicalHandler() {
+    if (m_incrementalSAXSource.getClass().getName()
+        .equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter"))
       return (LexicalHandler) m_incrementalSAXSource;
     else
       return this;
@@ -444,8 +440,7 @@
    *
    * @return null if this model doesn't respond to SAX entity ref events.
    */
-  public EntityResolver getEntityResolver()
-  {
+  public EntityResolver getEntityResolver() {
     return this;
   }
 
@@ -454,8 +449,7 @@
    *
    * @return null if this model doesn't respond to SAX dtd events.
    */
-  public DTDHandler getDTDHandler()
-  {
+  public DTDHandler getDTDHandler() {
     return this;
   }
 
@@ -464,8 +458,7 @@
    *
    * @return null if this model doesn't respond to SAX error events.
    */
-  public ErrorHandler getErrorHandler()
-  {
+  public ErrorHandler getErrorHandler() {
     return this;
   }
 
@@ -474,8 +467,7 @@
    *
    * @return null if this model doesn't respond to SAX Decl events.
    */
-  public DeclHandler getDeclHandler()
-  {
+  public DeclHandler getDeclHandler() {
     return this;
   }
 
@@ -485,8 +477,7 @@
    * transformation and the parse run simultaneously. Guidance to the
    * DTMManager.
    */
-  public boolean needsTwoThreads()
-  {
+  public boolean needsTwoThreads() {
     return null != m_incrementalSAXSource;
   }
 
@@ -509,9 +500,8 @@
    */
   public void dispatchCharactersEvents(int nodeHandle, ContentHandler ch,
                                        boolean normalize)
-          throws SAXException
+    throws SAXException
   {
-
     int identity = makeNodeIdentity(nodeHandle);
 
     if (identity == DTM.NULL)
@@ -519,8 +509,7 @@
 
     int type = _type(identity);
 
-    if (isTextType(type))
-    {
+    if (isTextType(type)) {
       int dataIndex = m_dataOrQName.elementAt(identity);
       int offset = m_data.elementAt(dataIndex);
       int length = m_data.elementAt(dataIndex + 1);
@@ -529,13 +518,10 @@
         m_chars.sendNormalizedSAXcharacters(ch, offset, length);
       else
         m_chars.sendSAXcharacters(ch, offset, length);
-    }
-    else
-    {
+    } else {
       int firstChild = _firstch(identity);
 
-      if (DTM.NULL != firstChild)
-      {
+      if (DTM.NULL != firstChild) {
         int offset = -1;
         int length = 0;
         int startNode = identity;
@@ -545,12 +531,10 @@
         do {
           type = _type(identity);
 
-          if (isTextType(type))
-          {
+          if (isTextType(type)) {
             int dataIndex = _dataOrQName(identity);
 
-            if (-1 == offset)
-            {
+            if (-1 == offset) {
               offset = m_data.elementAt(dataIndex);
             }
 
@@ -560,36 +544,31 @@
           identity = getNextNodeIdentity(identity);
         } while (DTM.NULL != identity && (_parent(identity) >= startNode));
 
-        if (length > 0)
-        {
+        if (length > 0) {
           if(normalize)
             m_chars.sendNormalizedSAXcharacters(ch, offset, length);
           else
             m_chars.sendSAXcharacters(ch, offset, length);
         }
-      }
-      else if(type != DTM.ELEMENT_NODE)
-      {
+      } else if(type != DTM.ELEMENT_NODE) {
         int dataIndex = _dataOrQName(identity);
 
-        if (dataIndex < 0)
-        {
+        if (dataIndex < 0) {
           dataIndex = -dataIndex;
           dataIndex = m_data.elementAt(dataIndex + 1);
         }
 
         String str = m_valuesOrPrefixes.indexToString(dataIndex);
 
-          if(normalize)
-            FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(),
-                                                         0, str.length(), ch);
-          else
-            ch.characters(str.toCharArray(), 0, str.length());
+        if(normalize)
+          FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(),
+                                                       0, str.length(), ch);
+        else
+          ch.characters(str.toCharArray(), 0, str.length());
       }
     }
   }
 
-
   /**
    * Given a node handle, return its DOM-style node name. This will
    * include names such as #text or #document.
@@ -599,39 +578,29 @@
    * %REVIEW% Document when empty string is possible...
    * %REVIEW-COMMENT% It should never be empty, should it?
    */
-  public String getNodeName(int nodeHandle)
-  {
-
+  public String getNodeName(int nodeHandle) {
     int expandedTypeID = getExpandedTypeID(nodeHandle);
     // If just testing nonzero, no need to shift...
     int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID);
 
-    if (0 == namespaceID)
-    {
+    if (0 == namespaceID) {
       // Don't retrieve name until/unless needed
       // String name = m_expandedNameTable.getLocalName(expandedTypeID);
       int type = getNodeType(nodeHandle);
 
-      if (type == DTM.NAMESPACE_NODE)
-      {
+      if (type == DTM.NAMESPACE_NODE) {
         if (null == m_expandedNameTable.getLocalName(expandedTypeID))
           return "xmlns";
         else
           return "xmlns:" + m_expandedNameTable.getLocalName(expandedTypeID);
-      }
-      else if (0 == m_expandedNameTable.getLocalNameID(expandedTypeID))
-      {
+      } else if (0 == m_expandedNameTable.getLocalNameID(expandedTypeID)) {
         return m_fixednames[type];
-      }
-      else
+      } else
         return m_expandedNameTable.getLocalName(expandedTypeID);
-    }
-    else
-    {
+    } else {
       int qnameIndex = m_dataOrQName.elementAt(makeNodeIdentity(nodeHandle));
 
-      if (qnameIndex < 0)
-      {
+      if (qnameIndex < 0) {
         qnameIndex = -qnameIndex;
         qnameIndex = m_data.elementAt(qnameIndex);
       }
@@ -648,27 +617,21 @@
    * @param nodeHandle the id of the node.
    * @return String Name of this node, which may be an empty string.
    */
-  public String getNodeNameX(int nodeHandle)
-  {
-
+  public String getNodeNameX(int nodeHandle) {
     int expandedTypeID = getExpandedTypeID(nodeHandle);
     int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID);
 
-    if (0 == namespaceID)
-    {
+    if (namespaceID == 0) {
       String name = m_expandedNameTable.getLocalName(expandedTypeID);
 
       if (name == null)
         return "";
       else
         return name;
-    }
-    else
-    {
+    } else {
       int qnameIndex = m_dataOrQName.elementAt(makeNodeIdentity(nodeHandle));
 
-      if (qnameIndex < 0)
-      {
+      if (qnameIndex < 0) {
         qnameIndex = -qnameIndex;
         qnameIndex = m_data.elementAt(qnameIndex);
       }
@@ -686,11 +649,9 @@
    * @return <code>true</code> if the attribute was specified;
    *         <code>false</code> if it was defaulted.
    */
-  public boolean isAttributeSpecified(int attributeHandle)
-  {
-
+  public boolean isAttributeSpecified(int attributeHandle) {
     // I'm not sure if I want to do anything with this...
-    return true;  // ??
+    return true; // ??
   }
 
   /**
@@ -701,9 +662,7 @@
    *
    * @return the system identifier String object, or null if there is none.
    */
-  public String getDocumentTypeDeclarationSystemIdentifier()
-  {
-
+  public String getDocumentTypeDeclarationSystemIdentifier() {
     /** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMDefaultBase abstract method */
     error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"Not yet supported!");
 
@@ -717,14 +676,11 @@
    * @param identity The node identity (index).
    * @return identity+1, or DTM.NULL.
    */
-  protected int getNextNodeIdentity(int identity)
-  {
-
+  protected int getNextNodeIdentity(int identity) {
     identity += 1;
 
-    while (identity >= m_size)
-    {
-      if (null == m_incrementalSAXSource)
+    while (identity >= m_size) {
+      if (m_incrementalSAXSource == null)
         return DTM.NULL;
 
       nextNode();
@@ -739,10 +695,10 @@
    * @param nodeHandle The node ID.
    * @param ch A non-null reference to a ContentHandler.
    *
-   * @throws org.xml.sax.SAXException
+   * @throws SAXException
    */
-  public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
-          throws org.xml.sax.SAXException
+  public void dispatchToEvents(int nodeHandle, ContentHandler ch)
+          throws SAXException
   {
 
     DTMTreeWalker treeWalker = m_walker;
@@ -1087,28 +1043,22 @@
    * @return String containing the URI of the Unparsed Entity, or an
    * empty string if no such entity exists.
    */
-  public String getUnparsedEntityURI(String name)
-  {
-
+  public String getUnparsedEntityURI(String name) {
     String url = "";
 
-    if (null == m_entities)
+    if (null == m_entities) {
       return url;
+    }
 
     int n = m_entities.size();
 
-    for (int i = 0; i < n; i += ENTITY_FIELDS_PER)
-    {
-      String ename = (String) m_entities.elementAt(i + ENTITY_FIELD_NAME);
+    for (int i = 0; i < n; i += ENTITY_FIELDS_PER) {
+      String ename = m_entities.get(i + ENTITY_FIELD_NAME);
 
-      if (null != ename && ename.equals(name))
-      {
-        String nname = (String) m_entities.elementAt(i
-                         + ENTITY_FIELD_NOTATIONNAME);
+      if (null != ename && ename.equals(name)) {
+        String nname = m_entities.get(i + ENTITY_FIELD_NOTATIONNAME);
 
-        if (null != nname)
-        {
-
+        if (null != nname) {
           // The draft says: "The XSLT processor may use the public
           // identifier to generate a URI for the entity instead of the URI
           // specified in the system identifier. If the XSLT processor does
@@ -1118,11 +1068,10 @@
           // the resource containing the entity declaration as the base
           // URI [RFC2396]."
           // So I'm falling a bit short here.
-          url = (String) m_entities.elementAt(i + ENTITY_FIELD_SYSTEMID);
+          url = m_entities.get(i + ENTITY_FIELD_SYSTEMID);
 
-          if (null == url)
-          {
-            url = (String) m_entities.elementAt(i + ENTITY_FIELD_PUBLICID);
+          if (null == url) {
+            url = m_entities.get(i + ENTITY_FIELD_PUBLICID);
           }
         }
 
@@ -1400,26 +1349,18 @@
    *
    * @return The prefix if there is one, or null.
    */
-  public String getPrefix(String qname, String uri)
-  {
-
+  public String getPrefix(String qname, String uri) {
     String prefix;
     int uriIndex = -1;
 
-    if (null != uri && uri.length() > 0)
-    {
-
-      do
-      {
+    if (null != uri && uri.length() > 0) {
+      do {
         uriIndex = m_prefixMappings.indexOf(uri, ++uriIndex);
-      } while ( (uriIndex & 0x01) == 0);
+      } while ((uriIndex & 0x01) == 0);
 
-      if (uriIndex >= 0)
-      {
-        prefix = (String) m_prefixMappings.elementAt(uriIndex - 1);
-      }
-      else if (null != qname)
-      {
+      if (uriIndex >= 0) {
+        prefix = m_prefixMappings.elementAt(uriIndex - 1);
+      } else if (null != qname) {
         int indexOfNSSep = qname.indexOf(':');
 
         if (qname.equals("xmlns"))
@@ -1429,33 +1370,24 @@
         else
           prefix = (indexOfNSSep > 0)
                    ? qname.substring(0, indexOfNSSep) : null;
-      }
-      else
-      {
+      } else {
         prefix = null;
       }
-    }
-    else if (null != qname)
-    {
+    } else if (null != qname) {
       int indexOfNSSep = qname.indexOf(':');
 
-      if (indexOfNSSep > 0)
-      {
+      if (indexOfNSSep > 0) {
         if (qname.startsWith("xmlns:"))
           prefix = qname.substring(indexOfNSSep + 1);
         else
           prefix = qname.substring(0, indexOfNSSep);
-      }
-      else
-      {
+      } else {
         if (qname.equals("xmlns"))
           prefix = "";
         else
           prefix = null;
       }
-    }
-    else
-    {
+    } else {
       prefix = null;
     }
 
@@ -1470,38 +1402,31 @@
    *
    * @return The prefix if there is one, or null.
    */
-  public int getIdForNamespace(String uri)
-  {
-
+  public int getIdForNamespace(String uri) {
      return m_valuesOrPrefixes.stringToIndex(uri);
-
   }
 
-    /**
+  /**
    * Get a prefix either from the qname or from the uri mapping, or just make
    * one up!
    *
    * @return The prefix if there is one, or null.
    */
-  public String getNamespaceURI(String prefix)
-  {
-
+  public String getNamespaceURI(String prefix) {
     String uri = "";
     int prefixIndex = m_contextIndexes.peek() - 1 ;
 
-    if(null == prefix)
+    if (null == prefix) {
       prefix = "";
+    }
 
-      do
-      {
-        prefixIndex = m_prefixMappings.indexOf(prefix, ++prefixIndex);
-      } while ( (prefixIndex >= 0) && (prefixIndex & 0x01) == 0x01);
+    do {
+      prefixIndex = m_prefixMappings.indexOf(prefix, ++prefixIndex);
+    } while ((prefixIndex >= 0) && (prefixIndex & 0x01) == 0x01);
 
-      if (prefixIndex > -1)
-      {
-        uri = (String) m_prefixMappings.elementAt(prefixIndex + 1);
-      }
-
+    if (prefixIndex > -1) {
+      uri = m_prefixMappings.elementAt(prefixIndex + 1);
+    }
 
     return uri;
   }
@@ -1578,7 +1503,7 @@
    *         default behaviour.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.EntityResolver#resolveEntity
+   * @see EntityResolver#resolveEntity
    *
    * @throws SAXException
    */
@@ -1605,7 +1530,7 @@
    * @param systemId The notation system identifier.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.DTDHandler#notationDecl
+   * @see DTDHandler#notationDecl
    *
    * @throws SAXException
    */
@@ -1630,41 +1555,35 @@
    * @param notationName The name of the associated notation.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   * @see DTDHandler#unparsedEntityDecl
    *
    * @throws SAXException
    */
-  public void unparsedEntityDecl(
-          String name, String publicId, String systemId, String notationName)
-            throws SAXException
+  public void unparsedEntityDecl(String name, String publicId, String systemId,
+                                 String notationName) throws SAXException
   {
-
-    if (null == m_entities)
-    {
-      m_entities = new Vector();
+    if (null == m_entities) {
+      m_entities = new ArrayList<>();
     }
 
-    try
-    {
+    try {
       systemId = SystemIDResolver.getAbsoluteURI(systemId,
                                                  getDocumentBaseURI());
-    }
-    catch (Exception e)
-    {
-      throw new org.xml.sax.SAXException(e);
+    } catch (Exception e) {
+      throw new SAXException(e);
     }
 
     //  private static final int ENTITY_FIELD_PUBLICID = 0;
-    m_entities.addElement(publicId);
+    m_entities.add(publicId);
 
     //  private static final int ENTITY_FIELD_SYSTEMID = 1;
-    m_entities.addElement(systemId);
+    m_entities.add(systemId);
 
     //  private static final int ENTITY_FIELD_NOTATIONNAME = 2;
-    m_entities.addElement(notationName);
+    m_entities.add(notationName);
 
     //  private static final int ENTITY_FIELD_NAME = 3;
-    m_entities.addElement(name);
+    m_entities.add(name);
   }
 
   ////////////////////////////////////////////////////////////////////
@@ -1679,8 +1598,8 @@
    * with other document events.</p>
    *
    * @param locator A locator for all SAX document events.
-   * @see org.xml.sax.ContentHandler#setDocumentLocator
-   * @see org.xml.sax.Locator
+   * @see ContentHandler#setDocumentLocator
+   * @see Locator
    */
   public void setDocumentLocator(Locator locator)
   {
@@ -1693,7 +1612,7 @@
    *
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#startDocument
+   * @see ContentHandler#startDocument
    */
   public void startDocument() throws SAXException
   {
@@ -1716,7 +1635,7 @@
    *
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#endDocument
+   * @see ContentHandler#endDocument
    */
   public void endDocument() throws SAXException
   {
@@ -1754,7 +1673,7 @@
    * @param uri The Namespace URI mapped to the prefix.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#startPrefixMapping
+   * @see ContentHandler#startPrefixMapping
    */
   public void startPrefixMapping(String prefix, String uri)
           throws SAXException
@@ -1780,7 +1699,7 @@
    * @param prefix The Namespace prefix being declared.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#endPrefixMapping
+   * @see ContentHandler#endPrefixMapping
    */
   public void endPrefixMapping(String prefix) throws SAXException
   {
@@ -1815,16 +1734,13 @@
    * @return true if the declaration has already been declared in the
    *         current context.
    */
-  protected boolean declAlreadyDeclared(String prefix)
-  {
-
+  protected boolean declAlreadyDeclared(String prefix) {
     int startDecls = m_contextIndexes.peek();
-    java.util.Vector prefixMappings = m_prefixMappings;
+    Vector<String> prefixMappings = m_prefixMappings;
     int nDecls = prefixMappings.size();
 
-    for (int i = startDecls; i < nDecls; i += 2)
-    {
-      String prefixDecl = (String) prefixMappings.elementAt(i);
+    for (int i = startDecls; i < nDecls; i += 2) {
+      String prefixDecl = prefixMappings.elementAt(i);
 
       if (prefixDecl == null)
         continue;
@@ -1836,7 +1752,7 @@
     return false;
   }
 
-        boolean m_pastFirstElement=false;
+  boolean m_pastFirstElement=false;
 
   /**
    * Receive notification of the start of an element.
@@ -1857,35 +1773,38 @@
    * @param attributes The specified or defaulted attributes.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#startElement
+   * @see ContentHandler#startElement
    */
-  public void startElement(
-          String uri, String localName, String qName, Attributes attributes)
-            throws SAXException
+  public void startElement(String uri, String localName, String qName,
+                           Attributes attributes) throws SAXException
   {
-   if (DEBUG)
-         {
-      System.out.println("startElement: uri: " + uri + ", localname: "
-                                                                                                 + localName + ", qname: "+qName+", atts: " + attributes);
+    if (DEBUG) {
+      System.out.println("startElement: uri: " + uri +
+                         ", localname: " + localName +
+                         ", qname: "+qName+", atts: " + attributes);
 
-                        boolean DEBUG_ATTRS=true;
-                        if(DEBUG_ATTRS & attributes!=null)
-                        {
-                                int n = attributes.getLength();
-                                if(n==0)
-                                        System.out.println("\tempty attribute list");
-                                else for (int i = 0; i < n; i++)
-                                        System.out.println("\t attr: uri: " + attributes.getURI(i) +
-                                                                                                                 ", localname: " + attributes.getLocalName(i) +
-                                                                                                                 ", qname: " + attributes.getQName(i) +
-                                                                                                                 ", type: " + attributes.getType(i) +
-                                                                                                                 ", value: " + attributes.getValue(i)
-                                                                                                                 );
-                        }
-         }
+      boolean DEBUG_ATTRS=true;
+      if (DEBUG_ATTRS & attributes!=null) {
+        int n = attributes.getLength();
+        if (n==0) {
+          System.out.println("\tempty attribute list");
+        } else for (int i = 0; i < n; i++) {
+          System.out.println("\t attr: uri: " + attributes.getURI(i) +
+                             ", localname: " + attributes.getLocalName(i) +
+                             ", qname: " + attributes.getQName(i) +
+                             ", type: " + attributes.getType(i) +
+                             ", value: " + attributes.getValue(i));
+        }
+      }
+    }
 
     charactersFlush();
 
+    if ((localName == null || localName.isEmpty()) &&
+        (uri == null || uri.isEmpty())) {
+      localName = qName;
+    }
+
     int exName = m_expandedNameTable.getExpandedTypeID(uri, localName, DTM.ELEMENT_NODE);
     String prefix = getPrefix(qName, uri);
     int prefixIndex = (null != prefix)
@@ -1894,20 +1813,18 @@
     int elemNode = addNode(DTM.ELEMENT_NODE, exName,
                            m_parents.peek(), m_previous, prefixIndex, true);
 
-    if(m_indexing)
+    if (m_indexing)
       indexNode(exName, elemNode);
 
-
     m_parents.push(elemNode);
 
     int startDecls = m_contextIndexes.peek();
     int nDecls = m_prefixMappings.size();
     int prev = DTM.NULL;
 
-    if(!m_pastFirstElement)
-    {
+    if (!m_pastFirstElement) {
       // SPECIAL CASE: Implied declaration at root element
-      prefix="xml";
+      prefix = "xml";
       String declURL = "http://www.w3.org/XML/1998/namespace";
       exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE);
       int val = m_valuesOrPrefixes.stringToIndex(declURL);
@@ -1916,14 +1833,13 @@
       m_pastFirstElement=true;
     }
 
-    for (int i = startDecls; i < nDecls; i += 2)
-    {
-      prefix = (String) m_prefixMappings.elementAt(i);
+    for (int i = startDecls; i < nDecls; i += 2) {
+      prefix = m_prefixMappings.elementAt(i);
 
       if (prefix == null)
         continue;
 
-      String declURL = (String) m_prefixMappings.elementAt(i + 1);
+      String declURL = m_prefixMappings.elementAt(i + 1);
 
       exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE);
 
@@ -1935,8 +1851,7 @@
 
     int n = attributes.getLength();
 
-    for (int i = 0; i < n; i++)
-    {
+    for (int i = 0; i < n; i++) {
       String attrUri = attributes.getURI(i);
       String attrQName = attributes.getQName(i);
       String valString = attributes.getValue(i);
@@ -1947,17 +1862,13 @@
 
        String attrLocalName = attributes.getLocalName(i);
 
-      if ((null != attrQName)
-              && (attrQName.equals("xmlns")
-                  || attrQName.startsWith("xmlns:")))
-      {
+      if ((null != attrQName) &&
+          (attrQName.equals("xmlns") || attrQName.startsWith("xmlns:"))) {
         if (declAlreadyDeclared(prefix))
           continue;  // go to the next attribute.
 
         nodeType = DTM.NAMESPACE_NODE;
-      }
-      else
-      {
+      } else {
         nodeType = DTM.ATTRIBUTE_NODE;
 
         if (attributes.getType(i).equalsIgnoreCase("ID"))
@@ -1966,15 +1877,13 @@
 
       // Bit of a hack... if somehow valString is null, stringToIndex will
       // return -1, which will make things very unhappy.
-      if(null == valString)
+      if (null == valString)
         valString = "";
 
       int val = m_valuesOrPrefixes.stringToIndex(valString);
       //String attrLocalName = attributes.getLocalName(i);
 
-      if (null != prefix)
-      {
-
+      if (null != prefix) {
         prefixIndex = m_valuesOrPrefixes.stringToIndex(attrQName);
 
         int dataIndex = m_data.size();
@@ -1993,8 +1902,7 @@
     if (DTM.NULL != prev)
       m_nextsib.setElementAt(DTM.NULL,prev);
 
-    if (null != m_wsfilter)
-    {
+    if (null != m_wsfilter) {
       short wsv = m_wsfilter.getShouldStripSpace(makeNodeHandle(elemNode), this);
       boolean shouldStrip = (DTMWSFilter.INHERIT == wsv)
                             ? getShouldStripWhitespace()
@@ -2026,7 +1934,7 @@
    *        empty string if qualified names are not available.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#endElement
+   * @see ContentHandler#endElement
    */
   public void endElement(String uri, String localName, String qName)
           throws SAXException
@@ -2074,7 +1982,7 @@
    *               character array.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#characters
+   * @see ContentHandler#characters
    */
   public void characters(char ch[], int start, int length) throws SAXException
   {
@@ -2109,7 +2017,7 @@
    *               character array.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#ignorableWhitespace
+   * @see ContentHandler#ignorableWhitespace
    */
   public void ignorableWhitespace(char ch[], int start, int length)
           throws SAXException
@@ -2133,7 +2041,7 @@
    *             none is supplied.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#processingInstruction
+   * @see ContentHandler#processingInstruction
    */
   public void processingInstruction(String target, String data)
           throws SAXException
@@ -2163,7 +2071,7 @@
    * @param name The name of the skipped entity.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#processingInstruction
+   * @see ContentHandler#processingInstruction
    */
   public void skippedEntity(String name) throws SAXException
   {
@@ -2187,8 +2095,8 @@
    * @param e The warning information encoded as an exception.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ErrorHandler#warning
-   * @see org.xml.sax.SAXParseException
+   * @see ErrorHandler#warning
+   * @see SAXParseException
    */
   public void warning(SAXParseException e) throws SAXException
   {
@@ -2208,8 +2116,8 @@
    * @param e The warning information encoded as an exception.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ErrorHandler#warning
-   * @see org.xml.sax.SAXParseException
+   * @see ErrorHandler#warning
+   * @see SAXParseException
    */
   public void error(SAXParseException e) throws SAXException
   {
@@ -2230,8 +2138,8 @@
    * @param e The error information encoded as an exception.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ErrorHandler#fatalError
-   * @see org.xml.sax.SAXParseException
+   * @see ErrorHandler#fatalError
+   * @see SAXParseException
    */
   public void fatalError(SAXParseException e) throws SAXException
   {
@@ -2299,7 +2207,7 @@
    * @param value The replacement text of the entity.
    * @throws SAXException The application may raise an exception.
    * @see #externalEntityDecl
-   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   * @see DTDHandler#unparsedEntityDecl
    */
   public void internalEntityDecl(String name, String value)
           throws SAXException
@@ -2321,7 +2229,7 @@
    * @param systemId The declared system identifier of the entity.
    * @throws SAXException The application may raise an exception.
    * @see #internalEntityDecl
-   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
+   * @see DTDHandler#unparsedEntityDecl
    */
   public void externalEntityDecl(
           String name, String publicId, String systemId) throws SAXException
@@ -2386,15 +2294,15 @@
    * properly nested within start/end entity events.</p>
    *
    * <p>Note that skipped entities will be reported through the
-   * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
+   * {@link ContentHandler#skippedEntity skippedEntity}
    * event, which is part of the ContentHandler interface.</p>
    *
    * @param name The name of the entity.  If it is a parameter
    *        entity, the name will begin with '%'.
    * @throws SAXException The application may raise an exception.
    * @see #endEntity
-   * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
-   * @see org.xml.sax.ext.DeclHandler#externalEntityDecl
+   * @see DeclHandler#internalEntityDecl
+   * @see DeclHandler#externalEntityDecl
    */
   public void startEntity(String name) throws SAXException
   {
@@ -2419,7 +2327,7 @@
    * Report the start of a CDATA section.
    *
    * <p>The contents of the CDATA section will be reported through
-   * the regular {@link org.xml.sax.ContentHandler#characters
+   * the regular {@link ContentHandler#characters
    * characters} event.</p>
    *
    * @throws SAXException The application may raise an exception.
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,13 +1,13 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -17,13 +17,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: SAX2DTM2.java,v 1.2.4.1 2005/09/15 08:15:12 suresh_emailid Exp $
- */
+
 package com.sun.org.apache.xml.internal.dtm.ref.sax2dtm;
 
-import com.sun.org.apache.xml.internal.dtm.*;
-import com.sun.org.apache.xml.internal.dtm.ref.*;
+import com.sun.org.apache.xml.internal.dtm.DTM;
+import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
+import com.sun.org.apache.xml.internal.dtm.DTMException;
+import com.sun.org.apache.xml.internal.dtm.DTMManager;
+import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
+import com.sun.org.apache.xml.internal.dtm.ref.ExpandedNameTable;
+import com.sun.org.apache.xml.internal.dtm.ref.ExtendedType;
 import com.sun.org.apache.xml.internal.utils.FastStringBuffer;
 import com.sun.org.apache.xml.internal.utils.XMLString;
 import com.sun.org.apache.xml.internal.utils.XMLStringDefault;
@@ -31,11 +35,12 @@
 import com.sun.org.apache.xml.internal.res.XMLMessages;
 import com.sun.org.apache.xml.internal.res.XMLErrorResources;
 import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
-
+import com.sun.org.apache.xml.internal.utils.SuballocatedIntVector;
+import java.util.ArrayList;
 import javax.xml.transform.Source;
-import java.util.Vector;
-import com.sun.org.apache.xml.internal.utils.SuballocatedIntVector;
-import org.xml.sax.*;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
 
 /**
  * SAX2DTM2 is an optimized version of SAX2DTM which is used in non-incremental situation.
@@ -53,10 +58,6 @@
  * The design of SAX2DTM2 may limit its extensibilty. If you have a reason to extend the
  * SAX2DTM model, please extend from SAX2DTM instead of this class.
  * <p>
- * TODO: This class is currently only used by XSLTC. We need to investigate the possibility
- * of also using it in Xalan-J Interpretive. Xalan's performance is likely to get an instant
- * boost if we use SAX2DTM2 instead of SAX2DTM in non-incremental case.
- * <p>
  * %MK% The code in this class is critical to the XSLTC_DTM performance. Be very careful
  * when making changes here!
  */
@@ -87,11 +88,10 @@
      */
     public DTMAxisIterator setStartNode(int node)
     {
-//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
+      //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
       if (node == DTMDefaultBase.ROOTNODE)
         node = getDocument();
-      if (_isRestartable)
-      {
+      if (_isRestartable) {
         _startNode = node;
         _currentNode = (node == DTM.NULL) ? DTM.NULL
                                           : _firstch2(makeNodeIdentity(node));
@@ -108,8 +108,7 @@
      * @return The next node handle in the iteration, or END if no more
      * are available.
      */
-    public int next()
-    {
+    public int next() {
       if (_currentNode != NULL) {
         int node = _currentNode;
         _currentNode = _nextsib2(node);
@@ -139,13 +138,11 @@
      *
      * @return A DTMAxisIterator set to the start of the iteration.
      */
-    public DTMAxisIterator setStartNode(int node)
-    {
-//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
+    public DTMAxisIterator setStartNode(int node) {
+      //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
       if (node == DTMDefaultBase.ROOTNODE)
         node = getDocument();
-      if (_isRestartable)
-      {
+      if (_isRestartable) {
         _startNode = node;
 
         if (node != DTM.NULL)
@@ -229,8 +226,7 @@
      *
      * @param nodeType The extended type ID being requested.
      */
-    public TypedChildrenIterator(int nodeType)
-    {
+    public TypedChildrenIterator(int nodeType) {
       _nodeType = nodeType;
     }
 
@@ -242,17 +238,14 @@
      *
      * @return A DTMAxisIterator set to the start of the iteration.
      */
-    public DTMAxisIterator setStartNode(int node)
-    {
-//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
+    public DTMAxisIterator setStartNode(int node) {
+      //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
       if (node == DTMDefaultBase.ROOTNODE)
         node = getDocument();
-      if (_isRestartable)
-      {
+      if (_isRestartable) {
         _startNode = node;
-        _currentNode = (node == DTM.NULL)
-                                   ? DTM.NULL
-                                   : _firstch2(makeNodeIdentity(_startNode));
+        _currentNode = (node == DTM.NULL) ? DTM.NULL :
+                         _firstch2(makeNodeIdentity(_startNode));
 
         return resetPosition();
       }
@@ -265,8 +258,7 @@
      *
      * @return The next node handle in the iteration, or END.
      */
-    public int next()
-    {
+    public int next() {
       int node = _currentNode;
       if (node == DTM.NULL)
         return DTM.NULL;
@@ -301,14 +293,12 @@
         _currentNode = _nextsib2(node);
         return returnNode(makeNodeHandle(node));
       }
-
     }
 
     /**
      * Return the node at the given position.
      */
-    public int getNodeByPosition(int position)
-    {
+    public int getNodeByPosition(int position) {
       if (position <= 0)
         return DTM.NULL;
 
@@ -327,8 +317,7 @@
           node = _nextsib2(node);
         }
         return NULL;
-      }
-      else {
+      } else {
         while (node != DTM.NULL) {
           if (_exptype2(node) >= DTM.NTYPES) {
             pos++;
@@ -415,13 +404,11 @@
      *
      * @return A DTMAxisIterator set to the start of the iteration.
      */
-    public DTMAxisIterator setStartNode(int node)
-    {
-//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
+    public DTMAxisIterator setStartNode(int node) {
+      //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
       if (node == DTMDefaultBase.ROOTNODE)
         node = getDocument();
-      if (_isRestartable)
-      {
+      if (_isRestartable) {
         _startNode = node;
         _currentNode = makeNodeIdentity(node);
 
@@ -436,8 +423,7 @@
      *
      * @return The next node handle in the iteration, or END.
      */
-    public int next()
-    {
+    public int next() {
       _currentNode = (_currentNode == DTM.NULL) ? DTM.NULL
                                                 : _nextsib2(_currentNode);
       return returnNode(makeNodeHandle(_currentNode));
@@ -460,8 +446,7 @@
      *
      * @param type The extended type ID being requested.
      */
-    public TypedFollowingSiblingIterator(int type)
-    {
+    public TypedFollowingSiblingIterator(int type) {
       _nodeType = type;
     }
 
@@ -470,8 +455,7 @@
      *
      * @return The next node handle in the iteration, or END.
      */
-    public int next()
-    {
+    public int next() {
       if (_currentNode == DTM.NULL) {
         return DTM.NULL;
       }
@@ -481,8 +465,7 @@
 
       if (nodeType != DTM.ELEMENT_NODE) {
         while ((node = _nextsib2(node)) != DTM.NULL && _exptype2(node) != nodeType) {}
-      }
-      else {
+      } else {
         while ((node = _nextsib2(node)) != DTM.NULL && _exptype2(node) < DTM.NTYPES) {}
       }
 
@@ -498,8 +481,7 @@
   /**
    * Iterator that returns attribute nodes (of what nodes?)
    */
-  public final class AttributeIterator extends InternalAxisIteratorBase
-  {
+  public final class AttributeIterator extends InternalAxisIteratorBase {
 
     // assumes caller will pass element nodes
 
@@ -511,13 +493,11 @@
      *
      * @return A DTMAxisIterator set to the start of the iteration.
      */
-    public DTMAxisIterator setStartNode(int node)
-    {
-//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
+    public DTMAxisIterator setStartNode(int node) {
+      //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
       if (node == DTMDefaultBase.ROOTNODE)
         node = getDocument();
-      if (_isRestartable)
-      {
+      if (_isRestartable) {
         _startNode = node;
         _currentNode = getFirstAttributeIdentity(makeNodeIdentity(node));
 
@@ -532,9 +512,7 @@
      *
      * @return The next node handle in the iteration, or END.
      */
-    public int next()
-    {
-
+    public int next() {
       final int node = _currentNode;
 
       if (node != NULL) {
@@ -561,8 +539,7 @@
      *
      * @param nodeType The extended type ID that is requested.
      */
-    public TypedAttributeIterator(int nodeType)
-    {
+    public TypedAttributeIterator(int nodeType) {
       _nodeType = nodeType;
     }
 
@@ -576,14 +553,10 @@
      *
      * @return A DTMAxisIterator set to the start of the iteration.
      */
-    public DTMAxisIterator setStartNode(int node)
-    {
-      if (_isRestartable)
-      {
+    public DTMAxisIterator setStartNode(int node) {
+      if (_isRestartable) {
         _startNode = node;
-
         _currentNode = getTypedAttribute(node, _nodeType);
-
         return resetPosition();
       }
 
@@ -595,9 +568,7 @@
      *
      * @return The next node handle in the iteration, or END.
      */
-    public int next()
-    {
-
+    public int next() {
       final int node = _currentNode;
 
       // singleton iterator, since there can only be one attribute of
@@ -624,8 +595,7 @@
      *
      * @return true.
      */
-    public boolean isReverse()
-    {
+    public boolean isReverse() {
       return true;
     }
 
@@ -637,30 +607,25 @@
      *
      * @return A DTMAxisIterator set to the start of the iteration.
      */
-    public DTMAxisIterator setStartNode(int node)
-    {
-//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
+    public DTMAxisIterator setStartNode(int node) {
+      //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
       if (node == DTMDefaultBase.ROOTNODE)
         node = getDocument();
-      if (_isRestartable)
-      {
+      if (_isRestartable) {
         _startNode = node;
         node = _startNodeID = makeNodeIdentity(node);
 
-        if(node == NULL)
-        {
+        if(node == NULL) {
           _currentNode = node;
           return resetPosition();
         }
 
         int type = _type2(node);
-        if(ExpandedNameTable.ATTRIBUTE == type
-           || ExpandedNameTable.NAMESPACE == type )
+        if (ExpandedNameTable.ATTRIBUTE == type ||
+            ExpandedNameTable.NAMESPACE == type)
         {
           _currentNode = node;
-        }
-        else
-        {
+        } else {
           // Be careful to handle the Document node properly
           _currentNode = _parent2(node);
           if(NULL!=_currentNode)
@@ -680,18 +645,12 @@
      *
      * @return The next node handle in the iteration, or END.
      */
-    public int next()
-    {
-
-      if (_currentNode == _startNodeID || _currentNode == DTM.NULL)
-      {
+    public int next() {
+      if (_currentNode == _startNodeID || _currentNode == DTM.NULL) {
         return NULL;
-      }
-      else
-      {
+      } else {
         final int node = _currentNode;
         _currentNode = _nextsib2(node);
-
         return returnNode(makeNodeHandle(node));
       }
     }
@@ -714,8 +673,7 @@
      *
      * @param type The extended type ID being requested.
      */
-    public TypedPrecedingSiblingIterator(int type)
-    {
+    public TypedPrecedingSiblingIterator(int type) {
       _nodeType = type;
     }
 
@@ -724,8 +682,7 @@
      *
      * @return The next node handle in the iteration, or END.
      */
-    public int next()
-    {
+    public int next() {
       int node = _currentNode;
 
       final int nodeType = _nodeType;
@@ -735,8 +692,7 @@
         while (node != NULL && node != startNodeID && _exptype2(node) != nodeType) {
           node = _nextsib2(node);
         }
-      }
-      else {
+      } else {
         while (node != NULL && node != startNodeID && _exptype2(node) < DTM.NTYPES) {
           node = _nextsib2(node);
         }
@@ -745,8 +701,7 @@
       if (node == DTM.NULL || node == startNodeID) {
         _currentNode = NULL;
         return NULL;
-      }
-      else {
+      } else {
         _currentNode = _nextsib2(node);
         return returnNode(makeNodeHandle(node));
       }
@@ -755,8 +710,7 @@
     /**
      * Return the index of the last node in this iterator.
      */
-    public int getLast()
-    {
+    public int getLast() {
       if (_last != -1)
         return _last;
 
@@ -774,8 +728,7 @@
           }
           node = _nextsib2(node);
         }
-      }
-      else {
+      } else {
         while (node != NULL && node != startNodeID) {
           if (_exptype2(node) >= DTM.NTYPES) {
             last++;
@@ -860,7 +813,7 @@
      */
     public DTMAxisIterator setStartNode(int node)
     {
-//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
+      //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
       if (node == DTMDefaultBase.ROOTNODE)
         node = getDocument();
       if (_isRestartable)
@@ -1799,9 +1752,7 @@
   // %OPT% These values are unlikely to be equal. Storing
   // them in a plain Vector is more efficient than storing in the
   // DTMStringPool because we can save the cost for hash calculation.
-  //
-  // %REVISIT% Do we need a custom class (e.g. StringVector) here?
-  protected Vector m_values;
+  protected ArrayList<String> m_values;
 
   // The current index into the m_values Vector.
   private int m_valueIndex = 0;
@@ -1881,9 +1832,8 @@
     m_buildIdIndex = buildIdIndex;
 
     // Some documents do not have attribute nodes. That is why
-    // we set the initial size of this Vector to be small and set
-    // the increment to a bigger number.
-    m_values = new Vector(32, 512);
+    // we set the initial size of this ArrayList to be small.
+    m_values = new ArrayList<>(32);
 
     m_maxNodeIndex = 1 << DTMManager.IDENT_DTM_NODE_BITS;
 
@@ -1953,10 +1903,7 @@
    * @param identity A node identity, which <em>must not</em> be equal to
    *        <code>DTM.NULL</code>
    */
-  public final int _firstch2(int identity)
-  {
-    //return m_firstch.elementAt(identity);
-
+  public final int _firstch2(int identity) {
     if (identity < m_blocksize)
       return m_firstch_map0[identity];
     else
@@ -1969,10 +1916,7 @@
    * @param identity A node identity, which <em>must not</em> be equal to
    *        <code>DTM.NULL</code>
    */
-  public final int _parent2(int identity)
-  {
-    //return m_parent.elementAt(identity);
-
+  public final int _parent2(int identity) {
     if (identity < m_blocksize)
       return m_parent_map0[identity];
     else
@@ -1985,9 +1929,7 @@
    * @param identity A node identity, which <em>must not</em> be equal to
    *        <code>DTM.NULL</code>
    */
-  public final int _type2(int identity)
-  {
-    //int eType = _exptype2(identity);
+  public final int _type2(int identity) {
     int eType;
     if (identity < m_blocksize)
       eType = m_exptype_map0[identity];
@@ -2006,12 +1948,9 @@
    * <p>This one is only used by DOMAdapter.getExpandedTypeID(int), which
    * is mostly called from the compiled translets.
    */
-  public final int getExpandedTypeID2(int nodeHandle)
-  {
+  public final int getExpandedTypeID2(int nodeHandle) {
     int nodeID = makeNodeIdentity(nodeHandle);
 
-    //return (nodeID != NULL) ? _exptype2(nodeID) : NULL;
-
     if (nodeID != NULL) {
       if (nodeID < m_blocksize)
         return m_exptype_map0[nodeID];
@@ -2026,12 +1965,10 @@
    *                 END of DTM base accessor interfaces
    *************************************************************************/
 
-
   /**
    * Return the node type from the expanded type
    */
-  public final int _exptype2Type(int exptype)
-  {
+  public final int _exptype2Type(int exptype) {
     if (NULL != exptype)
       return m_extendedTypes[exptype].getNodeType();
     else
@@ -2046,16 +1983,14 @@
    *
    * @return The prefix if there is one, or null.
    */
-  public int getIdForNamespace(String uri)
-  {
+  public int getIdForNamespace(String uri) {
      int index = m_values.indexOf(uri);
-     if (index < 0)
-     {
-       m_values.addElement(uri);
+     if (index < 0) {
+       m_values.add(uri);
        return m_valueIndex++;
+     } else {
+       return index;
      }
-     else
-       return index;
   }
 
   /**
@@ -2079,15 +2014,25 @@
    * @param attributes The specified or defaulted attributes.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#startElement
+   * @see ContentHandler#startElement
    */
-  public void startElement(String uri, String localName, String qName, Attributes attributes)
-      throws SAXException
+  public void startElement(String uri, String localName, String qName,
+                           Attributes attributes) throws SAXException
   {
-
     charactersFlush();
 
-    int exName = m_expandedNameTable.getExpandedTypeID(uri, localName, DTM.ELEMENT_NODE);
+    // in case URI and localName are empty, the input is not using the
+    // namespaces feature. Then we should take the part after the last
+    // colon of qName as localName (strip all namespace prefixes)
+    if ((uri == null || uri.isEmpty()) &&
+        (localName == null || localName.isEmpty()))
+    {
+      final int colon = qName.lastIndexOf(':');
+      localName = (colon > -1) ? qName.substring(colon + 1) : qName;
+    }
+
+    int exName = m_expandedNameTable.getExpandedTypeID(uri, localName,
+                                                       DTM.ELEMENT_NODE);
 
     int prefixIndex = (qName.length() != localName.length())
                       ? m_valuesOrPrefixes.stringToIndex(qName) : 0;
@@ -2095,7 +2040,7 @@
     int elemNode = addNode(DTM.ELEMENT_NODE, exName,
                            m_parents.peek(), m_previous, prefixIndex, true);
 
-    if(m_indexing)
+    if (m_indexing)
       indexNode(exName, elemNode);
 
     m_parents.push(elemNode);
@@ -2104,31 +2049,31 @@
     int nDecls = m_prefixMappings.size();
     String prefix;
 
-    if(!m_pastFirstElement)
-    {
+    if (!m_pastFirstElement) {
       // SPECIAL CASE: Implied declaration at root element
-      prefix="xml";
+      prefix = "xml";
       String declURL = "http://www.w3.org/XML/1998/namespace";
-      exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE);
-      m_values.addElement(declURL);
+      exName = m_expandedNameTable.getExpandedTypeID(null, prefix,
+                                                     DTM.NAMESPACE_NODE);
+      m_values.add(declURL);
       int val = m_valueIndex++;
       addNode(DTM.NAMESPACE_NODE, exName, elemNode,
                      DTM.NULL, val, false);
       m_pastFirstElement=true;
     }
 
-    for (int i = startDecls; i < nDecls; i += 2)
-    {
-      prefix = (String) m_prefixMappings.elementAt(i);
+    for (int i = startDecls; i < nDecls; i += 2) {
+      prefix = m_prefixMappings.elementAt(i);
 
       if (prefix == null)
         continue;
 
-      String declURL = (String) m_prefixMappings.elementAt(i + 1);
-
-      exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE);
-
-      m_values.addElement(declURL);
+      String declURL = m_prefixMappings.elementAt(i + 1);
+
+      exName = m_expandedNameTable.getExpandedTypeID(null, prefix,
+                                                     DTM.NAMESPACE_NODE);
+
+      m_values.add(declURL);
       int val = m_valueIndex++;
 
       addNode(DTM.NAMESPACE_NODE, exName, elemNode, DTM.NULL, val, false);
@@ -2136,28 +2081,37 @@
 
     int n = attributes.getLength();
 
-    for (int i = 0; i < n; i++)
-    {
+    for (int i = 0; i < n; i++) {
       String attrUri = attributes.getURI(i);
+      String attrLocalName = attributes.getLocalName(i);
       String attrQName = attributes.getQName(i);
       String valString = attributes.getValue(i);
 
+      // in case URI and localName are empty, the input is not using the
+      // namespaces feature. Then we should take the part after the last
+      // colon of qName as localName (strip all namespace prefixes)
+      // When the URI is empty but localName has colons then we can also
+      // assume non namespace aware and prefixes can be stripped
+      if (attrUri == null || attrUri.isEmpty()) {
+        if (attrLocalName == null || attrLocalName.isEmpty()) {
+          final int colon = attrQName.lastIndexOf(':');
+          attrLocalName = (colon > -1) ? attrQName.substring(colon + 1) : attrQName;
+        } else {
+          final int colon = attrLocalName.lastIndexOf(':');
+          attrLocalName = (colon > -1) ? attrLocalName.substring(colon + 1) : attrLocalName;
+        }
+      }
+
       int nodeType;
-
-      String attrLocalName = attributes.getLocalName(i);
-
-      if ((null != attrQName)
-              && (attrQName.equals("xmlns")
-                  || attrQName.startsWith("xmlns:")))
+      if ((null != attrQName) &&
+          (attrQName.equals("xmlns") || attrQName.startsWith("xmlns:")))
       {
         prefix = getPrefix(attrQName, attrUri);
         if (declAlreadyDeclared(prefix))
           continue;  // go to the next attribute.
 
         nodeType = DTM.NAMESPACE_NODE;
-      }
-      else
-      {
+      } else {
         nodeType = DTM.ATTRIBUTE_NODE;
 
         if (m_buildIdIndex && attributes.getType(i).equalsIgnoreCase("ID"))
@@ -2166,36 +2120,31 @@
 
       // Bit of a hack... if somehow valString is null, stringToIndex will
       // return -1, which will make things very unhappy.
-      if(null == valString)
+      if (null == valString)
         valString = "";
 
-      m_values.addElement(valString);
+      m_values.add(valString);
       int val = m_valueIndex++;
 
-      if (attrLocalName.length() != attrQName.length())
-      {
-
+      if (attrLocalName.length() != attrQName.length()) {
         prefixIndex = m_valuesOrPrefixes.stringToIndex(attrQName);
-
         int dataIndex = m_data.size();
-
         m_data.addElement(prefixIndex);
         m_data.addElement(val);
-
         val = -dataIndex;
       }
 
-      exName = m_expandedNameTable.getExpandedTypeID(attrUri, attrLocalName, nodeType);
-      addNode(nodeType, exName, elemNode, DTM.NULL, val,
-                     false);
+      exName = m_expandedNameTable.getExpandedTypeID(attrUri, attrLocalName,
+                                                     nodeType);
+      addNode(nodeType, exName, elemNode, DTM.NULL, val, false);
     }
 
-    if (null != m_wsfilter)
-    {
-      short wsv = m_wsfilter.getShouldStripSpace(makeNodeHandle(elemNode), this);
-      boolean shouldStrip = (DTMWSFilter.INHERIT == wsv)
-                            ? getShouldStripWhitespace()
-                            : (DTMWSFilter.STRIP == wsv);
+    if (null != m_wsfilter) {
+      short wsv = m_wsfilter.getShouldStripSpace(makeNodeHandle(elemNode),
+                                                 this);
+      boolean shouldStrip = (DTMWSFilter.INHERIT == wsv) ?
+                            getShouldStripWhitespace() :
+                            (DTMWSFilter.STRIP == wsv);
 
       pushShouldStripWhitespace(shouldStrip);
     }
@@ -2223,7 +2172,7 @@
    *        empty string if qualified names are not available.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#endElement
+   * @see ContentHandler#endElement
    */
   public void endElement(String uri, String localName, String qName)
           throws SAXException
@@ -2257,9 +2206,7 @@
    * @param length The number of characters to use from the array.
    * @throws SAXException The application may raise an exception.
    */
-  public void comment(char ch[], int start, int length) throws SAXException
-  {
-
+  public void comment(char ch[], int start, int length) throws SAXException {
     if (m_insideDTD)      // ignore comments if we're inside the DTD
       return;
 
@@ -2267,7 +2214,7 @@
 
     // %OPT% Saving the comment string in a Vector has a lower cost than
     // saving it in DTMStringPool.
-    m_values.addElement(new String(ch, start, length));
+    m_values.add(new String(ch, start, length));
     int dataIndex = m_valueIndex++;
 
     m_previous = addNode(DTM.COMMENT_NODE, DTM.COMMENT_NODE,
@@ -2279,13 +2226,10 @@
    *
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#startDocument
+   * @see ContentHandler#startDocument
    */
-  public void startDocument() throws SAXException
-  {
-
-    int doc = addNode(DTM.DOCUMENT_NODE,
-                      DTM.DOCUMENT_NODE,
+  public void startDocument() throws SAXException {
+    int doc = addNode(DTM.DOCUMENT_NODE, DTM.DOCUMENT_NODE,
                       DTM.NULL, DTM.NULL, 0, true);
 
     m_parents.push(doc);
@@ -2299,10 +2243,9 @@
    *
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#endDocument
+   * @see ContentHandler#endDocument
    */
-  public void endDocument() throws SAXException
-  {
+  public void endDocument() throws SAXException {
     super.endDocument();
 
     // Add a NULL entry to the end of the node arrays as
@@ -2334,16 +2277,15 @@
    * @return The index identity of the node that was added.
    */
   protected final int addNode(int type, int expandedTypeID,
-                        int parentIndex, int previousSibling,
-                        int dataOrPrefix, boolean canHaveFirstChild)
+                              int parentIndex, int previousSibling,
+                              int dataOrPrefix, boolean canHaveFirstChild)
   {
     // Common to all nodes:
     int nodeIndex = m_size++;
 
     // Have we overflowed a DTM Identity's addressing range?
     //if(m_dtmIdent.size() == (nodeIndex>>>DTMManager.IDENT_DTM_NODE_BITS))
-    if (nodeIndex == m_maxNodeIndex)
-    {
+    if (nodeIndex == m_maxNodeIndex) {
       addNewDTMID(nodeIndex);
       m_maxNodeIndex += (1 << DTMManager.IDENT_DTM_NODE_BITS);
     }
@@ -2366,8 +2308,7 @@
     // is called, to handle successive characters() events.
 
     // Special handling by type: Declare namespaces, attach first child
-    switch(type)
-    {
+    switch(type) {
     case DTM.NAMESPACE_NODE:
       declareNamespaceInContext(parentIndex,nodeIndex);
       break;
@@ -2376,8 +2317,7 @@
     default:
       if (DTM.NULL != previousSibling) {
         m_nextsib.setElementAt(nodeIndex,previousSibling);
-      }
-      else if (DTM.NULL != parentIndex) {
+      } else if (DTM.NULL != parentIndex) {
         m_firstch.setElementAt(nodeIndex,parentIndex);
       }
       break;
@@ -2390,16 +2330,12 @@
    * Check whether accumulated text should be stripped; if not,
    * append the appropriate flavor of text/cdata node.
    */
-  protected final void charactersFlush()
-  {
-
-    if (m_textPendingStart >= 0)  // -1 indicates no-text-in-progress
-    {
+  protected final void charactersFlush() {
+    if (m_textPendingStart >= 0) { // -1 indicates no-text-in-progress
       int length = m_chars.size() - m_textPendingStart;
       boolean doStrip = false;
 
-      if (getShouldStripWhitespace())
-      {
+      if (getShouldStripWhitespace()) {
         doStrip = m_chars.isWhitespace(m_textPendingStart, length);
       }
 
@@ -2412,19 +2348,19 @@
           // If the offset and length do not exceed the given limits
           // (offset < 2^21 and length < 2^10), then save both the offset
           // and length in a bitwise encoded value.
-          if (length <= TEXT_LENGTH_MAX
-                  && m_textPendingStart <= TEXT_OFFSET_MAX) {
+          if (length <= TEXT_LENGTH_MAX &&
+              m_textPendingStart <= TEXT_OFFSET_MAX) {
             m_previous = addNode(m_coalescedTextType, DTM.TEXT_NODE,
-                             m_parents.peek(), m_previous,
-                             length + (m_textPendingStart << TEXT_LENGTH_BITS),
-                             false);
+                                 m_parents.peek(), m_previous,
+                                 length + (m_textPendingStart << TEXT_LENGTH_BITS),
+                                 false);
 
           } else {
             // Store offset and length in the m_data array if one exceeds
             // the given limits. Use a negative dataIndex as an indication.
             int dataIndex = m_data.size();
             m_previous = addNode(m_coalescedTextType, DTM.TEXT_NODE,
-                               m_parents.peek(), m_previous, -dataIndex, false);
+                                 m_parents.peek(), m_previous, -dataIndex, false);
 
             m_data.addElement(m_textPendingStart);
             m_data.addElement(length);
@@ -2452,7 +2388,7 @@
    *             none is supplied.
    * @throws SAXException Any SAX exception, possibly
    *            wrapping another exception.
-   * @see org.xml.sax.ContentHandler#processingInstruction
+   * @see ContentHandler#processingInstruction
    */
   public void processingInstruction(String target, String data)
           throws SAXException
@@ -2467,7 +2403,7 @@
                          -dataIndex, false);
 
     m_data.addElement(m_valuesOrPrefixes.stringToIndex(target));
-    m_values.addElement(data);
+    m_values.add(data);
     m_data.addElement(m_valueIndex++);
 
   }
@@ -2865,9 +2801,9 @@
       }
 
       if (m_xstrf != null)
-        return m_xstrf.newstr((String)m_values.elementAt(dataIndex));
+        return m_xstrf.newstr(m_values.get(dataIndex));
       else
-        return new XMLStringDefault((String)m_values.elementAt(dataIndex));
+        return new XMLStringDefault(m_values.get(dataIndex));
     }
   }
 
@@ -2966,7 +2902,7 @@
         dataIndex = m_data.elementAt(dataIndex + 1);
       }
 
-      return (String)m_values.elementAt(dataIndex);
+      return m_values.get(dataIndex);
     }
   }
 
@@ -3106,7 +3042,7 @@
         dataIndex = m_data.elementAt(dataIndex + 1);
       }
 
-      String str = (String)m_values.elementAt(dataIndex);
+      String str = m_values.get(dataIndex);
 
       if(normalize)
         FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(),
@@ -3160,7 +3096,7 @@
         dataIndex = m_data.elementAt(dataIndex + 1);
       }
 
-      return (String)m_values.elementAt(dataIndex);
+      return m_values.get(dataIndex);
     }
   }
 
@@ -3202,8 +3138,7 @@
         if (uri.length() == 0) {
             handler.startElement(name);
             return name;
-        }
-        else {
+        } else {
             int qnameIndex = m_dataOrQName.elementAt(nodeID);
 
             if (qnameIndex == 0) {
@@ -3223,14 +3158,12 @@
             String prefix;
             if (prefixIndex > 0) {
                 prefix = qName.substring(0, prefixIndex);
-            }
-            else {
+            } else {
                 prefix = null;
             }
             handler.namespaceAfterStartElement(prefix, uri);
             return qName;
         }
-
     }
 
     /**
@@ -3285,7 +3218,7 @@
                 dataIndex = m_data.elementAt(dataIndex + 1);
             }
 
-            String nodeValue = (String)m_values.elementAt(dataIndex);
+            String nodeValue = m_values.get(dataIndex);
 
             handler.namespaceAfterStartElement(nodeName, nodeValue);
 
@@ -3335,7 +3268,6 @@
     }
 
 
-
     /**
      * Copy an Attribute node to a SerializationHandler
      *
@@ -3347,14 +3279,6 @@
         SerializationHandler handler)
         throws SAXException
     {
-        /*
-            final String uri = getNamespaceName(node);
-            if (uri.length() != 0) {
-                final String prefix = getPrefix(node);
-                handler.namespaceAfterStartElement(prefix, uri);
-            }
-            handler.addAttribute(getNodeName(node), getNodeValue(node));
-        */
         final ExtendedType extType = m_extendedTypes[exptype];
         final String uri = extType.getNamespace();
         final String localName = extType.getLocalName();
@@ -3377,7 +3301,7 @@
             }
 
         String nodeName = (prefix != null) ? qname : localName;
-        String nodeValue = (String)m_values.elementAt(valueIndex);
+        String nodeValue = m_values.get(valueIndex);
 
         handler.addAttribute(uri, localName, nodeName, "CDATA", nodeValue);
     }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/AltCatalog.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/AltCatalog.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@
     }
 
     /**
-     * Returns the catalog attribute as an URI String.
+     * Returns the catalog attribute as a URI String.
      * @return The value of the catalog attribute
      */
     String getCatalogId() {
@@ -66,7 +66,7 @@
     }
 
     /**
-     * Returns the catalog attribute as an URI.
+     * Returns the catalog attribute as a URI.
      * @return The value of the catalog attribute
      */
     URI getCatalogURI() {
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Objects;
+import static javax.xml.catalog.CatalogMessages.ERR_INVALID_ARGUMENT;
 
 /**
  * Represents a general Catalog entry.
@@ -210,13 +211,12 @@
      * @param arg The name of the argument
      * @param uri The URI to be verified
      * @return The URI created from the specified uri
-     * @throws IllegalArgumentException if the specified uri is null,
-     * or an URL can not be created based on the specified base and uri
+     * @throws NullPointerException if the specified uri is null
+     * @throws IllegalArgumentException if a URL can not be created based on
+     * the specified base and uri
      */
     URL verifyURI(String arg, URL base, String uri) {
-        if (uri == null) {
-            CatalogMessages.reportIAE(new Object[]{uri, arg}, null);
-        }
+        CatalogMessages.reportNPEOnNull(arg, uri);
 
         URL url = null;
         uri = Normalizer.normalizeURI(uri);
@@ -228,32 +228,9 @@
                 url = new URL(uri);
             }
         } catch (MalformedURLException e) {
-            CatalogMessages.reportIAE(new Object[]{uri, arg}, e);
+            CatalogMessages.reportIAE(ERR_INVALID_ARGUMENT,
+                    new Object[]{uri, arg}, e);
         }
         return url;
     }
-
-    /**
-     * Construct an absolute URI from a relative one, using the current base
-     * URI.
-     *
-     * @param sysid The (possibly relative) system identifier
-     * @return The system identifier made absolute with respect to the current
-     * {@link #base}.
-     */
-    protected String makeAbsolute(String sysid) {
-        URL local = null;
-
-        sysid = Util.fixSlashes(sysid);
-        /**
-         * try { local = new URL(base, sysid); } catch (MalformedURLException e)
-         * { catalogManager.debug.message(1, "Malformed URL on system
-         * identifier", sysid); }
-         */
-        if (local != null) {
-            return local.toString();
-        } else {
-            return sysid;
-        }
-    }
 }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@
  * <ul>
  * <li>Locate the external resources with a public or system identifier;
  * </li>
- * <li>Locate an alternate URI reference with an URI.
+ * <li>Locate an alternate URI reference with a URI.
  * </li>
  * </ul>
  * <p>
@@ -84,7 +84,7 @@
      *
      * @param systemId the system identifier of the entity to be matched
      *
-     * @return an URI string if a mapping is found, or null otherwise
+     * @return a URI string if a mapping is found, or null otherwise
      */
     public String matchSystem(String systemId);
 
@@ -108,7 +108,7 @@
      *
      * @param publicId the public identifier of the entity to be matched
      * @see CatalogFeatures.Feature
-     * @return an URI string if a mapping is found, or null otherwise
+     * @return a URI string if a mapping is found, or null otherwise
      */
     public String matchPublic(String publicId);
 
@@ -134,7 +134,7 @@
      *
      * @param uri the URI reference of the entity to be matched
      *
-     * @return an URI string if a mapping is found, or null otherwise
+     * @return a URI string if a mapping is found, or null otherwise
      */
     public String matchURI(String uri);
 
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,14 +56,14 @@
  *
  * <tr>
  * <td><a name="FILES">FILES</a></td>
- * <td>A semicolon-delimited list of catalog files. Relative file paths are
- * considered relative to ${user.dir}.
+ * <td>A semicolon-delimited list of URIs to locate the catalog files.
+ * The URIs must be absolute and have a URL protocol handler for the URI scheme.
  * </td>
  * <td>javax.xml.catalog.files</td>
  * <td>javax.xml.catalog.files</td>
  * <td>javax.xml.catalog.files</td>
  * <td>String</td>
- * <td>File paths</td>
+ * <td>URIs</td>
  * <td>
  * Reads the first catalog as the current catalog; Loads others if no match
  * is found in the current catalog including delegate catalogs if any.
@@ -170,7 +170,7 @@
  * Properties set through the Catalog API override those that may have been set
  * by system properties and/or in {@code jaxp.properties}. In case of multiple
  * interfaces, the latest in a procedure shall take preference. For
- * {@link Feature#FILES}, this means that the path(s) specified through the methods
+ * {@link Feature#FILES}, this means that the URI(s) specified through the methods
  * of the {@link CatalogManager} will override any that may have been entered
  * through the {@link Builder}.
  *
@@ -188,7 +188,7 @@
  * in the following sample code:
  * <pre>{@code
                 CatalogFeatures f = CatalogFeatures.builder()
-                        .with(Feature.FILES, "catalog.xml")
+                        .with(Feature.FILES, "file:///etc/xml/catalog")
                         .with(Feature.PREFER, "public")
                         .with(Feature.DEFER, "true")
                         .with(Feature.RESOLVE, "ignore")
@@ -202,14 +202,14 @@
  * Schema Validation ({@link javax.xml.validation}), and XML Transformation
  * ({@link javax.xml.transform}). The features described above can be set through JAXP
  * factories or processors that define a setProperty or setAttribute interface.
- * For example, the following code snippet sets a path to a catalog file on a SAX
+ * For example, the following code snippet sets a URI to a catalog file on a SAX
  * parser through the {@code javax.xml.catalog.files} property:
  * <p>
  * <pre>{@code
  *      SAXParserFactory spf = SAXParserFactory.newInstance();
  *      spf.setFeature(XMLConstants.USE_CATALOG, true); [1]
  *      SAXParser parser = spf.newSAXParser();
- *      parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), "catalog.xml");
+ *      parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), "file:///etc/xml/catalog");
  * }</pre>
  * <p>
  * [1] Note that this statement is not required since the default value of
@@ -275,7 +275,7 @@
    The following XInclude element:
    <xi:include href="http://openjdk.java.net/xml/disclaimer.xml"/>
 
-   can be resolved using an uri entry:
+   can be resolved using a URI entry:
    <uri name="http://openjdk.java.net/xml/disclaimer.xml" uri="file:///pathto/local/disclaimer.xml"/>
    or
    <uriSuffix uriSuffix="disclaimer.xml" uri="file:///pathto/local/disclaimer.xml"/>
@@ -291,7 +291,7 @@
     <xsd:import namespace="http://openjdk.java.net/xsd/XSDImport_person"
                 schemaLocation="http://openjdk.java.net/xsd/XSDImport_person.xsd"/>
 
-   can be resolved using an uri entry:
+   can be resolved using a URI entry:
    <uri name="http://openjdk.java.net/xsd/XSDImport_person.xsd" uri="file:///pathto/local/XSDImport_person.xsd"/>
    or
    <uriSuffix uriSuffix="XSDImport_person.xsd" uri="file:///pathto/local/XSDImport_person.xsd"/>
@@ -308,7 +308,7 @@
    The following include element:
    <xsd:include schemaLocation="http://openjdk.java.net/xsd/XSDInclude_person.xsd"/>
 
-   can be resolved using an uri entry:
+   can be resolved using a URI entry:
    <uri name="http://openjdk.java.net/xsd/XSDInclude_person.xsd" uri="file:///pathto/local/XSDInclude_person.xsd"/>
    or
    <uriSuffix uriSuffix="XSDInclude_person.xsd" uri="file:///pathto/local/XSDInclude_person.xsd"/>
@@ -323,7 +323,7 @@
    The following include element:
    <xsl:include href="http://openjdk.java.net/xsl/include.xsl"/>
 
-   can be resolved using an uri entry:
+   can be resolved using a URI entry:
    <uri name="http://openjdk.java.net/xsl/include.xsl" uri="file:///pathto/local/include.xsl"/>
    or
    <uriSuffix uriSuffix="include.xsl" uri="file:///pathto/local/include.xsl"/>
@@ -338,7 +338,7 @@
    The document in the following element:
    <xsl:variable name="dummy" select="document('http://openjdk.java.net/xsl/list.xml')"/>
 
-   can be resolved using an uri entry:
+   can be resolved using a URI entry:
    <uri name="http://openjdk.java.net/xsl/list.xml" uri="file:///pathto/local/list.xml"/>
    or
    <uriSuffix uriSuffix="list.xml" uri="file:///pathto/local/list.xml"/>
@@ -559,7 +559,7 @@
         values = new String[Feature.values().length];
         states = new State[Feature.values().length];
         for (Feature cf : Feature.values()) {
-            setProperty(cf.ordinal(), State.DEFAULT, cf.defaultValue());
+            setProperty(cf, State.DEFAULT, cf.defaultValue());
         }
         //read system properties or jaxp.properties
         readSystemProperties();
@@ -571,52 +571,27 @@
      */
     private void setProperties(Builder builder) {
         builder.values.entrySet().stream().forEach((entry) -> {
-            setProperty(entry.getKey().ordinal(), State.APIPROPERTY, entry.getValue());
+            setProperty(entry.getKey(), State.APIPROPERTY, entry.getValue());
         });
     }
     /**
-     * Sets the value of a property by its index, updates only if it shall override.
+     * Sets the value of a property, updates only if it shall override.
      *
      * @param index the index of the property
      * @param state the state of the property
      * @param value the value of the property
      * @throws IllegalArgumentException if the value is invalid
      */
-    private void setProperty(int index, State state, String value) {
+    private void setProperty(Feature feature, State state, String value) {
+        int index = feature.ordinal();
         if (value != null && value.length() != 0) {
-            if (index == Feature.PREFER.ordinal()) {
-                if (!value.equals(PREFER_SYSTEM) && !value.equals(PREFER_PUBLIC)) {
-                    CatalogMessages.reportIAE(new Object[]{value, Feature.PREFER.name()}, null);
-                }
-            } else if (index == Feature.DEFER.ordinal()) {
-                if (!value.equals(DEFER_TRUE) && !value.equals(DEFER_FALSE)) {
-                    CatalogMessages.reportIAE(new Object[]{value, Feature.DEFER.name()}, null);
-                }
-            } else if (index == Feature.RESOLVE.ordinal()) {
-                if (!value.equals(RESOLVE_STRICT) && !value.equals(RESOLVE_CONTINUE)
-                         && !value.equals(RESOLVE_IGNORE)) {
-                    CatalogMessages.reportIAE(new Object[]{value, Feature.RESOLVE.name()}, null);
-                }
-            } else if (index == Feature.FILES.ordinal()) {
-                try {
-                    String[] catalogFile = value.split(";[ ]*");
-                    for (String temp : catalogFile) {
-                        if (Util.verifyAndGetURI(temp, null) == null) {
-                            CatalogMessages.reportIAE(new Object[]{value, Feature.FILES.name()}, null);
-                        }
-                    }
-                }catch (MalformedURLException | URISyntaxException | IllegalArgumentException ex) {
-                    CatalogMessages.reportIAE(new Object[]{value, Feature.FILES.name()}, ex);
-                }
+            if (state != State.APIPROPERTY) {
+                Util.validateFeatureInput(feature, value);
             }
             if (states[index] == null || state.compareTo(states[index]) >= 0) {
                 values[index] = value;
                 states[index] = state;
             }
-        } else {
-            if (state == State.SYSTEMPROPERTY || state == State.JAXPDOTPROPERTIES) {
-                CatalogMessages.reportIAE(new Object[]{value, Feature.values()[index].name()}, null);
-            }
         }
     }
 
@@ -639,13 +614,13 @@
         if (cf.hasSystemProperty()) {
             String value = SecuritySupport.getSystemProperty(sysPropertyName);
             if (value != null && !value.equals("")) {
-                setProperty(cf.ordinal(), State.SYSTEMPROPERTY, value);
+                setProperty(cf, State.SYSTEMPROPERTY, value);
                 return true;
             }
 
             value = SecuritySupport.readJAXPProperty(sysPropertyName);
             if (value != null && !value.equals("")) {
-                setProperty(cf.ordinal(), State.JAXPDOTPROPERTIES, value);
+                setProperty(cf, State.JAXPDOTPROPERTIES, value);
                 return true;
             }
         }
@@ -685,9 +660,7 @@
          * property
          */
         public Builder with(Feature feature, String value) {
-            if (value == null || value.length() == 0) {
-                CatalogMessages.reportIAE(new Object[]{value, feature.name()}, null);
-            }
+            Util.validateFeatureInput(feature, value);
             values.put(feature, value);
             return this;
         }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,7 +75,7 @@
 
     /*
      A list of catalog entry files from the input, excluding the current catalog.
-     Paths in the List are normalized.
+     URIs in the List are verified during input validation or property retrieval.
      */
     List<String> inputFiles;
 
@@ -86,43 +86,44 @@
     SAXParser parser;
 
     /**
-     * Construct a Catalog with specified path.
+     * Construct a Catalog with specified URI.
      *
-     * @param file The path to a catalog file.
+     * @param uris the uri(s) to one or more catalogs
      * @throws CatalogException If an error happens while parsing the specified
      * catalog file.
      */
-    public CatalogImpl(CatalogFeatures f, String... file) throws CatalogException {
-        this(null, f, file);
+    public CatalogImpl(CatalogFeatures f, URI... uris) throws CatalogException {
+        this(null, f, uris);
     }
 
     /**
-     * Construct a Catalog with specified path.
+     * Construct a Catalog with specified URI.
      *
      * @param parent The parent catalog
-     * @param file The path to a catalog file.
+     * @param uris the uri(s) to one or more catalogs
      * @throws CatalogException If an error happens while parsing the specified
      * catalog file.
      */
-    public CatalogImpl(CatalogImpl parent, CatalogFeatures f, String... file) throws CatalogException {
+    public CatalogImpl(CatalogImpl parent, CatalogFeatures f, URI... uris) throws CatalogException {
         super(CatalogEntryType.CATALOG, parent);
         if (f == null) {
             throw new NullPointerException(
                     formatMessage(CatalogMessages.ERR_NULL_ARGUMENT, new Object[]{"CatalogFeatures"}));
         }
 
-        if (file.length > 0) {
-            CatalogMessages.reportNPEOnNull("The path to the catalog file", file[0]);
-        }
-
         init(f);
 
         //Path of catalog files
-        String[] catalogFile = file;
-        if (level == 0 && file.length == 0) {
+        String[] catalogFile = null;
+        if (level == 0 && uris.length == 0) {
             String files = features.get(Feature.FILES);
             if (files != null) {
-                catalogFile = files.split(";[ ]*");
+                catalogFile = files.split(";");
+            }
+        } else {
+            catalogFile = new String[uris.length];
+            for (int i=0; i<uris.length; i++) {
+                catalogFile[i] = uris[i].toASCIIString();
             }
         }
 
@@ -134,10 +135,10 @@
             int start = 0;
             URI uri = null;
             for (String temp : catalogFile) {
-                uri = getSystemId(temp);
+                uri = URI.create(temp);
                 start++;
                 if (verifyCatalogFile(uri)) {
-                    systemId = uri.toASCIIString();
+                    systemId = temp;
                     try {
                         baseURI = new URL(systemId);
                     } catch (MalformedURLException e) {
@@ -294,29 +295,6 @@
     }
 
     /**
-     * Resolves the specified file path to an absolute systemId. If it is
-     * relative, it shall be resolved using the base or user.dir property if
-     * base is not specified.
-     *
-     * @param file The specified file path
-     * @return The systemId of the file
-     * @throws CatalogException if the specified file path can not be converted
-     * to a system id
-     */
-    private URI getSystemId(String file) {
-        URI temp = null;
-
-        try {
-            temp = Util.verifyAndGetURI(file, baseURI);
-        } catch (MalformedURLException | URISyntaxException | IllegalArgumentException e) {
-            CatalogMessages.reportRunTimeError(CatalogMessages.ERR_INVALID_PATH,
-                    new Object[]{file}, e);
-        }
-
-        return temp;
-    }
-
-    /**
      * Returns a SAXParser instance
      * @return a SAXParser instance
      * @throws CatalogException if constructing a SAXParser failed
@@ -394,7 +372,7 @@
                 //Check the input list
                 if (c == null && inputFiles != null) {
                     while (c == null && inputFilesIndex < inputFiles.size()) {
-                        c = getCatalog(getSystemId(inputFiles.get(inputFilesIndex++)));
+                        c = getCatalog(URI.create(inputFiles.get(inputFilesIndex++)));
                     }
                 }
 
@@ -436,8 +414,8 @@
 
         //loads catalogs from the input list
         if (inputFiles != null) {
-            inputFiles.stream().forEach((file) -> {
-                getCatalog(getSystemId(file));
+            inputFiles.stream().forEach((uri) -> {
+                getCatalog(URI.create(uri));
             });
         }
     }
@@ -454,12 +432,11 @@
         }
 
         CatalogImpl c = null;
-        String path = uri.toASCIIString();
 
         if (verifyCatalogFile(uri)) {
-            c = getLoadedCatalog(path);
+            c = getLoadedCatalog(uri.toASCIIString());
             if (c == null) {
-                c = new CatalogImpl(this, features, path);
+                c = new CatalogImpl(this, features, uri);
                 c.load();
             }
         }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
  */
 package javax.xml.catalog;
 
+import java.net.URI;
 
 /**
  * The Catalog Manager manages the creation of XML Catalogs and Catalog Resolvers.
@@ -39,30 +40,36 @@
 
     /**
      * Creates a {@code Catalog} object using the specified feature settings and
-     * path to one or more catalog files.
+     * uri(s) to one or more catalog files.
      * <p>
-     * If {@code paths} is empty, system property {@code javax.xml.catalog.files}
-     * will be read to locate the initial list of catalog files.
+     * If {@code uris} is empty, system property {@code javax.xml.catalog.files},
+     * as defined in {@link CatalogFeatures}, will be read to locate the initial
+     * list of catalog files.
      * <p>
-     * If more than one catalog files are specified through the paths argument or
+     * If multiple catalog files are specified through the {@code uris} argument or
      * {@code javax.xml.catalog.files} property, the first entry is considered
      * the main catalog, while others are treated as alternative catalogs after
      * those referenced by the {@code nextCatalog} elements in the main catalog.
      * <p>
      * As specified in
      * <a href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html#s.res.fail">
-     * XML Catalogs, OASIS Standard V1.1</a>, invalid path entries will be ignored.
-     * No error will be reported. In case all entries are invalid, the resolver
-     * will return as no mapping is found.
+     * XML Catalogs, OASIS Standard V1.1</a>, if a catalog entry is invalid, it
+     * is ignored. In case all entries are invalid, the resulting Catalog object
+     * will contain no Catalog elements. Any matching operation using the Catalog
+     * will return null.
      *
      * @param features the catalog features
-     * @param paths path(s) to one or more catalogs.
+     * @param uris uri(s) to one or more catalogs.
      *
      * @return an instance of a {@code Catalog}
+     * @throws IllegalArgumentException if either the URIs are not absolute
+     * or do not have a URL protocol handler for the URI scheme
      * @throws CatalogException If an error occurs while parsing the catalog
+     * @throws SecurityException if access to the resource is denied by the security manager
      */
-    public static Catalog catalog(CatalogFeatures features, String... paths) {
-        CatalogImpl catalog = new CatalogImpl(features, paths);
+    public static Catalog catalog(CatalogFeatures features, URI... uris) {
+        Util.validateUrisSyntax(uris);
+        CatalogImpl catalog = new CatalogImpl(features, uris);
         catalog.load();
         return catalog;
     }
@@ -80,30 +87,36 @@
 
     /**
      * Creates an instance of a {@code CatalogResolver} using the specified feature
-     * settings and path to one or more catalog files.
+     * settings and uri(s) to one or more catalog files.
      * <p>
-     * If {@code paths} is empty, system property {@code javax.xml.catalog.files}
-     * will be read to locate the initial list of catalog files.
+     * If {@code uris} is empty, system property {@code javax.xml.catalog.files},
+     * as defined in {@link CatalogFeatures}, will be read to locate the initial
+     * list of catalog files.
      * <p>
-     * If more than one catalog files are specified through the paths argument or
+     * If multiple catalog files are specified through the {@code uris} argument or
      * {@code javax.xml.catalog.files} property, the first entry is considered
      * the main catalog, while others are treated as alternative catalogs after
      * those referenced by the {@code nextCatalog} elements in the main catalog.
      * <p>
      * As specified in
      * <a href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html#s.res.fail">
-     * XML Catalogs, OASIS Standard V1.1</a>, invalid path entries will be ignored.
-     * No error will be reported. In case all entries are invalid, the resolver
-     * will return as no mapping is found.
+     * XML Catalogs, OASIS Standard V1.1</a>, if a catalog entry is invalid, it
+     * is ignored. In case all entries are invalid, the resulting CatalogResolver
+     * object will contain no valid catalog. Any resolution operation using the
+     * resolver therefore will return as no mapping is found. See {@link CatalogResolver}
+     * for the behavior when no mapping is found.
      *
      * @param features the catalog features
-     * @param paths the path(s) to one or more catalogs
+     * @param uris the uri(s) to one or more catalogs
      *
      * @return an instance of a {@code CatalogResolver}
+     * @throws IllegalArgumentException if either the URIs are not absolute
+     * or do not have a URL protocol handler for the URI scheme
      * @throws CatalogException If an error occurs while parsing the catalog
+     * @throws SecurityException if access to the resource is denied by the security manager
      */
-    public static CatalogResolver catalogResolver(CatalogFeatures features, String... paths) {
-        Catalog catalog = catalog(features, paths);
+    public static CatalogResolver catalogResolver(CatalogFeatures features, URI... uris) {
+        Catalog catalog = catalog(features, uris);
         return new CatalogResolverImpl(catalog);
     }
 }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,11 @@
  */
 package javax.xml.catalog;
 
-import jdk.xml.internal.SecuritySupport;
+import java.net.URI;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import jdk.xml.internal.SecuritySupport;
 
 /**
  * Catalog Error messages
@@ -38,6 +39,8 @@
 
     public static final String ERR_INVALID_CATALOG = "InvalidCatalog";
     public static final String ERR_INVALID_ENTRY_TYPE = "InvalidEntryType";
+    public static final String ERR_URI_NOTABSOLUTE = "UriNotAbsolute";
+    public static final String ERR_URI_NOTVALIDURL = "UriNotValidUrl";
     public static final String ERR_INVALID_ARGUMENT = "InvalidArgument";
     public static final String ERR_NULL_ARGUMENT = "NullArgument";
     public static final String ERR_CIRCULAR_REFERENCE = "CircularReference";
@@ -120,7 +123,7 @@
      * @param name the name of the argument
      * @param value the value of the argument
      */
-    static void reportNPEOnNull(String name, String value) {
+    static void reportNPEOnNull(String name, Object value) {
         if (value == null) {
             throw new NullPointerException(
                     formatMessage(ERR_NULL_ARGUMENT, new Object[]{name}));
@@ -132,9 +135,9 @@
      * @param arguments the arguments for formating the error message
      * @param cause the cause if any
      */
-    static void reportIAE(Object[] arguments, Throwable cause) {
+    static void reportIAE(String key, Object[] arguments, Throwable cause) {
         throw new IllegalArgumentException(
-                formatMessage(ERR_INVALID_ARGUMENT, arguments), cause);
+                formatMessage(key, arguments), cause);
     }
 
     /**
@@ -174,7 +177,7 @@
 
     /**
      * Returns sanitized URI.
-     * @param uri an URI to be sanitized
+     * @param uri a URI to be sanitized
      */
     static String sanitize(String uri) {
         if (uri == null) {
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -31,6 +31,8 @@
 CircularReference = Circular reference is not allowed: ''{0}''.
 
 #errors
+UriNotAbsolute = The specified URI ''{0}'' is not absolute.
+UriNotValidUrl = The specified URI ''{0}'' is not a valid URL.
 InvalidArgument = The specified argument ''{0}'' (case sensitive) for ''{1}'' is not valid.
 NullArgument = The argument ''{0}'' can not be null.
 InvalidPath = The path ''{0}'' is invalid.
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,6 @@
 package javax.xml.catalog;
 
 import java.io.StringReader;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import javax.xml.catalog.BaseEntry.CatalogEntryType;
 import javax.xml.parsers.SAXParser;
 import javax.xml.transform.Source;
@@ -94,25 +90,6 @@
         this.parser = parser;
     }
 
-    /**
-     * Returns when the specified path is valid.
-     * @param path a path
-     * @return true if the path is valid, false otherwise
-     */
-    boolean isValidPath(String path) {
-        boolean valid = true;
-        try {
-            Path p = Paths.get(new URI(path));
-            if (!p.toFile().exists()) {
-                valid = false;
-            }
-        } catch (URISyntaxException ex) {
-            valid = false;
-        }
-
-        return valid;
-    }
-
     @Override
     public void startElement(String namespaceURI,
             String localName,
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
  * {@link javax.xml.stream.XMLResolver} and {@link org.w3c.dom.ls.LSResourceResolver}
  * however, make no such distinction.
  * In consistent with the existing Java API, this CatalogResolver recognizes a
- * system identifier as an URI and will search both {@code system} and {@code uri}
+ * system identifier as a URI and will search both {@code system} and {@code uri}
  * entries in a catalog in order to find a matching entry.
  * <p>
  * The search is started in the current catalog. If a match is found,
@@ -137,9 +137,9 @@
      * with the specified {@code href} attribute. The {@code href} attribute will
      * be used literally, with no attempt to be made absolute to the {@code base}.
      * <p>
-     * If the value is an URN, the {@code href} attribute is recognized as a
+     * If the value is a URN, the {@code href} attribute is recognized as a
      * {@code publicId}, and used to search {@code public} entries.
-     * If the value is an URI, it is taken as a {@code systemId}, and used to
+     * If the value is a URI, it is taken as a {@code systemId}, and used to
      * search both {@code system} and {@code uri} entries.
      *
      *
@@ -219,7 +219,7 @@
      * @param publicId  the public identifier of the external entity being
      *   referenced, or {@code null} if no public identifier was
      *   supplied or if the resource is not an entity.
-     * @param systemId  the system identifier, an URI reference of the
+     * @param systemId  the system identifier, a URI reference of the
      *   external resource being referenced
      * @param baseUri  the absolute base URI, not used by the CatalogResolver
      *
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,7 +73,7 @@
         systemId = Normalizer.normalizeURI(Util.getNotNullOrEmpty(systemId));
         publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(Util.getNotNullOrEmpty(publicId)));
 
-        //check whether systemId is an urn
+        //check whether systemId is a urn
         if (systemId != null && systemId.startsWith(Util.URN)) {
             systemId = Normalizer.decodeURN(systemId);
             if (publicId != null && !publicId.equals(systemId)) {
@@ -123,7 +123,7 @@
             return null;
         }
 
-        //check whether uri is an urn
+        //check whether uri is a urn
         if (uri != null && uri.startsWith(Util.URN)) {
             String publicId = Normalizer.decodeURN(uri);
             if (publicId != null) {
@@ -131,7 +131,7 @@
             }
         }
 
-        //if no match with a public id, continue search for an URI
+        //if no match with a public id, continue search for a URI
         if (result == null) {
             //remove fragment if any.
             int hashPos = uri.indexOf("#");
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,6 @@
 package javax.xml.catalog;
 
 import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -217,7 +215,7 @@
      * @param systemId The system identifier of the external entity being
      * referenced.
      *
-     * @return An URI string if a mapping is found, or null otherwise.
+     * @return a URI string if a mapping is found, or null otherwise.
      */
     public String matchSystem(String systemId) {
         systemEntrySearched = true;
@@ -285,7 +283,7 @@
      * @param publicId The public identifier of the external entity being
      * referenced.
      *
-     * @return An URI string if a mapping is found, or null otherwise.
+     * @return a URI string if a mapping is found, or null otherwise.
      */
     public String matchPublic(String publicId) {
         /*
@@ -329,7 +327,7 @@
      *
      * @param uri The URI reference of a resource.
      *
-     * @return An URI string if a mapping is found, or null otherwise.
+     * @return a URI string if a mapping is found, or null otherwise.
      */
     public String matchURI(String uri) {
         String match = null;
@@ -455,7 +453,7 @@
             delegateCatalog = getLoadedCatalog(catalogId);
             if (delegateCatalog == null) {
                 if (verifyCatalogFile(catalogURI)) {
-                    delegateCatalog = new CatalogImpl(catalog, features, catalogId);
+                    delegateCatalog = new CatalogImpl(catalog, features, catalogURI);
                     delegateCatalog.load();
                     delegateCatalogs.put(catalogId, delegateCatalog);
                 }
@@ -504,7 +502,8 @@
         }
 
         //Ignore it if it doesn't exist
-        if (!Files.exists(Paths.get(catalogURI))) {
+        if (Util.isFileUri(catalogURI) &&
+                !Util.isFileUriExist(catalogURI, false)) {
             return false;
         }
 
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 import java.net.URL;
 
 /**
- * Represents an uriEntry entry.
+ * Represents a uri entry.
  *
  * @since 9
  */
@@ -36,7 +36,7 @@
     URL uri;
 
     /**
-     * Construct a group entry.
+     * Construct a uri entry.
      * @param name The name attribute.
      * @param uri The uri attribute.
      */
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,20 @@
 package javax.xml.catalog;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.Iterator;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import static javax.xml.catalog.CatalogFeatures.DEFER_FALSE;
+import static javax.xml.catalog.CatalogFeatures.DEFER_TRUE;
+import javax.xml.catalog.CatalogFeatures.Feature;
+import static javax.xml.catalog.CatalogFeatures.PREFER_PUBLIC;
+import static javax.xml.catalog.CatalogFeatures.PREFER_SYSTEM;
+import static javax.xml.catalog.CatalogFeatures.RESOLVE_CONTINUE;
+import static javax.xml.catalog.CatalogFeatures.RESOLVE_IGNORE;
+import static javax.xml.catalog.CatalogFeatures.RESOLVE_STRICT;
 import jdk.xml.internal.SecuritySupport;
 
 /**
@@ -39,22 +46,25 @@
  * @since 9
  */
 class Util {
+
     final static String URN = "urn:publicid:";
     final static String PUBLICID_PREFIX = "-//";
     final static String PUBLICID_PREFIX_ALT = "+//";
+    final static String SCHEME_FILE = "file";
+    final static String SCHEME_JAR = "jar";
+    final static String SCHEME_JARFILE = "jar:file:";
 
     /**
      * Finds an entry in the catalog that matches with the publicId or systemId.
      *
-     * The resolution follows the following rules determined by the prefer setting:
+     * The resolution follows the following rules determined by the prefer
+     * setting:
      *
-     * prefer "system": attempts to resolve with a system entry;
-     *                  attempts to resolve with a public entry when only
-     *                  publicId is specified.
+     * prefer "system": attempts to resolve with a system entry; attempts to
+     * resolve with a public entry when only publicId is specified.
      *
-     * prefer "public": attempts to resolve with a system entry;
-     *                  attempts to resolve with a public entry if no matching
-     *                  system entry is found.
+     * prefer "public": attempts to resolve with a system entry; attempts to
+     * resolve with a public entry if no matching system entry is found.
      *
      * If no match is found, continue searching uri entries
      *
@@ -70,9 +80,9 @@
         catalog.reset();
         if (systemId != null) {
             /*
-               If a system identifier is specified, it is used no matter how
-            prefer is set.
-            */
+             If a system identifier is specified, it is used no matter how
+             prefer is set.
+             */
             resolvedSystemId = catalog.matchSystem(systemId);
         }
 
@@ -91,7 +101,7 @@
         if (resolvedSystemId == null) {
             Iterator<Catalog> iter = catalog.catalogs().iterator();
             while (iter.hasNext()) {
-                resolvedSystemId = resolve((CatalogImpl)iter.next(), publicId, systemId);
+                resolvedSystemId = resolve((CatalogImpl) iter.next(), publicId, systemId);
                 if (resolvedSystemId != null) {
                     break;
                 }
@@ -102,73 +112,112 @@
         return resolvedSystemId;
     }
 
+    static void validateUrisSyntax(URI... uris) {
+        for (URI uri : uris) {
+            validateUriSyntax(uri);
+        }
+    }
+
+    static void validateUrisSyntax(String... uris) {
+        for (String uri : uris) {
+            validateUriSyntax(URI.create(uri));
+        }
+    }
+
     /**
-     * Resolves the specified file path to an absolute systemId. If it is
-     * relative, it shall be resolved using the base or user.dir property if
-     * base is not specified.
+     * Validate that the URI must be absolute and a valid URL.
      *
-     * @param file The specified file path
-     * @param baseURI the base URI
-     * @return The URI
-     * @throws CatalogException if the specified file path can not be converted
-     * to a system id
+     * Note that this method does not verify the existence of the resource. The
+     * Catalog standard requires that such resources be ignored.
+     *
+     * @param uri
+     * @throws IllegalArgumentException if the uri is not absolute and a valid
+     * URL
      */
-    static URI verifyAndGetURI(String file, URL baseURI)
-            throws MalformedURLException, URISyntaxException, IllegalArgumentException {
-        URL filepath;
-        URI temp;
-        if (file != null && file.length() > 0) {
-            File f = new File(file);
+    static void validateUriSyntax(URI uri) {
+        CatalogMessages.reportNPEOnNull("URI input", uri);
+
+        if (!uri.isAbsolute()) {
+            CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTABSOLUTE,
+                    new Object[]{uri}, null);
+        }
 
-            if (baseURI != null && !f.isAbsolute()) {
-                filepath = new URL(baseURI, fixSlashes(file));
-                temp = filepath.toURI();
-            } else {
-                temp = resolveURI(file);
-            }
-            //Paths.get may throw IllegalArgumentException
-            Path path = Paths.get(temp);
-            if (path.toFile().isFile()) {
-                return temp;
+        try {
+            // check if the scheme was valid
+            uri.toURL();
+        } catch (MalformedURLException ex) {
+            CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTVALIDURL,
+                    new Object[]{uri}, null);
+        }
+
+        // verify the resource exists where possible
+        if (isFileUri(uri)) {
+            if (!isFileUriExist(uri, false)) {
+                CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTVALIDURL,
+                        new Object[]{uri}, null);
             }
         }
-        return null;
     }
 
     /**
-     * Resolves the specified uri. If the uri is relative, makes it absolute by
-     * the user.dir directory.
+     * Checks whether the URI is a file URI, including JAR file.
      *
-     * @param uri The specified URI.
-     * @return The resolved URI
+     * @param uri the specified URI.
+     * @return true if it is a file or JAR file URI, false otherwise
      */
-    static URI resolveURI(String uri) throws MalformedURLException {
-        if (uri == null) {
-            uri = "";
+    static boolean isFileUri(URI uri) {
+        if (SCHEME_FILE.equals(uri.getScheme())
+                || SCHEME_JAR.equals(uri.getScheme())) {
+            return true;
         }
-
-        URI temp = null;
-        try {
-            URL url = new URL(uri);
-            temp = url.toURI();
-        } catch (MalformedURLException | URISyntaxException mue) {
-            File file = new File(uri);
-            temp = file.toURI();
-        }
-
-        return temp;
+        return false;
     }
 
     /**
-     * Replace backslashes with forward slashes. (URLs always use forward
-     * slashes.)
+     * Verifies whether the file resource exists.
      *
-     * @param sysid The input system identifier.
-     * @return The same system identifier with backslashes turned into forward
-     * slashes.
+     * @param uri the URI to locate the resource
+     * @param openJarFile a flag to indicate whether a JAR file should be
+     * opened. This operation may be expensive.
+     * @return true if the resource exists, false otherwise.
      */
-    static String fixSlashes(String sysid) {
-        return sysid.replace('\\', '/');
+    static boolean isFileUriExist(URI uri, boolean openJarFile) {
+        if (uri != null && uri.isAbsolute()) {
+            if (null != uri.getScheme()) {
+                switch (uri.getScheme()) {
+                    case SCHEME_FILE:
+                        String path = uri.getPath();
+                        File f1 = new File(path);
+                        if (f1.isFile()) {
+                            return true;
+                        }
+                        break;
+                    case SCHEME_JAR:
+                        String tempUri = uri.toString();
+                        int pos = tempUri.indexOf("!");
+                        if (pos < 0) {
+                            return false;
+                        }
+                        if (openJarFile) {
+                            String jarFile = tempUri.substring(SCHEME_JARFILE.length(), pos);
+                            String entryName = tempUri.substring(pos + 2);
+                            try {
+                                JarFile jf = new JarFile(jarFile);
+                                JarEntry je = jf.getJarEntry(entryName);
+                                if (je != null) {
+                                    return true;
+                                }
+                            } catch (IOException ex) {
+                                return false;
+                            }
+                        } else {
+                            return true;
+                        }
+                        break;
+                }
+            }
+        }
+        return false;
     }
 
     /**
@@ -187,11 +236,12 @@
     }
 
     /**
-     * Checks whether the specified string is null or empty, returns the original
-     * string with leading and trailing spaces removed if not.
+     * Checks whether the specified string is null or empty, returns the
+     * original string with leading and trailing spaces removed if not.
+     *
      * @param test the string to be tested
-     * @return the original string with leading and trailing spaces removed,
-     * or null if it is null or empty
+     * @return the original string with leading and trailing spaces removed, or
+     * null if it is null or empty
      *
      */
     static String getNotNullOrEmpty(String test) {
@@ -206,4 +256,39 @@
             }
         }
     }
+
+    /**
+     * Validates the input for features.
+     *
+     * @param f the feature
+     * @param value the value
+     * @throws IllegalArgumentException if the value is invalid for the feature
+     */
+    static void validateFeatureInput(Feature f, String value) {
+        CatalogMessages.reportNPEOnNull(f.name(), value);
+        if (value.length() == 0) {
+            CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT,
+                    new Object[]{value, f.name()}, null);
+        }
+
+        if (f == Feature.PREFER) {
+            if (!value.equals(PREFER_SYSTEM) && !value.equals(PREFER_PUBLIC)) {
+                CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT,
+                        new Object[]{value, Feature.PREFER.name()}, null);
+            }
+        } else if (f == Feature.DEFER) {
+            if (!value.equals(DEFER_TRUE) && !value.equals(DEFER_FALSE)) {
+                CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT,
+                        new Object[]{value, Feature.DEFER.name()}, null);
+            }
+        } else if (f == Feature.RESOLVE) {
+            if (!value.equals(RESOLVE_STRICT) && !value.equals(RESOLVE_CONTINUE)
+                    && !value.equals(RESOLVE_IGNORE)) {
+                CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT,
+                        new Object[]{value, Feature.RESOLVE.name()}, null);
+            }
+        } else if (f == Feature.FILES) {
+            Util.validateUrisSyntax(value.split(";"));
+        }
+    }
 }
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,7 @@
     @Test
     public void specifyCatalogViaSysProps() {
         setSystemProperty(FEATURE_FILES,
-                getCatalogPath("specifyCatalog-sysProps.xml"));
+                getCatalogPath("specifyCatalog-sysProps.xml").toASCIIString());
 
         checkResolutionOnEntityResolver(catalogResolver((String[]) null),
                 "http://local/base/dtd/docSysPropsSys.dtd");
@@ -107,6 +107,6 @@
     }
 
     private static CatalogFeatures createFeature(String catalogName) {
-        return builder().with(FILES, getCatalogPath(catalogName)).build();
+        return builder().with(FILES, getCatalogPath(catalogName).toASCIIString()).build();
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/dummy.xml	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,1 @@
+<dummy />
--- a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,16 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
-
 import javax.xml.catalog.CatalogFeatures;
 import javax.xml.catalog.CatalogManager;
 import javax.xml.catalog.CatalogResolver;
-
 import jaxp.library.JAXPTestUtilities;
 
 /*
@@ -115,20 +114,20 @@
     }
 
     // Gets the paths of the specified catalogs.
-    private static String[] getCatalogPaths(String... catalogNames) {
+    private static URI[] getCatalogPaths(String... catalogNames) {
         return catalogNames == null
                 ? null
                 : Stream.of(catalogNames).map(
                         catalogName -> getCatalogPath(catalogName)).collect(
-                                Collectors.toList()).toArray(new String[0]);
+                                Collectors.toList()).toArray(new URI[0]);
     }
 
     // Gets the paths of the specified catalogs.
-    static String getCatalogPath(String catalogName) {
+    static URI getCatalogPath(String catalogName) {
         return catalogName == null
                 ? null
-                : JAXPTestUtilities.getPathByClassName(CatalogTestUtils.class, "catalogFiles")
-                        + catalogName;
+                : Paths.get(JAXPTestUtilities.getPathByClassName(CatalogTestUtils.class, "catalogFiles")
+                        + catalogName).toUri();
     }
 
     /* ********** jaxp.properties ********** */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JarUtils.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jaxp.library;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * This class consists exclusively of static utility methods that are useful
+ * for creating and manipulating JAR files.
+ */
+
+public final class JarUtils {
+    private JarUtils() { }
+
+    /**
+     * Creates a JAR file.
+     *
+     * Equivalent to {@code jar cfm <jarfile> <manifest> -C <dir> file...}
+     *
+     * The input files are resolved against the given directory. Any input
+     * files that are directories are processed recursively.
+     */
+    public static void createJarFile(Path jarfile, Manifest man, Path dir, Path... file)
+        throws IOException
+    {
+        // create the target directory
+        Path parent = jarfile.getParent();
+        if (parent != null)
+            Files.createDirectories(parent);
+
+        List<Path> entries = new ArrayList<>();
+        for (Path entry : file) {
+            Files.find(dir.resolve(entry), Integer.MAX_VALUE,
+                        (p, attrs) -> attrs.isRegularFile())
+                    .map(e -> dir.relativize(e))
+                    .forEach(entries::add);
+        }
+
+        try (OutputStream out = Files.newOutputStream(jarfile);
+             JarOutputStream jos = new JarOutputStream(out))
+        {
+            if (man != null) {
+                JarEntry je = new JarEntry(JarFile.MANIFEST_NAME);
+                jos.putNextEntry(je);
+                man.write(jos);
+                jos.closeEntry();
+            }
+
+            for (Path entry : entries) {
+                String name = toJarEntryName(entry);
+                jos.putNextEntry(new JarEntry(name));
+                Files.copy(dir.resolve(entry), jos);
+                jos.closeEntry();
+            }
+        }
+    }
+
+    /**
+     * Creates a JAR file.
+     *
+     * Equivalent to {@code jar cf <jarfile>  -C <dir> file...}
+     *
+     * The input files are resolved against the given directory. Any input
+     * files that are directories are processed recursively.
+     */
+    public static void createJarFile(Path jarfile, Path dir, Path... file)
+        throws IOException
+    {
+        createJarFile(jarfile, null, dir, file);
+    }
+
+    /**
+     * Creates a JAR file.
+     *
+     * Equivalent to {@code jar cf <jarfile> -C <dir> file...}
+     *
+     * The input files are resolved against the given directory. Any input
+     * files that are directories are processed recursively.
+     */
+    public static void createJarFile(Path jarfile, Path dir, String... input)
+        throws IOException
+    {
+        Path[] paths = Stream.of(input).map(Paths::get).toArray(Path[]::new);
+        createJarFile(jarfile, dir, paths);
+    }
+
+    /**
+     * Creates a JAR file from the contents of a directory.
+     *
+     * Equivalent to {@code jar cf <jarfile> -C <dir> .}
+     */
+    public static void createJarFile(Path jarfile, Path dir) throws IOException {
+        createJarFile(jarfile, dir, Paths.get("."));
+    }
+
+    /**
+     * Map a file path to the equivalent name in a JAR file
+     */
+    private static String toJarEntryName(Path file) {
+        Path normalized = file.normalize();
+        return normalized.subpath(0, normalized.getNameCount())  // drop root
+                .toString()
+                .replace(File.separatorChar, '/');
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/SimpleHttpServer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jaxp.library;
+
+import com.sun.net.httpserver.Headers;
+import com.sun.net.httpserver.HttpContext;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * A simple HTTP Server
+ */
+public class SimpleHttpServer {
+    HttpServer _httpserver;
+    ExecutorService _executor;
+
+    String _address;
+
+    String _context, _docroot;
+    int _port;
+
+    public SimpleHttpServer(String context, String docroot) {
+        //let the system pick up an ephemeral port in a bind operation
+        this(0, context, docroot);
+    }
+
+    public SimpleHttpServer(int port, String context, String docroot) {
+        _port = port;
+        _context = context;
+        _docroot = docroot;
+    }
+
+    public void start() {
+        MyHttpHandler handler = new MyHttpHandler(_docroot);
+        InetSocketAddress addr = new InetSocketAddress(_port);
+        try {
+            _httpserver = HttpServer.create(addr, 0);
+        } catch (IOException ex) {
+            throw new RuntimeException("cannot create httpserver", ex);
+        }
+
+        //TestHandler is mapped to /test
+        HttpContext ctx = _httpserver.createContext(_context, handler);
+
+        _executor = Executors.newCachedThreadPool();
+        _httpserver.setExecutor(_executor);
+        _httpserver.start();
+
+        _address = "http://localhost:" + _httpserver.getAddress().getPort();
+    }
+
+    public void stop() {
+        _httpserver.stop(2);
+        _executor.shutdown();
+    }
+
+    public String getAddress() {
+        return _address;
+    }
+
+    static class MyHttpHandler implements HttpHandler {
+
+        String _docroot;
+
+        public MyHttpHandler(String docroot) {
+            _docroot = docroot;
+        }
+
+        public void handle(HttpExchange t)
+                throws IOException {
+            InputStream is = t.getRequestBody();
+            Headers map = t.getRequestHeaders();
+            Headers rmap = t.getResponseHeaders();
+            OutputStream os = t.getResponseBody();
+            URI uri = t.getRequestURI();
+            String path = uri.getPath();
+
+
+            while (is.read() != -1) ;
+            is.close();
+
+            File f = new File(_docroot, path);
+            if (!f.exists()) {
+                notfound(t, path);
+                return;
+            }
+
+            String method = t.getRequestMethod();
+            if (method.equals("HEAD")) {
+                rmap.set("Content-Length", Long.toString(f.length()));
+                t.sendResponseHeaders(200, -1);
+                t.close();
+            } else if (!method.equals("GET")) {
+                t.sendResponseHeaders(405, -1);
+                t.close();
+                return;
+            }
+
+            if (path.endsWith(".html") || path.endsWith(".htm")) {
+                rmap.set("Content-Type", "text/html");
+            } else {
+                rmap.set("Content-Type", "text/plain");
+            }
+
+            t.sendResponseHeaders (200, f.length());
+
+            FileInputStream fis = new FileInputStream(f);
+            int count = 0;
+            try {
+                byte[] buf = new byte[16 * 1024];
+                int len;
+                while ((len = fis.read(buf)) != -1) {
+                    os.write(buf, 0, len);
+                    count += len;
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            fis.close();
+            os.close();
+        }
+
+        void moved(HttpExchange t) throws IOException {
+            Headers req = t.getRequestHeaders();
+            Headers map = t.getResponseHeaders();
+            URI uri = t.getRequestURI();
+            String host = req.getFirst("Host");
+            String location = "http://" + host + uri.getPath() + "/";
+            map.set("Content-Type", "text/html");
+            map.set("Location", location);
+            t.sendResponseHeaders(301, -1);
+            t.close();
+        }
+
+        void notfound(HttpExchange t, String p) throws IOException {
+            t.getResponseHeaders().set("Content-Type", "text/html");
+            t.sendResponseHeaders(404, 0);
+            OutputStream os = t.getResponseBody();
+            String s = "<h2>File not found</h2>";
+            s = s + p + "<p>";
+            os.write(s.getBytes());
+            os.close();
+            t.close();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogAccessTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package catalog;
+
+import java.net.URI;
+import javax.xml.catalog.CatalogFeatures;
+import javax.xml.catalog.CatalogManager;
+import javax.xml.catalog.CatalogResolver;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+import org.xml.sax.InputSource;
+import static jaxp.library.JAXPTestUtilities.tryRunWithAllPerm;
+
+/*
+ * @test
+ * @bug 8171243
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm -DrunSecMngr=true catalog.CatalogAccessTest
+ * @summary the Catalog API grants no privilege to external resources. This test
+ * verifies that SecurityException will be thrown if access to resources is denied
+ * by the security manager.
+ */
+@Listeners({jaxp.library.BasePolicy.class})
+public class CatalogAccessTest {
+    static final CatalogFeatures FEATURES = CatalogFeatures.builder().
+            with(CatalogFeatures.Feature.PREFER, "system").build();
+
+    /*
+     * Verifies that the SecurityException is thrown if access to the resource is
+     * denied by the security manager.
+     */
+    @Test(dataProvider = "accessTest", expectedExceptions = SecurityException.class)
+    public void testSecurity(String cfile, String sysId, String pubId) throws Exception {
+        CatalogResolver cr = CatalogManager.catalogResolver(FEATURES, URI.create(cfile));
+        InputSource is = cr.resolveEntity(pubId, sysId);
+        Assert.fail("Failed to throw SecurityException");
+    }
+
+    /*
+        DataProvider: used for SecurityException testing
+        Data columns:
+        catalog uri, systemId, publicId
+     */
+    @DataProvider(name = "accessTest")
+    Object[][] getDataForAccessTest() throws Exception {
+        String systemId = "http://www.sys00test.com/rewrite.dtd";
+        String publicId = "PUB-404";
+        String urlFile = tryRunWithAllPerm(() ->
+                getClass().getResource("rewriteSystem_id.xml").toExternalForm());
+        return new Object[][]{
+            {urlFile, systemId, publicId}
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogFileInputTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package catalog;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import static java.nio.file.StandardOpenOption.APPEND;
+import static java.nio.file.StandardOpenOption.CREATE;
+import javax.xml.catalog.Catalog;
+import javax.xml.catalog.CatalogException;
+import javax.xml.catalog.CatalogFeatures;
+import javax.xml.catalog.CatalogManager;
+import javax.xml.catalog.CatalogResolver;
+import static jaxp.library.JAXPTestUtilities.getSystemProperty;
+import jaxp.library.JarUtils;
+import jaxp.library.SimpleHttpServer;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+import org.xml.sax.InputSource;
+
+/*
+ * @test
+ * @bug 8151154 8171243
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng/othervm catalog.CatalogFileInputTest
+ * @summary Verifies that the Catalog API accepts valid URIs only;
+            Verifies that the CatalogFeatures' builder throws
+ *          IllegalArgumentException on invalid file inputs.
+ *          This test was splitted from CatalogTest.java due to
+ *          JDK-8168968, it has to only run without SecurityManager
+ *          because an ACE will be thrown for invalid path.
+ */
+@Listeners({jaxp.library.FilePolicy.class, jaxp.library.NetAccessPolicy.class})
+public class CatalogFileInputTest extends CatalogSupportBase {
+
+    static final CatalogFeatures FEATURES = CatalogFeatures.builder().
+            with(CatalogFeatures.Feature.PREFER, "system").build();
+    static String USER_DIR = getSystemProperty("user.dir");
+    static String CLS_DIR = getSystemProperty("test.classes");
+    static String SRC_DIR = System.getProperty("test.src");
+    static String JAR_CONTENT = "META-INF";
+    final static String SCHEME_JARFILE = "jar:";
+    static final String REMOTE_FILE_LOCATION = "/jar/META-INF";
+    static final String DOCROOT = SRC_DIR;
+    static final String TESTCONTEXT = REMOTE_FILE_LOCATION;  //mapped to local file path
+    SimpleHttpServer _httpserver;
+    String _remoteFilePath;
+
+    /*
+     * Initializing fields
+     */
+    @BeforeClass
+    public void setUpClass() throws Exception {
+        super.setUp();
+
+        // set up HttpServer
+        _httpserver = new SimpleHttpServer(TESTCONTEXT, DOCROOT);
+        _httpserver.start();
+        _remoteFilePath = _httpserver.getAddress() + REMOTE_FILE_LOCATION;
+
+    }
+
+    @AfterClass
+    protected void tearDown() throws Exception {
+        if (_httpserver != null) {
+            _httpserver.stop();
+        }
+    }
+
+    /*
+     * Verifies that the Catalog can be created with file system paths including JAR
+     * and http URL, and used to resolve a systemId as expected.
+     */
+    @Test(dataProvider = "acceptedURI")
+    public void testMatch(String uri, String sysId, String pubId,
+            String expectedId, String msg) throws Exception {
+        CatalogResolver cr = CatalogManager.catalogResolver(FEATURES, URI.create(uri));
+        InputSource is = cr.resolveEntity(pubId, sysId);
+        Assert.assertNotNull(is, msg);
+        Assert.assertEquals(expectedId, is.getSystemId(), msg);
+    }
+
+    @Test(dataProvider = "invalidCatalog")
+    public void testEmptyCatalog(String uri, String publicId, String msg) {
+        Catalog c = CatalogManager.catalog(FEATURES, uri != null? URI.create(uri) : null);
+        Assert.assertNull(c.matchSystem(publicId), msg);
+    }
+
+    @Test(dataProvider = "invalidCatalog", expectedExceptions = CatalogException.class)
+    public void testCatalogResolverWEmptyCatalog(String uri, String publicId, String msg) {
+        CatalogResolver cr = CatalogManager.catalogResolver(
+                CatalogFeatures.builder().with(CatalogFeatures.Feature.RESOLVE, "strict").build(),
+                uri != null? URI.create(uri) : null);
+        InputSource is = cr.resolveEntity(publicId, "");
+    }
+
+    @Test(dataProvider = "invalidCatalog")
+    public void testCatalogResolverWEmptyCatalog1(String uri, String publicId, String msg) {
+        CatalogResolver cr = CatalogManager.catalogResolver(
+                CatalogFeatures.builder().with(CatalogFeatures.Feature.RESOLVE, "continue").build(),
+                uri != null? URI.create(uri) : null);
+        Assert.assertNull(cr.resolveEntity(publicId, ""), msg);
+    }
+
+    @Test(dataProvider = "invalidInput", expectedExceptions = IllegalArgumentException.class)
+    public void testFileInput(String file) {
+        CatalogFeatures features = CatalogFeatures.builder()
+            .with(CatalogFeatures.Feature.FILES, file)
+            .build();
+    }
+
+    @Test(dataProvider = "invalidInput", expectedExceptions = IllegalArgumentException.class)
+    public void testInvalidUri(String file) {
+        CatalogResolver cr = CatalogManager.catalogResolver(FEATURES, file != null? URI.create(file) : null);
+    }
+
+    @Test(dataProvider = "invalidInput", expectedExceptions = IllegalArgumentException.class)
+    public void testInvalidUri1(String file) {
+        Catalog c = CatalogManager.catalog(FEATURES, file != null? URI.create(file) : null);
+        System.err.println("Catalog =" + c);
+    }
+
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void testNullFileInput() {
+        CatalogFeatures features = CatalogFeatures.builder()
+            .with(CatalogFeatures.Feature.FILES, null)
+            .build();
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void testNullUri() {
+        URI uri = null;
+        CatalogResolver cr = CatalogManager.catalogResolver(FEATURES, uri);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void testNullUri1() {
+        URI uri = null;
+        Catalog c = CatalogManager.catalog(FEATURES, uri);
+    }
+
+    String systemId = "http://www.sys00test.com/rewrite.dtd";
+    String publicId = "PUB-404";
+    String expected = "http://www.groupxmlbase.com/dtds/rewrite.dtd";
+    String errMsg = "Relative rewriteSystem with xml:base at group level failed";
+
+    /*
+        DataProvider: used to verify CatalogResolver's resolveEntity function.
+        Data columns:
+        catalog, systemId, publicId, expectedUri, msg
+     */
+    @DataProvider(name = "acceptedURI")
+    Object[][] getData() throws Exception {
+        String filename = "rewriteSystem_id.xml";
+        String urlFile = getClass().getResource(filename).toExternalForm();
+        String urlHttp = _remoteFilePath + "/jax-ws-catalog.xml";
+        String remoteXSD = _remoteFilePath + "/catalog/ws-addr.xsd";
+        File file = new File(CLS_DIR + "/JDK8171243.jar!/META-INF/jax-ws-catalog.xml");
+        String jarPath = SCHEME_JARFILE + file.toURI().toString();
+        String xsd = jarPath.substring(0, jarPath.lastIndexOf("/")) + "/catalog/ws-addr.xsd";
+
+        // create JAR file
+        try {
+            JarUtils.createJarFile(Paths.get(CLS_DIR + "/JDK8171243.jar"),
+                    Paths.get(SRC_DIR + "/jar"), JAR_CONTENT);
+        } catch (IOException ex) {
+            Assert.fail("Failed to create JAR: " + ex.getMessage());
+        }
+
+        return new Object[][]{
+            // URL
+            {urlFile, systemId, publicId, expected, errMsg},
+            {urlHttp, "http://www.w3.org/2006/03/addressing/ws-addr.xsd", "", remoteXSD, "http test failed."},
+            // JAR file
+            {jarPath, "http://www.w3.org/2006/03/addressing/ws-addr.xsd", "", xsd, "jar file test failed."},
+        };
+    }
+
+    /*
+     *  DataProvider: invalid catalog result in empty catalog
+     *  Note: the difference from invalidInput is that invalidInput is syntactically
+     *  rejected with an IAE.
+     */
+    @DataProvider(name = "invalidCatalog")
+    public Object[][] getInvalidCatalog() throws Exception {
+        String catalogUri = getClass().getResource("catalog_invalid.xml").toExternalForm();
+        return new Object[][]{
+            {catalogUri, "-//W3C//DTD XHTML 1.0 Strict//EN",
+                "The catalog is invalid, attempting to match the public entry shall return null."}
+        };
+    }
+
+    /*
+     *  DataProvider: a list of invalid inputs, expects IAE
+     *  Note: exclude null since NPE would have been expected
+     */
+    @DataProvider(name = "invalidInput")
+    public Object[][] getFiles() throws Exception {
+        String filename = "rewriteSystem_id.xml";
+        copyFile(Paths.get(SRC_DIR + "/" + filename), Paths.get(filename));
+        String absolutePath = getClass().getResource(filename).getFile();
+
+        return new Object[][]{
+            {""},
+            {"file:a/b\\c"},
+            {"file:/../../.."},
+            {"c:/te:t"},
+            {"c:/te?t"},
+            {"c/te*t"},
+            {"in|valid.txt"},
+            {"shema:invalid.txt"},
+            // relative file path
+            {filename},
+            // absolute file path
+            {absolutePath}
+        };
+    }
+
+    /*
+       DataProvider: a list of invalid inputs
+     */
+    @DataProvider(name = "nullTest")
+    public Object[][] getNull() throws Exception {
+
+        return new Object[][]{
+            {null},
+        };
+    }
+
+    void copyFile(Path src, Path target) throws Exception {
+
+        try (InputStream in = Files.newInputStream(src);
+                BufferedReader reader
+                = new BufferedReader(new InputStreamReader(in));
+                OutputStream out = new BufferedOutputStream(
+                        Files.newOutputStream(target, CREATE, APPEND));
+                BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out))) {
+            String line = null;
+            while ((line = reader.readLine()) != null) {
+                bw.write(line);
+            }
+        } catch (IOException x) {
+            throw new Exception(x.getMessage());
+        }
+    }
+}
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogInvalidPathTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package catalog;
-
-import javax.xml.catalog.CatalogFeatures;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/*
- * @test
- * @bug 8151154
- * @run testng/othervm catalog.CatalogInvalidPathTest
- * @summary Verifies that the CatalogFeatures' builder throws
- *          IllegalArgumentException on invalid file inputs.
- *          This test was splitted from CatalogTest.java due to
- *          JDK-8168968, it has to only run without SecurityManager
- *          because an ACE will be thrown for invalid path.
- */
-public class CatalogInvalidPathTest {
-    /*
-       DataProvider: for testing the verification of file paths by
-                     the CatalogFeatures builder
-     */
-    @DataProvider(name = "invalidPaths")
-    public Object[][] getFiles() {
-        return new Object[][]{
-            {null},
-            {""},
-            {"file:a/b\\c"},
-            {"file:/../../.."},
-            {"c:/te:t"},
-            {"c:/te?t"},
-            {"c/te*t"},
-            {"in|valid.txt"},
-            {"shema:invalid.txt"},
-        };
-    }
-
-    @Test(dataProvider = "invalidPaths", expectedExceptions = IllegalArgumentException.class)
-    public void testFileInput(String file) {
-        CatalogFeatures features = CatalogFeatures.builder()
-            .with(CatalogFeatures.Feature.FILES, file)
-            .build();
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,13 @@
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
+import java.nio.file.Paths;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
 import javax.xml.XMLConstants;
 import javax.xml.catalog.CatalogFeatures;
 import javax.xml.catalog.CatalogResolver;
@@ -133,8 +140,8 @@
         dtd_system = filepath + "system.dtd";
         dtd_systemResolved = "<!ENTITY system \"resolved by an EntityHandler, rather than a Catalog\">";
 
-        xml_catalog = filepath + "CatalogSupport.xml";
-        xml_bogus_catalog = filepath + "CatalogSupport_bogus.xml";
+        xml_catalog = Paths.get(filepath + "CatalogSupport.xml").toUri().toASCIIString();
+        xml_bogus_catalog = Paths.get(filepath + "CatalogSupport_bogus.xml").toUri().toASCIIString();
 
         xml_xInclude = "<?xml version=\"1.0\"?>\n" +
             "<xinclude:include xmlns:xinclude=\"http://www.w3.org/2001/XInclude\"\n" +
@@ -997,4 +1004,35 @@
             return null;
         }
     }
+
+    /**
+     * Simple policy implementation that grants a set of permissions to all code
+     * sources and protection domains.
+     */
+    static class SimplePolicy extends Policy {
+
+        private final Permissions perms;
+
+        public SimplePolicy(Permission... permissions) {
+            perms = new Permissions();
+            for (Permission permission : permissions) {
+                perms.add(permission);
+            }
+        }
+
+        @Override
+        public PermissionCollection getPermissions(CodeSource cs) {
+            return perms;
+        }
+
+        @Override
+        public PermissionCollection getPermissions(ProtectionDomain pd) {
+            return perms;
+        }
+
+        @Override
+        public boolean implies(ProtectionDomain pd, Permission p) {
+            return perms.implies(p);
+        }
+    }
 }
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,17 +22,14 @@
  */
 package catalog;
 
-import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
-import static jaxp.library.JAXPTestUtilities.setSystemProperty;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.net.URI;
 import java.nio.file.Paths;
-
 import javax.xml.XMLConstants;
 import javax.xml.catalog.Catalog;
 import javax.xml.catalog.CatalogException;
@@ -55,7 +52,8 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
-
+import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
+import static jaxp.library.JAXPTestUtilities.setSystemProperty;
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
@@ -95,10 +93,10 @@
      * CatalogException is thrown.
      */
     @Test(dataProvider = "getFeatures", expectedExceptions = CatalogException.class)
-    public void testCircularRef(CatalogFeatures cf, String xml) {
+    public void testCircularRef(CatalogFeatures cf, String xml) throws Exception {
         CatalogResolver catalogResolver = CatalogManager.catalogResolver(
                 cf,
-                getClass().getResource(xml).getFile());
+                getClass().getResource(xml).toURI());
         catalogResolver.resolve("anyuri", "");
     }
 
@@ -108,14 +106,14 @@
      */
     @DataProvider(name = "getFeatures")
     public Object[][] getFeatures() {
-
+        String self = "catalogReferCircle-itself.xml";
+        String left = "catalogReferCircle-left.xml";
         return new Object[][]{
-            {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(),
-                "catalogReferCircle-itself.xml"},
-            {CatalogFeatures.defaults(), "catalogReferCircle-itself.xml"},
-            {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(),
-                "catalogReferCircle-left.xml"},
-            {CatalogFeatures.defaults(), "catalogReferCircle-left.xml"},};
+            {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(), self},
+            {CatalogFeatures.defaults(), self},
+            {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(), left},
+            {CatalogFeatures.defaults(), left}
+        };
     }
 
     /*
@@ -134,7 +132,7 @@
      * Expected: the parser returns the expected string.
     */
     @Test(dataProvider = "supportXMLResolver")
-    public void supportEntityResolver(String catalogFile, String xml, String expected) throws Exception {
+    public void supportEntityResolver(URI catalogFile, String xml, String expected) throws Exception {
         String xmlSource = getClass().getResource(xml).getFile();
 
         CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile);
@@ -150,7 +148,7 @@
      * Expected: the parser returns the expected string.
     */
     @Test(dataProvider = "supportXMLResolver")
-    public void supportXMLResolver(String catalogFile, String xml, String expected) throws Exception {
+    public void supportXMLResolver(URI catalogFile, String xml, String expected) throws Exception {
         String xmlSource = getClass().getResource(xml).getFile();
 
         CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile);
@@ -159,7 +157,7 @@
         xifactory.setProperty(XMLInputFactory.IS_COALESCING, true);
         xifactory.setProperty(XMLInputFactory.RESOLVER, cr);
         File file = new File(xmlSource);
-        String systemId = file.toURI().toString();
+        String systemId = file.toURI().toASCIIString();
         InputStream entityxml = new FileInputStream(file);
         XMLStreamReader streamReader = xifactory.createXMLStreamReader(systemId, entityxml);
         String result = null;
@@ -183,7 +181,7 @@
      * Fail: throws Exception if references are not resolved (by the CatalogResolver)
     */
     @Test(dataProvider = "supportLSResourceResolver")
-    public void supportLSResourceResolver(String catalogFile, Source schemaSource) throws SAXException {
+    public void supportLSResourceResolver(URI catalogFile, Source schemaSource) throws SAXException {
 
         CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile);
 
@@ -199,7 +197,7 @@
      * Fail: throws Exception if references are not resolved (by the CatalogResolver)
     */
     @Test(dataProvider = "supportLSResourceResolver1")
-    public void supportLSResourceResolver1(String catalogFile, Source source) throws Exception {
+    public void supportLSResourceResolver1(URI catalogFile, Source source) throws Exception {
 
         CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile);
 
@@ -215,7 +213,7 @@
      * Fail: throws Exception if references are not resolved (by the CatalogResolver)
     */
     @Test(dataProvider = "supportURIResolver")
-    public void supportURIResolver(String catalogFile, Source xsl, Source xml, String expected) throws Exception {
+    public void supportURIResolver(URI catalogFile, Source xsl, Source xml, String expected) throws Exception {
 
         CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile);
 
@@ -235,9 +233,9 @@
         catalog filepath, xml source file, expected result
      */
     @DataProvider(name = "supportXMLResolver")
-    public Object[][] supportXMLResolver() {
-        String catalogFile = getClass().getResource("catalog.xml").getFile();
-        String catalogFileUri = getClass().getResource("catalog_uri.xml").getFile();
+    public Object[][] supportXMLResolver() throws Exception {
+        URI catalogFile = getClass().getResource("catalog.xml").toURI();
+        URI catalogFileUri = getClass().getResource("catalog_uri.xml").toURI();
 
         return new Object[][]{
             {catalogFile, "system.xml", "Test system entry"},
@@ -263,9 +261,9 @@
         catalog filepath, schema source file
      */
     @DataProvider(name = "supportLSResourceResolver")
-    public Object[][] supportLSResourceResolver() {
-        String catalogFile = getClass().getResource("CatalogSupport.xml").getFile();
-        String catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").getFile();
+    public Object[][] supportLSResourceResolver() throws Exception {
+        URI catalogFile = getClass().getResource("CatalogSupport.xml").toURI();
+        URI catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").toURI();
 
         /*
          * XMLSchema.xsd has a reference to XMLSchema.dtd which in turn refers to
@@ -287,9 +285,9 @@
         catalog filepath, source file
      */
     @DataProvider(name = "supportLSResourceResolver1")
-    public Object[][] supportLSResourceResolver1() {
-        String catalogFile = getClass().getResource("CatalogSupport.xml").getFile();
-        String catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").getFile();
+    public Object[][] supportLSResourceResolver1() throws Exception {
+        URI catalogFile = getClass().getResource("CatalogSupport.xml").toURI();
+        URI catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").toURI();
 
         /*
          * val_test.xml has a reference to system.dtd and val_test.xsd
@@ -310,9 +308,9 @@
         catalog filepath, xsl source, xml source file
      */
     @DataProvider(name = "supportURIResolver")
-    public Object[][] supportURIResolver() {
-        String catalogFile = getClass().getResource("CatalogSupport.xml").getFile();
-        String catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").getFile();
+    public Object[][] supportURIResolver() throws Exception {
+        URI catalogFile = getClass().getResource("CatalogSupport.xml").toURI();
+        URI catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").toURI();
         SAXSource xslSource = new SAXSource(new InputSource(new File(xsl_doc).toURI().toASCIIString()));
 
         /*
@@ -353,8 +351,9 @@
      * other cases in that test.
      */
     @Test(dataProvider = "resolveUri")
-    public void testMatch1(String cFile, String href, String expectedFile, String expectedUri, String msg) {
-        String catalogFile = getClass().getResource(cFile).getFile();
+    public void testMatch1(String cFile, String href, String expectedFile,
+            String expectedUri, String msg) throws Exception {
+        URI catalogFile = getClass().getResource(cFile).toURI();
         CatalogResolver cur = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile);
         Source source = cur.resolve(href, null);
         Assert.assertNotNull(source, "Source returned is null");
@@ -368,15 +367,16 @@
      */
     @Test(dataProvider = "hierarchyOfCatFilesData")
     public void hierarchyOfCatFiles2(String systemId, String expectedUri) {
-        String file1 = getClass().getResource("first_cat.xml").getFile();
-        String file2 = getClass().getResource("second_cat.xml").getFile();
+        String file1 = getClass().getResource("first_cat.xml").toExternalForm();
+        String file2 = getClass().getResource("second_cat.xml").toExternalForm();
         String files = file1 + ";" + file2;
 
         try {
             setSystemProperty(KEY_FILES, files);
             CatalogResolver catalogResolver = CatalogManager.catalogResolver(CatalogFeatures.defaults());
             String sysId = catalogResolver.resolveEntity(null, systemId).getSystemId();
-            Assert.assertEquals(sysId, Paths.get(filepath + expectedUri).toUri().toString().replace("///", "/"), "System ID match not right");
+            Assert.assertEquals(sysId, Paths.get(filepath + expectedUri).toUri().toString().replace("///", "/"),
+                    "System ID match not right");
         } finally {
             clearSystemProperty(KEY_FILES);
         }
@@ -390,8 +390,9 @@
      * expected.
      */
     @Test(dataProvider = "resolveEntity")
-    public void testMatch1(String cfile, String prefer, String sysId, String pubId, String expectedUri, String expectedFile, String msg) {
-        String catalogFile = getClass().getResource(cfile).getFile();
+    public void testMatch1(String cfile, String prefer, String sysId, String pubId,
+            String expectedUri, String expectedFile, String msg) throws Exception {
+        URI catalogFile = getClass().getResource(cfile).toURI();
         CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).build();
         CatalogResolver catalogResolver = CatalogManager.catalogResolver(features, catalogFile);
         InputSource is = catalogResolver.resolveEntity(pubId, sysId);
@@ -406,9 +407,12 @@
      * results as expected.
      */
     @Test(dataProvider = "matchWithPrefer")
-    public void matchWithPrefer(String prefer, String cfile, String publicId, String systemId, String expected) {
-        String catalogFile = getClass().getResource(cfile).getFile();
-        Catalog c = CatalogManager.catalog(CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).build(), catalogFile);
+    public void matchWithPrefer(String prefer, String cfile, String publicId,
+            String systemId, String expected) throws Exception {
+        URI catalogFile = getClass().getResource(cfile).toURI();
+        Catalog c = CatalogManager.catalog(
+                CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).build(),
+                catalogFile);
         String result;
         if (publicId != null && publicId.length() > 0) {
             result = c.matchPublic(publicId);
@@ -430,8 +434,9 @@
      *                  system entry is found.
      */
     @Test(dataProvider = "resolveWithPrefer")
-    public void resolveWithPrefer(String prefer, String cfile, String publicId, String systemId, String expected) {
-        String catalogFile = getClass().getResource(cfile).getFile();
+    public void resolveWithPrefer(String prefer, String cfile, String publicId,
+            String systemId, String expected) throws Exception {
+        URI catalogFile = getClass().getResource(cfile).toURI();
         CatalogFeatures f = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).with(CatalogFeatures.Feature.RESOLVE, "ignore").build();
         CatalogResolver catalogResolver = CatalogManager.catalogResolver(f, catalogFile);
         String result = catalogResolver.resolveEntity(publicId, systemId).getSystemId();
@@ -445,8 +450,8 @@
      * be loaded is determined by the defer attribute.
      */
     @Test(dataProvider = "invalidAltCatalogs", expectedExceptions = CatalogException.class)
-    public void testDeferAltCatalogs(String file) {
-        String catalogFile = getClass().getResource(file).getFile();
+    public void testDeferAltCatalogs(String file) throws Exception {
+        URI catalogFile = getClass().getResource(file).toURI();
         CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "true").build();
         /*
           Since the defer attribute is set to false in the specified catalog file,
@@ -462,8 +467,8 @@
      * PREFER from Features API taking precedence over catalog file
      */
     @Test
-    public void testJDK8146237() {
-        String catalogFile = getClass().getResource("JDK8146237_catalog.xml").getFile();
+    public void testJDK8146237() throws Exception {
+        URI catalogFile = getClass().getResource("JDK8146237_catalog.xml").toURI();
 
         try {
             CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, "system").build();
@@ -482,8 +487,8 @@
        Verifies that the resulting systemId does not contain duplicate slashes
     */
     @Test
-    public void testRewriteSystem() {
-        String catalog = getClass().getResource("rewriteCatalog.xml").getFile();
+    public void testRewriteSystem() throws Exception {
+        URI catalog = getClass().getResource("rewriteCatalog.xml").toURI();
 
         try {
             CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog);
@@ -500,8 +505,8 @@
        Verifies that the resulting systemId does not contain duplicate slashes
     */
     @Test
-    public void testRewriteUri() {
-        String catalog = getClass().getResource("rewriteCatalog.xml").getFile();
+    public void testRewriteUri() throws Exception {
+        URI catalog = getClass().getResource("rewriteCatalog.xml").toURI();
 
         try {
 
@@ -519,18 +524,18 @@
     */
     @Test(expectedExceptions = NullPointerException.class)
     public void testFeatureNull() {
-        CatalogResolver resolver = CatalogManager.catalogResolver(null, "");
+        CatalogResolver resolver = CatalogManager.catalogResolver(null, null);
 
     }
 
     /*
        @bug 8144966
-       Verifies that passing null as the path will result in a NPE.
+       Verifies that passing null as the URI will result in a NPE.
     */
     @Test(expectedExceptions = NullPointerException.class)
     public void testPathNull() {
-        String path = null;
-        CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), path);
+        URI uri = null;
+        CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), uri);
     }
 
     /*
@@ -540,10 +545,11 @@
     that matches the expected value.
      */
     @Test(dataProvider = "catalog")
-    public void testCatalogResolver(String test, String expected, String catalogFile, String xml, SAXParser saxParser) {
-        String catalog = null;
+    public void testCatalogResolver(String test, String expected, String catalogFile,
+            String xml, SAXParser saxParser) throws Exception {
+        URI catalog = null;
         if (catalogFile != null) {
-            catalog = getClass().getResource(catalogFile).getFile();
+            catalog = getClass().getResource(catalogFile).toURI();
         }
         String url = getClass().getResource(xml).getFile();
         try {
@@ -565,8 +571,8 @@
     catalog is provided, the resolver will throw an exception by default.
     */
     @Test
-    public void testInvalidCatalog() {
-        String catalog = getClass().getResource("catalog_invalid.xml").getFile();
+    public void testInvalidCatalog() throws Exception {
+        URI catalog = getClass().getResource("catalog_invalid.xml").toURI();
 
         String test = "testInvalidCatalog";
         try {
@@ -590,7 +596,7 @@
     */
     @Test
     public void testIgnoreInvalidCatalog() {
-        String catalog = getClass().getResource("catalog_invalid.xml").getFile();
+        String catalog = getClass().getResource("catalog_invalid.xml").toExternalForm();
         CatalogFeatures f = CatalogFeatures.builder()
                 .with(Feature.FILES, catalog)
                 .with(Feature.PREFER, "public")
@@ -600,7 +606,7 @@
 
         String test = "testInvalidCatalog";
         try {
-            CatalogResolver resolver = CatalogManager.catalogResolver(f, "");
+            CatalogResolver resolver = CatalogManager.catalogResolver(f);
             String actualSystemId = resolver.resolveEntity(null, "http://remote/xml/dtd/sys/alice/docAlice.dtd").getSystemId();
             System.out.println("testIgnoreInvalidCatalog: expected [null]");
             System.out.println("testIgnoreInvalidCatalog: expected [null]");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/MANIFEST.MF	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Created-By: 9-ea (Oracle Corporation)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/catalog/ws-addr.xsd	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    W3C XML Schema defined in the Web Services Addressing 1.0 specification
+    http://www.w3.org/TR/ws-addr-core
+
+   Copyright © 2005 World Wide Web Consortium,
+
+   (Massachusetts Institute of Technology, European Research Consortium for
+   Informatics and Mathematics, Keio University). All Rights Reserved. This
+   work is distributed under the W3C® Software License [1] in the hope that
+   it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+   [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+   $Id: ws-addr.xsd,v 1.2 2008/07/23 13:38:16 plehegar Exp $
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.w3.org/2005/08/addressing" targetNamespace="http://www.w3.org/2005/08/addressing" blockDefault="#all" elementFormDefault="qualified" finalDefault="" attributeFormDefault="unqualified">
+	
+	<!-- Constructs from the WS-Addressing Core -->
+
+	<xs:element name="EndpointReference" type="tns:EndpointReferenceType"/>
+	<xs:complexType name="EndpointReferenceType" mixed="false">
+		<xs:sequence>
+			<xs:element name="Address" type="tns:AttributedURIType"/>
+			<xs:element ref="tns:ReferenceParameters" minOccurs="0"/>
+			<xs:element ref="tns:Metadata" minOccurs="0"/>
+			<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+		</xs:sequence>
+		<xs:anyAttribute namespace="##other" processContents="lax"/>
+	</xs:complexType>
+	
+	<xs:element name="ReferenceParameters" type="tns:ReferenceParametersType"/>
+	<xs:complexType name="ReferenceParametersType" mixed="false">
+		<xs:sequence>
+			<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+		</xs:sequence>
+		<xs:anyAttribute namespace="##other" processContents="lax"/>
+	</xs:complexType>
+	
+	<xs:element name="Metadata" type="tns:MetadataType"/>
+	<xs:complexType name="MetadataType" mixed="false">
+		<xs:sequence>
+			<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+		</xs:sequence>
+		<xs:anyAttribute namespace="##other" processContents="lax"/>
+	</xs:complexType>
+	
+	<xs:element name="MessageID" type="tns:AttributedURIType"/>
+	<xs:element name="RelatesTo" type="tns:RelatesToType"/>
+	<xs:complexType name="RelatesToType" mixed="false">
+		<xs:simpleContent>
+			<xs:extension base="xs:anyURI">
+				<xs:attribute name="RelationshipType" type="tns:RelationshipTypeOpenEnum" use="optional" default="http://www.w3.org/2005/08/addressing/reply"/>
+				<xs:anyAttribute namespace="##other" processContents="lax"/>
+			</xs:extension>
+		</xs:simpleContent>
+	</xs:complexType>
+	
+	<xs:simpleType name="RelationshipTypeOpenEnum">
+		<xs:union memberTypes="tns:RelationshipType xs:anyURI"/>
+	</xs:simpleType>
+	
+	<xs:simpleType name="RelationshipType">
+		<xs:restriction base="xs:anyURI">
+			<xs:enumeration value="http://www.w3.org/2005/08/addressing/reply"/>
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<xs:element name="ReplyTo" type="tns:EndpointReferenceType"/>
+	<xs:element name="From" type="tns:EndpointReferenceType"/>
+	<xs:element name="FaultTo" type="tns:EndpointReferenceType"/>
+	<xs:element name="To" type="tns:AttributedURIType"/>
+	<xs:element name="Action" type="tns:AttributedURIType"/>
+
+	<xs:complexType name="AttributedURIType" mixed="false">
+		<xs:simpleContent>
+			<xs:extension base="xs:anyURI">
+				<xs:anyAttribute namespace="##other" processContents="lax"/>
+			</xs:extension>
+		</xs:simpleContent>
+	</xs:complexType>
+	
+	<!-- Constructs from the WS-Addressing SOAP binding -->
+
+	<xs:attribute name="IsReferenceParameter" type="xs:boolean"/>
+	
+	<xs:simpleType name="FaultCodesOpenEnumType">
+		<xs:union memberTypes="tns:FaultCodesType xs:QName"/>
+	</xs:simpleType>
+	
+	<xs:simpleType name="FaultCodesType">
+		<xs:restriction base="xs:QName">
+			<xs:enumeration value="tns:InvalidAddressingHeader"/>
+			<xs:enumeration value="tns:InvalidAddress"/>
+			<xs:enumeration value="tns:InvalidEPR"/>
+			<xs:enumeration value="tns:InvalidCardinality"/>
+			<xs:enumeration value="tns:MissingAddressInEPR"/>
+			<xs:enumeration value="tns:DuplicateMessageID"/>
+			<xs:enumeration value="tns:ActionMismatch"/>
+			<xs:enumeration value="tns:MessageAddressingHeaderRequired"/>
+			<xs:enumeration value="tns:DestinationUnreachable"/>
+			<xs:enumeration value="tns:ActionNotSupported"/>
+			<xs:enumeration value="tns:EndpointUnavailable"/>
+		</xs:restriction>
+	</xs:simpleType>
+	
+	<xs:element name="RetryAfter" type="tns:AttributedUnsignedLongType"/>
+	<xs:complexType name="AttributedUnsignedLongType" mixed="false">
+		<xs:simpleContent>
+			<xs:extension base="xs:unsignedLong">
+				<xs:anyAttribute namespace="##other" processContents="lax"/>
+			</xs:extension>
+		</xs:simpleContent>
+	</xs:complexType>
+	
+	<xs:element name="ProblemHeaderQName" type="tns:AttributedQNameType"/>
+	<xs:complexType name="AttributedQNameType" mixed="false">
+		<xs:simpleContent>
+			<xs:extension base="xs:QName">
+				<xs:anyAttribute namespace="##other" processContents="lax"/>
+			</xs:extension>
+		</xs:simpleContent>
+	</xs:complexType>
+	
+	<xs:element name="ProblemIRI" type="tns:AttributedURIType"/>
+	
+	<xs:element name="ProblemAction" type="tns:ProblemActionType"/>
+	<xs:complexType name="ProblemActionType" mixed="false">
+		<xs:sequence>
+			<xs:element ref="tns:Action" minOccurs="0"/>
+			<xs:element name="SoapAction" minOccurs="0" type="xs:anyURI"/>
+		</xs:sequence>
+		<xs:anyAttribute namespace="##other" processContents="lax"/>
+	</xs:complexType>
+	
+</xs:schema>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/jax-ws-catalog.xml	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,4 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<catalog prefer="system" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+  <system systemId="http://www.w3.org/2006/03/addressing/ws-addr.xsd" uri="./catalog/ws-addr.xsd"/>
+</catalog>
\ No newline at end of file
--- a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -37,6 +37,7 @@
 
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
@@ -74,11 +75,30 @@
  * @run testng/othervm -DrunSecMngr=true transform.TransformerTest
  * @run testng/othervm transform.TransformerTest
  * @summary Transformer Tests
- * @bug 6272879 6305029 6505031 8150704 8162598 8169112 8169772
+ * @bug 6272879 6305029 6505031 8150704 8162598 8169112 8169631 8169772
  */
 @Listeners({jaxp.library.FilePolicy.class})
 public class TransformerTest {
 
+    // some global constants
+    private static final String LINE_SEPARATOR =
+        getSystemProperty("line.separator");
+
+    private static final String NAMESPACES =
+        "http://xml.org/sax/features/namespaces";
+
+    private static final String NAMESPACE_PREFIXES =
+        "http://xml.org/sax/features/namespace-prefixes";
+
+    private static abstract class TestTemplate {
+        protected void printSnippet(String title, String snippet) {
+            StringBuilder div = new StringBuilder();
+            for (int i = 0; i < title.length(); i++)
+                div.append("=");
+            System.out.println(title + "\n" + div + "\n" + snippet + "\n");
+        }
+    }
+
     /**
      * Reads the contents of the given file into a string.
      * WARNING: this method adds a final line feed even if the last line of the file doesn't contain one.
@@ -101,44 +121,7 @@
         }
     }
 
-    /**
-     * Utility method for testBug8162598().
-     * Provides a convenient way to check/assert the expected namespaces
-     * of a Node and its siblings.
-     *
-     * @param test
-     * The node to check
-     * @param nstest
-     * Expected namespace of the node
-     * @param nsb
-     * Expected namespace of the first sibling
-     * @param nsc
-     * Expected namespace of the first sibling of the first sibling
-     */
-    private void checkNodeNS8162598(Node test, String nstest, String nsb, String nsc) {
-        String testNodeName = test.getNodeName();
-        if (nstest == null) {
-            Assert.assertNull(test.getNamespaceURI(), "unexpected namespace for " + testNodeName);
-        } else {
-            Assert.assertEquals(test.getNamespaceURI(), nstest, "unexpected namespace for " + testNodeName);
-        }
-        Node b = test.getChildNodes().item(0);
-        if (nsb == null) {
-            Assert.assertNull(b.getNamespaceURI(), "unexpected namespace for " + testNodeName + "->b");
-        } else {
-            Assert.assertEquals(b.getNamespaceURI(), nsb, "unexpected namespace for " + testNodeName + "->b");
-        }
-        Node c = b.getChildNodes().item(0);
-        if (nsc == null) {
-            Assert.assertNull(c.getNamespaceURI(), "unexpected namespace for " + testNodeName + "->b->c");
-        } else {
-            Assert.assertEquals(c.getNamespaceURI(), nsc, "unexpected namespace for " + testNodeName + "->b->c");
-        }
-    }
-
     private class XMLReaderFor6305029 implements XMLReader {
-        private static final String NAMESPACES = "http://xml.org/sax/features/namespaces";
-        private static final String NAMESPACE_PREFIXES = "http://xml.org/sax/features/namespace-prefixes";
         private boolean namespaces = true;
         private boolean namespacePrefixes = false;
         private EntityResolver resolver;
@@ -235,8 +218,6 @@
      */
     @Test
     public final void testBug6272879() throws IOException, TransformerException {
-        final String LINE_SEPARATOR = getSystemProperty("line.separator");
-
         final String xsl =
                 "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + LINE_SEPARATOR +
                 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" + LINE_SEPARATOR +
@@ -349,9 +330,125 @@
         Assert.assertTrue(s.contains("map1key1value") && s.contains("map2key1value"));
     }
 
+    private static class Test8169631 extends TestTemplate {
+        private final static String xsl =
+            "<?xml version=\"1.0\"?>" + LINE_SEPARATOR +
+            "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">" + LINE_SEPARATOR +
+            "  <xsl:template match=\"/\">" + LINE_SEPARATOR +
+            "    <xsl:variable name=\"Counter\" select=\"count(//row)\"/>" + LINE_SEPARATOR +
+            "    <xsl:variable name=\"AttribCounter\" select=\"count(//@attrib)\"/>" + LINE_SEPARATOR +
+            "    <Counter><xsl:value-of select=\"$Counter\"/></Counter>" + LINE_SEPARATOR +
+            "    <AttribCounter><xsl:value-of select=\"$AttribCounter\"/></AttribCounter>" + LINE_SEPARATOR +
+            "  </xsl:template>" + LINE_SEPARATOR +
+            "</xsl:stylesheet>" + LINE_SEPARATOR;
+
+        private final static String sourceXml =
+            "<?xml version=\"1.0\"?>" + LINE_SEPARATOR +
+            "<envelope xmlns=\"http://www.sap.com/myns\" xmlns:sap=\"http://www.sap.com/myns\">" + LINE_SEPARATOR +
+            "  <sap:row sap:attrib=\"a\">1</sap:row>" + LINE_SEPARATOR +
+            "  <row attrib=\"b\">2</row>" + LINE_SEPARATOR +
+            "  <row sap:attrib=\"c\">3</row>" + LINE_SEPARATOR +
+            "</envelope>" + LINE_SEPARATOR;
+
+        /**
+         * Utility method to print out transformation result and check values.
+         *
+         * @param type
+         * Text describing type of transformation
+         * @param result
+         * Resulting output of transformation
+         * @param elementCount
+         * Counter of elements to check
+         * @param attribCount
+         * Counter of attributes to check
+         */
+        private void verifyResult(String type, String result, int elementCount,
+                                  int attribCount)
+        {
+            printSnippet("Result of transformation from " + type + ":",
+                         result);
+            Assert.assertEquals(
+                result.contains("<Counter>" + elementCount + "</Counter>"),
+                true, "Result of transformation from " + type +
+                " should have count of " + elementCount + " elements.");
+            Assert.assertEquals(
+                result.contains("<AttribCounter>" + attribCount +
+                "</AttribCounter>"), true, "Result of transformation from " +
+                type + " should have count of "+ attribCount + " attributes.");
+        }
+
+        public void run() throws IOException, TransformerException,
+            SAXException, ParserConfigurationException
+        {
+            printSnippet("Source:", sourceXml);
+
+            printSnippet("Stylesheet:", xsl);
+
+            // create default transformer (namespace aware)
+            TransformerFactory tf1 = TransformerFactory.newInstance();
+            ByteArrayInputStream bais = new ByteArrayInputStream(xsl.getBytes());
+            Transformer t1 = tf1.newTransformer(new StreamSource(bais));
+
+            // test transformation from stream source with namespace support
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            bais = new ByteArrayInputStream(sourceXml.getBytes());
+            t1.transform(new StreamSource(bais), new StreamResult(baos));
+            verifyResult("StreamSource with namespace support", baos.toString(), 0, 1);
+
+            // test transformation from DOM source with namespace support
+            bais.reset();
+            baos.reset();
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            dbf.setNamespaceAware(true);
+            Document doc = dbf.newDocumentBuilder().parse(new InputSource(bais));
+            t1.transform(new DOMSource(doc), new StreamResult(baos));
+            verifyResult("DOMSource with namespace support", baos.toString(), 0, 1);
+
+            // test transformation from DOM source without namespace support
+            bais.reset();
+            baos.reset();
+            dbf.setNamespaceAware(false);
+            doc = dbf.newDocumentBuilder().parse(new InputSource(bais));
+            t1.transform(new DOMSource(doc), new StreamResult(baos));
+            verifyResult("DOMSource without namespace support", baos.toString(), 3, 3);
+
+            // test transformation from SAX source with namespace support
+            bais.reset();
+            baos.reset();
+            SAXParserFactory spf = SAXParserFactory.newInstance();
+            spf.setNamespaceAware(true);
+            XMLReader xmlr = spf.newSAXParser().getXMLReader();
+            SAXSource saxS = new SAXSource(xmlr, new InputSource(bais));
+            t1.transform(saxS, new StreamResult(baos));
+            verifyResult("SAXSource with namespace support", baos.toString(), 0, 1);
+
+            // test transformation from SAX source without namespace support
+            bais.reset();
+            baos.reset();
+            spf.setNamespaceAware(false);
+            xmlr = spf.newSAXParser().getXMLReader();
+            saxS = new SAXSource(xmlr, new InputSource(bais));
+            t1.transform(saxS, new StreamResult(baos));
+            verifyResult("SAXSource without namespace support", baos.toString(), 3, 3);
+        }
+    }
+
+    /*
+     * @bug 8169631
+     * @summary Test combinations of namespace awareness settings on
+     *          XSL transformations
+     */
+    @Test
+    public final void testBug8169631() throws IOException, SAXException,
+        TransformerException, ParserConfigurationException
+    {
+        new Test8169631().run();
+    }
+
     /*
      * @bug 8150704
-     * @summary Test that XSL transformation with lots of temporary result trees will not run out of DTM IDs.
+     * @summary Test that XSL transformation with lots of temporary result
+     *          trees will not run out of DTM IDs.
      */
     @Test
     public final void testBug8150704() throws TransformerException, IOException {
@@ -375,16 +472,8 @@
         System.out.println("Passed.");
     }
 
-    /*
-     * @bug 8162598
-     * @summary Test XSLTC handling of namespaces, especially empty namespace definitions to reset the
-     *          default namespace
-     */
-    @Test
-    public final void testBug8162598() throws IOException, TransformerException {
-        final String LINE_SEPARATOR = getSystemProperty("line.separator");
-
-        final String xsl =
+    private static class Test8162598 extends TestTemplate {
+        private static final String xsl =
             "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + LINE_SEPARATOR +
             "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">" + LINE_SEPARATOR +
             "    <xsl:template match=\"/\">" + LINE_SEPARATOR +
@@ -402,39 +491,85 @@
             "    </xsl:template>" + LINE_SEPARATOR +
             "</xsl:stylesheet>";
 
-
-        final String sourceXml =
-                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><aaa></aaa>" + LINE_SEPARATOR;
+        private static final String sourceXml =
+            "<?xml version=\"1.0\" encoding=\"UTF-8\"?><aaa></aaa>" + LINE_SEPARATOR;
+        /**
+         * Utility method for testBug8162598().
+         * Provides a convenient way to check/assert the expected namespaces
+         * of a Node and its siblings.
+         *
+         * @param test
+         * The node to check
+         * @param nstest
+         * Expected namespace of the node
+         * @param nsb
+         * Expected namespace of the first sibling
+         * @param nsc
+         * Expected namespace of the first sibling of the first sibling
+         */
 
-        System.out.println("Stylesheet:");
-        System.out.println("=============================");
-        System.out.println(xsl);
-        System.out.println();
-
-        System.out.println("Source before transformation:");
-        System.out.println("=============================");
-        System.out.println(sourceXml);
-        System.out.println();
+        private void checkNodeNS(Node test, String nstest, String nsb, String nsc) {
+            String testNodeName = test.getNodeName();
+            if (nstest == null) {
+                Assert.assertNull(test.getNamespaceURI(), "unexpected namespace for " + testNodeName);
+            } else {
+                Assert.assertEquals(test.getNamespaceURI(), nstest, "unexpected namespace for " + testNodeName);
+            }
+            Node b = test.getChildNodes().item(0);
+            if (nsb == null) {
+                Assert.assertNull(b.getNamespaceURI(), "unexpected namespace for " + testNodeName + "->b");
+            } else {
+                Assert.assertEquals(b.getNamespaceURI(), nsb, "unexpected namespace for " + testNodeName + "->b");
+            }
+            Node c = b.getChildNodes().item(0);
+            if (nsc == null) {
+                Assert.assertNull(c.getNamespaceURI(), "unexpected namespace for " + testNodeName + "->b->c");
+            } else {
+                Assert.assertEquals(c.getNamespaceURI(), nsc, "unexpected namespace for " + testNodeName + "->b->c");
+            }
+        }
 
-        // transform to DOM result
-        TransformerFactory tf = TransformerFactory.newInstance();
-        Transformer t = tf.newTransformer(new StreamSource(new ByteArrayInputStream(xsl.getBytes())));
-        DOMResult result = new DOMResult();
-        t.transform(new StreamSource(new ByteArrayInputStream(sourceXml.getBytes())), result);
-        Document document = (Document)result.getNode();
+        public void run()  throws IOException, TransformerException {
+            printSnippet("Source:", sourceXml);
+
+            printSnippet("Stylesheet:", xsl);
+
+            // transform to DOM result
+            TransformerFactory tf = TransformerFactory.newInstance();
+            ByteArrayInputStream bais = new ByteArrayInputStream(xsl.getBytes());
+            Transformer t = tf.newTransformer(new StreamSource(bais));
+            DOMResult result = new DOMResult();
+            bais = new ByteArrayInputStream(sourceXml.getBytes());
+            t.transform(new StreamSource(bais), result);
+            Document document = (Document)result.getNode();
+
+            System.out.println("Result after transformation:");
+            System.out.println("============================");
+            OutputFormat format = new OutputFormat();
+            format.setIndenting(true);
+            new XMLSerializer(System.out, format).serialize(document);
+            System.out.println();
 
-        System.out.println("Result after transformation:");
-        System.out.println("============================");
-        OutputFormat format = new OutputFormat();
-        format.setIndenting(true);
-        new XMLSerializer(System.out, format).serialize(document);
-        System.out.println();
-        checkNodeNS8162598(document.getElementsByTagName("test1").item(0), "ns2", "ns2", null);
-        checkNodeNS8162598(document.getElementsByTagName("test2").item(0), "ns1", "ns2", null);
-        checkNodeNS8162598(document.getElementsByTagName("test3").item(0), null, null, null);
-        checkNodeNS8162598(document.getElementsByTagName("test4").item(0), null, null, null);
-        checkNodeNS8162598(document.getElementsByTagName("test5").item(0), "ns1", "ns1", null);
-        Assert.assertNull(document.getElementsByTagName("test6").item(0).getNamespaceURI(), "unexpected namespace for test6");
+            checkNodeNS(document.getElementsByTagName("test1").item(0), "ns2", "ns2", null);
+            checkNodeNS(document.getElementsByTagName("test2").item(0), "ns1", "ns2", null);
+            checkNodeNS(document.getElementsByTagName("test3").item(0), null, null, null);
+            checkNodeNS(document.getElementsByTagName("test4").item(0), null, null, null);
+            checkNodeNS(document.getElementsByTagName("test5").item(0), "ns1", "ns1", null);
+            Assert.assertNull(document.getElementsByTagName("test6").item(0).getNamespaceURI(),
+                "unexpected namespace for test6");
+        }
+    }
+
+    /*
+     * @bug 8162598
+     * @summary Test XSLTC handling of namespaces, especially empty namespace
+     *          definitions to reset the default namespace
+     */
+    @Test
+    public final void testBug8162598() throws IOException,
+        TransformerException
+    {
+        new Test8162598().run();
     }
 
     /**
--- a/jaxws/.hgtags	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxws/.hgtags	Tue Jan 24 00:30:25 2017 +0100
@@ -397,3 +397,5 @@
 72554d319b474b3636c7d02fe3c110254d111b1a jdk-9+149
 77e4e30d9d111272cd4a45a2203e8f570d40b12e jdk-9+150
 c48b4d4768b1c2b8fe5d1a844ca13732e5dfbe2a jdk-9+151
+6f8fb1cf7e5f61c40dcc3654f9a623c505f6de1f jdk-9+152
+7a532a9a227137155b905341d4b99939db51220e jdk-9+153
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,13 +47,13 @@
     public DetailEntry addDetailEntry(Name name) throws SOAPException {
         DetailEntry entry = createDetailEntry(name);
         addNode(entry);
-        return (DetailEntry) circumventBug5034339(entry);
+        return entry;
     }
 
     public DetailEntry addDetailEntry(QName qname) throws SOAPException {
         DetailEntry entry = createDetailEntry(qname);
         addNode(entry);
-        return (DetailEntry) circumventBug5034339(entry);
+        return entry;
     }
 
     protected SOAPElement addElement(Name name) throws SOAPException {
@@ -119,28 +119,4 @@
        return true;
    }
 
-    //overriding this method since the only two uses of this method
-    // are in ElementImpl and DetailImpl
-    //whereas the original base impl does the correct job for calls to it inside ElementImpl
-    // But it would not work for DetailImpl.
-    protected SOAPElement circumventBug5034339(SOAPElement element) {
-
-        Name elementName = element.getElementName();
-        if (!isNamespaceQualified(elementName)) {
-            String prefix = elementName.getPrefix();
-            String defaultNamespace = getNamespaceURI(prefix);
-            if (defaultNamespace != null) {
-                Name newElementName =
-                    NameImpl.create(
-                        elementName.getLocalName(),
-                        elementName.getPrefix(),
-                        defaultNamespace);
-                SOAPElement newElement = createDetailEntry(newElementName);
-                replaceChild(newElement, element);
-                return newElement;
-            }
-        }
-        return element;
-    }
-
 }
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -127,8 +127,11 @@
     }
 
     public SOAPElement addChildElement(String localName) throws SOAPException {
-        return (SOAPElement) addChildElement(
-            NameImpl.createFromUnqualifiedName(localName));
+        String nsUri = getNamespaceURI("");
+        Name name = (nsUri == null || nsUri.isEmpty())
+                ?  NameImpl.createFromUnqualifiedName(localName)
+                :  NameImpl.createFromQualifiedName(localName, nsUri);
+        return addChildElement(name);
     }
 
     public SOAPElement addChildElement(String localName, String prefix)
@@ -372,13 +375,13 @@
     protected SOAPElement addElement(Name name) throws SOAPException {
         SOAPElement newElement = createElement(name);
         addNode(newElement);
-        return circumventBug5034339(newElement);
+        return newElement;
     }
 
     protected SOAPElement addElement(QName name) throws SOAPException {
         SOAPElement newElement = createElement(name);
         addNode(newElement);
-        return circumventBug5034339(newElement);
+        return newElement;
     }
 
     protected SOAPElement createElement(Name name) {
@@ -1226,26 +1229,6 @@
         return !"".equals(name.getNamespaceURI());
     }
 
-    protected SOAPElement circumventBug5034339(SOAPElement element) {
-
-        Name elementName = element.getElementName();
-        if (!isNamespaceQualified(elementName)) {
-            String prefix = elementName.getPrefix();
-            String defaultNamespace = getNamespaceURI(prefix);
-            if (defaultNamespace != null) {
-                Name newElementName =
-                    NameImpl.create(
-                        elementName.getLocalName(),
-                        elementName.getPrefix(),
-                        defaultNamespace);
-                SOAPElement newElement = createElement(newElementName);
-                replaceChild(newElement, element);
-                return newElement;
-            }
-        }
-        return element;
-    }
-
     //TODO: This is a temporary SAAJ workaround for optimizing XWS
     // should be removed once the corresponding JAXP bug is fixed
     // It appears the bug will be fixed in JAXP 1.4 (not by Appserver 9 timeframe)
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,10 @@
 
 package com.sun.xml.internal.messaging.saaj.util.stax;
 
+import java.util.Iterator;
 import java.util.Arrays;
-import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedList;
 
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
@@ -42,6 +44,17 @@
 /**
  * SaajStaxWriter builds a SAAJ SOAPMessage by using XMLStreamWriter interface.
  *
+ * <p>
+ * Defers creation of SOAPElement until all the aspects of the name of the element are known.
+ * In some cases, the namespace uri is indicated only by the {@link #writeNamespace(String, String)} call.
+ * After opening an element ({@code writeStartElement}, {@code writeEmptyElement} methods), all attributes
+ * and namespace assignments are retained within {@link DeferredElement} object ({@code deferredElement} field).
+ * As soon as any other method than {@code writeAttribute}, {@code writeNamespace}, {@code writeDefaultNamespace}
+ * or {@code setNamespace} is called, the contents of {@code deferredElement} is transformed into new SOAPElement
+ * (which is appropriately inserted into the SOAPMessage under construction).
+ * This mechanism is necessary to fix JDK-8159058 issue.
+ * </p>
+ *
  * @author shih-chang.chen@oracle.com
  */
 public class SaajStaxWriter implements XMLStreamWriter {
@@ -49,6 +62,7 @@
     protected SOAPMessage soap;
     protected String envURI;
     protected SOAPElement currentElement;
+    protected DeferredElement deferredElement;
 
     static final protected String Envelope = "Envelope";
     static final protected String Header = "Header";
@@ -58,6 +72,7 @@
     public SaajStaxWriter(final SOAPMessage msg, String uri) throws SOAPException {
         soap = msg;
         this.envURI = uri;
+        this.deferredElement = new DeferredElement();
     }
 
     public SOAPMessage getSOAPMessage() {
@@ -70,11 +85,8 @@
 
     @Override
     public void writeStartElement(final String localName) throws XMLStreamException {
-        try {
-            currentElement = currentElement.addChildElement(localName);
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
-        }
+        currentElement = deferredElement.flushTo(currentElement);
+        deferredElement.setLocalName(localName);
     }
 
     @Override
@@ -84,8 +96,10 @@
 
     @Override
     public void writeStartElement(final String prefix, final String ln, final String ns) throws XMLStreamException {
-        try {
-            if (envURI.equals(ns)) {
+        currentElement = deferredElement.flushTo(currentElement);
+
+        if (envURI.equals(ns)) {
+            try {
                 if (Envelope.equals(ln)) {
                     currentElement = getEnvelope();
                     fixPrefix(prefix);
@@ -99,13 +113,16 @@
                     fixPrefix(prefix);
                     return;
                 }
+            } catch (SOAPException e) {
+                throw new XMLStreamException(e);
             }
-            currentElement = (prefix == null) ?
-                    currentElement.addChildElement(new QName(ns, ln)) :
-                    currentElement.addChildElement(ln, prefix, ns);
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
+
         }
+
+        deferredElement.setLocalName(ln);
+        deferredElement.setNamespaceUri(ns);
+        deferredElement.setPrefix(prefix);
+
     }
 
     private void fixPrefix(final String prfx) throws XMLStreamException {
@@ -136,11 +153,13 @@
 
     @Override
     public void writeEndElement() throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         if (currentElement != null) currentElement = currentElement.getParentElement();
     }
 
     @Override
     public void writeEndDocument() throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
     }
 
     @Override
@@ -158,19 +177,14 @@
 
     @Override
     public void writeAttribute(final String prefix, final String ns, final String ln, final String value) throws XMLStreamException {
-        try {
-            if (ns == null) {
-                if (prefix == null && xmlns.equals(ln)) {
-                    currentElement.addNamespaceDeclaration("", value);
-                } else {
-                    currentElement.setAttributeNS("", ln, value);
-                }
+        if (ns == null && prefix == null && xmlns.equals(ln)) {
+            writeNamespace("", value);
+        } else {
+            if (deferredElement.isInitialized()) {
+                deferredElement.addAttribute(prefix, ns, ln, value);
             } else {
-                QName name = (prefix == null) ? new QName(ns, ln) : new QName(ns, ln, prefix);
-                currentElement.addAttribute(name, value);
+                addAttibuteToElement(currentElement, prefix, ns, ln, value);
             }
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
         }
     }
 
@@ -181,16 +195,16 @@
 
     @Override
     public void writeNamespace(String prefix, final String uri) throws XMLStreamException {
-
         // make prefix default if null or "xmlns" (according to javadoc)
-        if (prefix == null || "xmlns".equals(prefix)) {
-            prefix = "";
-        }
-
-        try {
-            currentElement.addNamespaceDeclaration(prefix, uri);
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
+        String thePrefix = prefix == null || "xmlns".equals(prefix) ? "" : prefix;
+        if (deferredElement.isInitialized()) {
+            deferredElement.addNamespaceDeclaration(thePrefix, uri);
+        } else {
+            try {
+                currentElement.addNamespaceDeclaration(thePrefix, uri);
+            } catch (SOAPException e) {
+                throw new XMLStreamException(e);
+            }
         }
     }
 
@@ -201,35 +215,40 @@
 
     @Override
     public void writeComment(final String data) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Comment c = soap.getSOAPPart().createComment(data);
         currentElement.appendChild(c);
     }
 
     @Override
     public void writeProcessingInstruction(final String target) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Node n = soap.getSOAPPart().createProcessingInstruction(target, "");
         currentElement.appendChild(n);
     }
 
     @Override
     public void writeProcessingInstruction(final String target, final String data) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Node n = soap.getSOAPPart().createProcessingInstruction(target, data);
         currentElement.appendChild(n);
     }
 
     @Override
     public void writeCData(final String data) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Node n = soap.getSOAPPart().createCDATASection(data);
         currentElement.appendChild(n);
     }
 
     @Override
     public void writeDTD(final String dtd) throws XMLStreamException {
-        //TODO ... Don't do anything here
+        currentElement = deferredElement.flushTo(currentElement);
     }
 
     @Override
     public void writeEntityRef(final String name) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Node n = soap.getSOAPPart().createEntityReference(name);
         currentElement.appendChild(n);
     }
@@ -257,6 +276,7 @@
 
     @Override
     public void writeCharacters(final String text) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         try {
             currentElement.addTextNode(text);
         } catch (SOAPException e) {
@@ -266,6 +286,7 @@
 
     @Override
     public void writeCharacters(final char[] text, final int start, final int len) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         char[] chr = (start == 0 && len == text.length) ? text : Arrays.copyOfRange(text, start, start + len);
         try {
             currentElement.addTextNode(new String(chr));
@@ -281,10 +302,16 @@
 
     @Override
     public void setPrefix(final String prefix, final String uri) throws XMLStreamException {
-        try {
-            this.currentElement.addNamespaceDeclaration(prefix, uri);
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
+        // TODO: this in fact is not what would be expected from XMLStreamWriter
+        //       (e.g. XMLStreamWriter for writing to output stream does not write anything as result of
+        //        this method, it just rememebers that given prefix is associated with the given uri
+        //        for the scope; to actually declare the prefix assignment in the resulting XML, one
+        //        needs to call writeNamespace(...) method
+        // Kept for backwards compatibility reasons - this might be worth of further investigation.
+        if (deferredElement.isInitialized()) {
+            deferredElement.addNamespaceDeclaration(prefix, uri);
+        } else {
+            throw new XMLStreamException("Namespace not associated with any element");
         }
     }
 
@@ -331,4 +358,209 @@
             }
         };
     }
+
+    static void addAttibuteToElement(SOAPElement element, String prefix, String ns, String ln, String value)
+            throws XMLStreamException {
+        try {
+            if (ns == null) {
+                element.setAttributeNS("", ln, value);
+            } else {
+                QName name = prefix == null ? new QName(ns, ln) : new QName(ns, ln, prefix);
+                element.addAttribute(name, value);
+            }
+        } catch (SOAPException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    /**
+     * Holds details of element that needs to be deferred in order to manage namespace assignments correctly.
+     *
+     * <p>
+     * An instance of can be set with all the aspects of the element name (local name, prefix, namespace uri).
+     * Attributes and namespace declarations (special case of attribute) can be added.
+     * Namespace declarations are handled so that the element namespace is updated if it is implied by the namespace
+     * declaration and the namespace was not set to non-{@code null} value previously.
+     * </p>
+     *
+     * <p>
+     * The state of this object can be {@link #flushTo(SOAPElement) flushed} to SOAPElement - new SOAPElement will
+     * be added a child element; the new element will have exactly the shape as represented by the state of this
+     * object. Note that the {@link #flushTo(SOAPElement)} method does nothing
+     * (and returns the argument immediately) if the state of this object is not initialized
+     * (i.e. local name is null).
+     * </p>
+     *
+     * @author ondrej.cerny@oracle.com
+     */
+    static class DeferredElement {
+        private String prefix;
+        private String localName;
+        private String namespaceUri;
+        private final List<NamespaceDeclaration> namespaceDeclarations;
+        private final List<AttributeDeclaration> attributeDeclarations;
+
+        DeferredElement() {
+            this.namespaceDeclarations = new LinkedList<NamespaceDeclaration>();
+            this.attributeDeclarations = new LinkedList<AttributeDeclaration>();
+            reset();
+        }
+
+
+        /**
+         * Set prefix of the element.
+         * @param prefix namespace prefix
+         */
+        public void setPrefix(final String prefix) {
+            this.prefix = prefix;
+        }
+
+        /**
+         * Set local name of the element.
+         *
+         * <p>
+         *     This method initializes the element.
+         * </p>
+         *
+         * @param localName local name {@code not null}
+         */
+        public void setLocalName(final String localName) {
+            if (localName == null) {
+                throw new IllegalArgumentException("localName can not be null");
+            }
+            this.localName = localName;
+        }
+
+        /**
+         * Set namespace uri.
+         *
+         * @param namespaceUri namespace uri
+         */
+        public void setNamespaceUri(final String namespaceUri) {
+            this.namespaceUri = namespaceUri;
+        }
+
+        /**
+         * Adds namespace prefix assignment to the element.
+         *
+         * @param prefix prefix (not {@code null})
+         * @param namespaceUri namespace uri
+         */
+        public void addNamespaceDeclaration(final String prefix, final String namespaceUri) {
+            if (null == this.namespaceUri && null != namespaceUri && prefix.equals(emptyIfNull(this.prefix))) {
+                this.namespaceUri = namespaceUri;
+            }
+            this.namespaceDeclarations.add(new NamespaceDeclaration(prefix, namespaceUri));
+        }
+
+        /**
+         * Adds attribute to the element.
+         * @param prefix prefix
+         * @param ns namespace
+         * @param ln local name
+         * @param value value
+         */
+        public void addAttribute(final String prefix, final String ns, final String ln, final String value) {
+            if (ns == null && prefix == null && xmlns.equals(ln)) {
+                this.addNamespaceDeclaration(prefix, value);
+            } else {
+                this.attributeDeclarations.add(new AttributeDeclaration(prefix, ns, ln, value));
+            }
+        }
+
+        /**
+         * Flushes state of this element to the {@code target} element.
+         *
+         * <p>
+         * If this element is initialized then it is added with all the namespace declarations and attributes
+         * to the {@code target} element as a child. The state of this element is reset to uninitialized.
+         * The newly added element object is returned.
+         * </p>
+         * <p>
+         * If this element is not initialized then the {@code target} is returned immediately, nothing else is done.
+         * </p>
+         *
+         * @param target target element
+         * @return {@code target} or new element
+         * @throws XMLStreamException on error
+         */
+        public SOAPElement flushTo(final SOAPElement target) throws XMLStreamException {
+            try {
+                if (this.localName != null) {
+                    // add the element appropriately (based on namespace declaration)
+                    final SOAPElement newElement;
+                    if (this.namespaceUri == null) {
+                        // add element with inherited scope
+                        newElement = target.addChildElement(this.localName);
+                    } else if (prefix == null) {
+                        newElement = target.addChildElement(new QName(this.namespaceUri, this.localName));
+                    } else {
+                        newElement = target.addChildElement(this.localName, this.prefix, this.namespaceUri);
+                    }
+                    // add namespace declarations
+                    for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
+                        target.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
+                    }
+                    // add attribute declarations
+                    for (AttributeDeclaration attribute : this.attributeDeclarations) {
+                        addAttibuteToElement(newElement,
+                                attribute.prefix, attribute.namespaceUri, attribute.localName, attribute.value);
+                    }
+                    // reset state
+                    this.reset();
+
+                    return newElement;
+                } else {
+                    return target;
+                }
+                // else after reset state -> not initialized
+            } catch (SOAPException e) {
+                throw new XMLStreamException(e);
+            }
+        }
+
+        /**
+         * Is the element initialized?
+         * @return boolean indicating whether it was initialized after last flush
+         */
+        public boolean isInitialized() {
+            return this.localName != null;
+        }
+
+        private void reset() {
+            this.localName = null;
+            this.prefix = null;
+            this.namespaceUri = null;
+            this.namespaceDeclarations.clear();
+            this.attributeDeclarations.clear();
+        }
+
+        private static String emptyIfNull(String s) {
+            return s == null ? "" : s;
+        }
+    }
+
+    static class NamespaceDeclaration {
+        final String prefix;
+        final String namespaceUri;
+
+        NamespaceDeclaration(String prefix, String namespaceUri) {
+            this.prefix = prefix;
+            this.namespaceUri = namespaceUri;
+        }
+    }
+
+    static class AttributeDeclaration {
+        final String prefix;
+        final String namespaceUri;
+        final String localName;
+        final String value;
+
+        AttributeDeclaration(String prefix, String namespaceUri, String localName, String value) {
+            this.prefix = prefix;
+            this.namespaceUri = namespaceUri;
+            this.localName = localName;
+            this.value = value;
+        }
+    }
 }
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,10 @@
 
 package com.sun.xml.internal.ws.api.message.saaj;
 
+import java.util.Iterator;
 import java.util.Arrays;
-import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedList;
 
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
@@ -42,6 +44,17 @@
 /**
  * SaajStaxWriter builds a SAAJ SOAPMessage by using XMLStreamWriter interface.
  *
+ * <p>
+ * Defers creation of SOAPElement until all the aspects of the name of the element are known.
+ * In some cases, the namespace uri is indicated only by the {@link #writeNamespace(String, String)} call.
+ * After opening an element ({@code writeStartElement}, {@code writeEmptyElement} methods), all attributes
+ * and namespace assignments are retained within {@link DeferredElement} object ({@code deferredElement} field).
+ * As soon as any other method than {@code writeAttribute}, {@code writeNamespace}, {@code writeDefaultNamespace}
+ * or {@code setNamespace} is called, the contents of {@code deferredElement} is transformed into new SOAPElement
+ * (which is appropriately inserted into the SOAPMessage under construction).
+ * This mechanism is necessary to fix JDK-8159058 issue.
+ * </p>
+ *
  * @author shih-chang.chen@oracle.com
  */
 public class SaajStaxWriter implements XMLStreamWriter {
@@ -49,6 +62,7 @@
     protected SOAPMessage soap;
     protected String envURI;
     protected SOAPElement currentElement;
+    protected DeferredElement deferredElement;
 
     static final protected String Envelope = "Envelope";
     static final protected String Header = "Header";
@@ -58,6 +72,7 @@
     public SaajStaxWriter(final SOAPMessage msg, String uri) throws SOAPException {
         soap = msg;
         this.envURI = uri;
+        this.deferredElement = new DeferredElement();
     }
 
     public SOAPMessage getSOAPMessage() {
@@ -70,11 +85,8 @@
 
     @Override
     public void writeStartElement(final String localName) throws XMLStreamException {
-        try {
-            currentElement = currentElement.addChildElement(localName);
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
-        }
+        currentElement = deferredElement.flushTo(currentElement);
+        deferredElement.setLocalName(localName);
     }
 
     @Override
@@ -84,8 +96,10 @@
 
     @Override
     public void writeStartElement(final String prefix, final String ln, final String ns) throws XMLStreamException {
-        try {
-            if (envURI.equals(ns)) {
+        currentElement = deferredElement.flushTo(currentElement);
+
+        if (envURI.equals(ns)) {
+            try {
                 if (Envelope.equals(ln)) {
                     currentElement = getEnvelope();
                     fixPrefix(prefix);
@@ -99,13 +113,16 @@
                     fixPrefix(prefix);
                     return;
                 }
+            } catch (SOAPException e) {
+                throw new XMLStreamException(e);
             }
-            currentElement = (prefix == null) ?
-                    currentElement.addChildElement(new QName(ns, ln)) :
-                    currentElement.addChildElement(ln, prefix, ns);
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
+
         }
+
+        deferredElement.setLocalName(ln);
+        deferredElement.setNamespaceUri(ns);
+        deferredElement.setPrefix(prefix);
+
     }
 
     private void fixPrefix(final String prfx) throws XMLStreamException {
@@ -136,11 +153,13 @@
 
     @Override
     public void writeEndElement() throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         if (currentElement != null) currentElement = currentElement.getParentElement();
     }
 
     @Override
     public void writeEndDocument() throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
     }
 
     @Override
@@ -158,19 +177,14 @@
 
     @Override
     public void writeAttribute(final String prefix, final String ns, final String ln, final String value) throws XMLStreamException {
-        try {
-            if (ns == null) {
-                if (prefix == null && xmlns.equals(ln)) {
-                    currentElement.addNamespaceDeclaration("", value);
-                } else {
-                    currentElement.setAttributeNS("", ln, value);
-                }
+        if (ns == null && prefix == null && xmlns.equals(ln)) {
+            writeNamespace("", value);
+        } else {
+            if (deferredElement.isInitialized()) {
+                deferredElement.addAttribute(prefix, ns, ln, value);
             } else {
-                QName name = (prefix == null) ? new QName(ns, ln) : new QName(ns, ln, prefix);
-                currentElement.addAttribute(name, value);
+                addAttibuteToElement(currentElement, prefix, ns, ln, value);
             }
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
         }
     }
 
@@ -181,16 +195,16 @@
 
     @Override
     public void writeNamespace(String prefix, final String uri) throws XMLStreamException {
-
         // make prefix default if null or "xmlns" (according to javadoc)
-        if (prefix == null || "xmlns".equals(prefix)) {
-            prefix = "";
-        }
-
-        try {
-            currentElement.addNamespaceDeclaration(prefix, uri);
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
+        String thePrefix = prefix == null || "xmlns".equals(prefix) ? "" : prefix;
+        if (deferredElement.isInitialized()) {
+            deferredElement.addNamespaceDeclaration(thePrefix, uri);
+        } else {
+            try {
+                currentElement.addNamespaceDeclaration(thePrefix, uri);
+            } catch (SOAPException e) {
+                throw new XMLStreamException(e);
+            }
         }
     }
 
@@ -201,35 +215,40 @@
 
     @Override
     public void writeComment(final String data) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Comment c = soap.getSOAPPart().createComment(data);
         currentElement.appendChild(c);
     }
 
     @Override
     public void writeProcessingInstruction(final String target) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Node n = soap.getSOAPPart().createProcessingInstruction(target, "");
         currentElement.appendChild(n);
     }
 
     @Override
     public void writeProcessingInstruction(final String target, final String data) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Node n = soap.getSOAPPart().createProcessingInstruction(target, data);
         currentElement.appendChild(n);
     }
 
     @Override
     public void writeCData(final String data) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Node n = soap.getSOAPPart().createCDATASection(data);
         currentElement.appendChild(n);
     }
 
     @Override
     public void writeDTD(final String dtd) throws XMLStreamException {
-        //TODO ... Don't do anything here
+        currentElement = deferredElement.flushTo(currentElement);
     }
 
     @Override
     public void writeEntityRef(final String name) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         Node n = soap.getSOAPPart().createEntityReference(name);
         currentElement.appendChild(n);
     }
@@ -257,6 +276,7 @@
 
     @Override
     public void writeCharacters(final String text) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         try {
             currentElement.addTextNode(text);
         } catch (SOAPException e) {
@@ -266,6 +286,7 @@
 
     @Override
     public void writeCharacters(final char[] text, final int start, final int len) throws XMLStreamException {
+        currentElement = deferredElement.flushTo(currentElement);
         char[] chr = (start == 0 && len == text.length) ? text : Arrays.copyOfRange(text, start, start + len);
         try {
             currentElement.addTextNode(new String(chr));
@@ -281,10 +302,16 @@
 
     @Override
     public void setPrefix(final String prefix, final String uri) throws XMLStreamException {
-        try {
-            this.currentElement.addNamespaceDeclaration(prefix, uri);
-        } catch (SOAPException e) {
-            throw new XMLStreamException(e);
+        // TODO: this in fact is not what would be expected from XMLStreamWriter
+        //       (e.g. XMLStreamWriter for writing to output stream does not write anything as result of
+        //        this method, it just rememebers that given prefix is associated with the given uri
+        //        for the scope; to actually declare the prefix assignment in the resulting XML, one
+        //        needs to call writeNamespace(...) method
+        // Kept for backwards compatibility reasons - this might be worth of further investigation.
+        if (deferredElement.isInitialized()) {
+            deferredElement.addNamespaceDeclaration(prefix, uri);
+        } else {
+            throw new XMLStreamException("Namespace not associated with any element");
         }
     }
 
@@ -315,12 +342,12 @@
                 return currentElement.lookupPrefix(namespaceURI);
             }
             public Iterator getPrefixes(final String namespaceURI) {
-                return new Iterator() {
+                return new Iterator<String>() {
                     String prefix = getPrefix(namespaceURI);
                     public boolean hasNext() {
                         return (prefix != null);
                     }
-                    public Object next() {
+                    public String next() {
                         if (!hasNext()) throw new java.util.NoSuchElementException();
                         String next = prefix;
                         prefix = null;
@@ -331,4 +358,209 @@
             }
         };
     }
+
+    static void addAttibuteToElement(SOAPElement element, String prefix, String ns, String ln, String value)
+            throws XMLStreamException {
+        try {
+            if (ns == null) {
+                element.setAttributeNS("", ln, value);
+            } else {
+                QName name = prefix == null ? new QName(ns, ln) : new QName(ns, ln, prefix);
+                element.addAttribute(name, value);
+            }
+        } catch (SOAPException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    /**
+     * Holds details of element that needs to be deferred in order to manage namespace assignments correctly.
+     *
+     * <p>
+     * An instance of can be set with all the aspects of the element name (local name, prefix, namespace uri).
+     * Attributes and namespace declarations (special case of attribute) can be added.
+     * Namespace declarations are handled so that the element namespace is updated if it is implied by the namespace
+     * declaration and the namespace was not set to non-{@code null} value previously.
+     * </p>
+     *
+     * <p>
+     * The state of this object can be {@link #flushTo(SOAPElement) flushed} to SOAPElement - new SOAPElement will
+     * be added a child element; the new element will have exactly the shape as represented by the state of this
+     * object. Note that the {@link #flushTo(SOAPElement)} method does nothing
+     * (and returns the argument immediately) if the state of this object is not initialized
+     * (i.e. local name is null).
+     * </p>
+     *
+     * @author ondrej.cerny@oracle.com
+     */
+    static class DeferredElement {
+        private String prefix;
+        private String localName;
+        private String namespaceUri;
+        private final List<NamespaceDeclaration> namespaceDeclarations;
+        private final List<AttributeDeclaration> attributeDeclarations;
+
+        DeferredElement() {
+            this.namespaceDeclarations = new LinkedList<NamespaceDeclaration>();
+            this.attributeDeclarations = new LinkedList<AttributeDeclaration>();
+            reset();
+        }
+
+
+        /**
+         * Set prefix of the element.
+         * @param prefix namespace prefix
+         */
+        public void setPrefix(final String prefix) {
+            this.prefix = prefix;
+        }
+
+        /**
+         * Set local name of the element.
+         *
+         * <p>
+         *     This method initializes the element.
+         * </p>
+         *
+         * @param localName local name {@code not null}
+         */
+        public void setLocalName(final String localName) {
+            if (localName == null) {
+                throw new IllegalArgumentException("localName can not be null");
+            }
+            this.localName = localName;
+        }
+
+        /**
+         * Set namespace uri.
+         *
+         * @param namespaceUri namespace uri
+         */
+        public void setNamespaceUri(final String namespaceUri) {
+            this.namespaceUri = namespaceUri;
+        }
+
+        /**
+         * Adds namespace prefix assignment to the element.
+         *
+         * @param prefix prefix (not {@code null})
+         * @param namespaceUri namespace uri
+         */
+        public void addNamespaceDeclaration(final String prefix, final String namespaceUri) {
+            if (null == this.namespaceUri && null != namespaceUri && prefix.equals(emptyIfNull(this.prefix))) {
+                this.namespaceUri = namespaceUri;
+            }
+            this.namespaceDeclarations.add(new NamespaceDeclaration(prefix, namespaceUri));
+        }
+
+        /**
+         * Adds attribute to the element.
+         * @param prefix prefix
+         * @param ns namespace
+         * @param ln local name
+         * @param value value
+         */
+        public void addAttribute(final String prefix, final String ns, final String ln, final String value) {
+            if (ns == null && prefix == null && xmlns.equals(ln)) {
+                this.addNamespaceDeclaration(prefix, value);
+            } else {
+                this.attributeDeclarations.add(new AttributeDeclaration(prefix, ns, ln, value));
+            }
+        }
+
+        /**
+         * Flushes state of this element to the {@code target} element.
+         *
+         * <p>
+         * If this element is initialized then it is added with all the namespace declarations and attributes
+         * to the {@code target} element as a child. The state of this element is reset to uninitialized.
+         * The newly added element object is returned.
+         * </p>
+         * <p>
+         * If this element is not initialized then the {@code target} is returned immediately, nothing else is done.
+         * </p>
+         *
+         * @param target target element
+         * @return {@code target} or new element
+         * @throws XMLStreamException on error
+         */
+        public SOAPElement flushTo(final SOAPElement target) throws XMLStreamException {
+            try {
+                if (this.localName != null) {
+                    // add the element appropriately (based on namespace declaration)
+                    final SOAPElement newElement;
+                    if (this.namespaceUri == null) {
+                        // add element with inherited scope
+                        newElement = target.addChildElement(this.localName);
+                    } else if (prefix == null) {
+                        newElement = target.addChildElement(new QName(this.namespaceUri, this.localName));
+                    } else {
+                        newElement = target.addChildElement(this.localName, this.prefix, this.namespaceUri);
+                    }
+                    // add namespace declarations
+                    for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
+                        target.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
+                    }
+                    // add attribute declarations
+                    for (AttributeDeclaration attribute : this.attributeDeclarations) {
+                        addAttibuteToElement(newElement,
+                                attribute.prefix, attribute.namespaceUri, attribute.localName, attribute.value);
+                    }
+                    // reset state
+                    this.reset();
+
+                    return newElement;
+                } else {
+                    return target;
+                }
+                // else after reset state -> not initialized
+            } catch (SOAPException e) {
+                throw new XMLStreamException(e);
+            }
+        }
+
+        /**
+         * Is the element initialized?
+         * @return boolean indicating whether it was initialized after last flush
+         */
+        public boolean isInitialized() {
+            return this.localName != null;
+        }
+
+        private void reset() {
+            this.localName = null;
+            this.prefix = null;
+            this.namespaceUri = null;
+            this.namespaceDeclarations.clear();
+            this.attributeDeclarations.clear();
+        }
+
+        private static String emptyIfNull(String s) {
+            return s == null ? "" : s;
+        }
+    }
+
+    static class NamespaceDeclaration {
+        final String prefix;
+        final String namespaceUri;
+
+        NamespaceDeclaration(String prefix, String namespaceUri) {
+            this.prefix = prefix;
+            this.namespaceUri = namespaceUri;
+        }
+    }
+
+    static class AttributeDeclaration {
+        final String prefix;
+        final String namespaceUri;
+        final String localName;
+        final String value;
+
+        AttributeDeclaration(String prefix, String namespaceUri, String localName, String value) {
+            this.prefix = prefix;
+            this.namespaceUri = namespaceUri;
+            this.localName = localName;
+            this.value = value;
+        }
+    }
 }
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.lang.reflect.Method;
+import java.net.URI;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -332,13 +333,13 @@
      * (com.sun.org.apache.xml.internal) for modular runtime.
      */
     private static EntityResolver createCatalogResolver(ArrayList<URL> urls) throws Exception {
-        // Prepare array of catalog paths
-        String[] paths = urls.stream()
-                             .map(u -> u.toExternalForm())
-                             .toArray(c -> new String[c]);
+        // Prepare array of catalog URIs
+        URI[] uris = urls.stream()
+                             .map(u -> URI.create(u.toExternalForm()))
+                             .toArray(URI[]::new);
 
         //Create CatalogResolver with new JDK9+ API
-        return (EntityResolver) CatalogManager.catalogResolver(catalogFeatures, paths);
+        return (EntityResolver) CatalogManager.catalogResolver(catalogFeatures, uris);
     }
 
     // Cache CatalogFeatures instance for future usages.
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -777,13 +777,13 @@
      * Adds a new catalog file.
      */
     public void addCatalog(File catalogFile) throws IOException {
-        String newUrl = catalogFile.getPath();
+        URI newUrl = catalogFile.toURI();
         if (!catalogUrls.contains(newUrl)) {
             catalogUrls.add(newUrl);
         }
         try {
             entityResolver = CatalogManager.catalogResolver(catalogFeatures,
-                                catalogUrls.toArray(new String[0]));
+                                catalogUrls.stream().toArray(URI[]::new));
         } catch (Exception ex) {
             entityResolver = null;
         }
@@ -791,7 +791,7 @@
 
     // Since javax.xml.catalog is unmodifiable we need to track catalog
     // URLs added and create new catalog each time addCatalog is called
-    private final ArrayList<String> catalogUrls = new ArrayList<String>();
+    private final ArrayList<URI> catalogUrls = new ArrayList<>();
 
     // Cache CatalogFeatures instance for future usages.
     // Resolve feature is set to "continue" value for backward compatibility.
--- a/jdk/.hgtags	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/.hgtags	Tue Jan 24 00:30:25 2017 +0100
@@ -394,3 +394,5 @@
 5a846396a24c7aff01d6a8feaa7afc0a6369f04d jdk-9+149
 71e198ef3839045e829a879af1d709be16ab0f88 jdk-9+150
 d27bab22ff62823902d93d1d35ca397cfd50d059 jdk-9+151
+a20f2cf90762673e1bc4980fd6597e70a2578045 jdk-9+152
+1c4411322327aea3f91011ec3977a12a05b09629 jdk-9+153
--- a/jdk/make/CompileModuleTools.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/make/CompileModuleTools.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -37,6 +37,5 @@
                 build/tools/jigsaw, \
     BIN := $(TOOLS_CLASSES_DIR), \
     ADD_JAVAC_FLAGS := \
-        --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \
         --add-exports java.base/jdk.internal.module=ALL-UNNAMED \
 ))
--- a/jdk/make/ModuleTools.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/make/ModuleTools.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -39,7 +39,6 @@
     build.tools.jigsaw.GenGraphs
 
 TOOL_MODULESUMMARY := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \
-    --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \
     build.tools.jigsaw.ModuleSummary
 
 TOOL_ADD_PACKAGES_ATTRIBUTE := $(BUILD_JAVA) $(JAVA_FLAGS_SMALL) \
--- a/jdk/make/data/fontconfig/solaris.fontconfig.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/make/data/fontconfig/solaris.fontconfig.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -436,15 +436,15 @@
 
 filename.-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arial.ttf
 filename.-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/ariali.ttf
-filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arialb.ttf
+filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arialbd.ttf
 filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arialbi.ttf
 filename.-monotype-courier_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cour.ttf
 filename.-monotype-courier_new-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/couri.ttf
-filename.-monotype-courier_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/courb.ttf
+filename.-monotype-courier_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/courbd.ttf
 filename.-monotype-courier_new-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/courbi.ttf
 filename.-monotype-times_new_roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/times.ttf
 filename.-monotype-times_new_roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesi.ttf
-filename.-monotype-times_new_roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesb.ttf
+filename.-monotype-times_new_roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesbd.ttf
 filename.-monotype-times_new_roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesbi.ttf
 
 filename.-monotype-angsana_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/angsa.ttf
--- a/jdk/make/lib/Awt2dLibraries.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/make/lib/Awt2dLibraries.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -222,6 +222,8 @@
 # applies to debug builds.
 ifeq ($(TOOLCHAIN_TYPE), gcc)
   BUILD_LIBAWT_debug_mem.c_CFLAGS := -w
+  # This option improves performance of MaskFill in Java2D by 20% for some gcc
+  LIBAWT_CFLAGS += -fgcse-after-reload
 endif
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBAWT, \
--- a/jdk/src/java.base/share/classes/com/sun/net/ssl/HttpsURLConnection.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/com/sun/net/ssl/HttpsURLConnection.java	Tue Jan 24 00:30:25 2017 +0100
@@ -69,6 +69,10 @@
     /**
      * Returns the server's X.509 certificate chain, or null if
      * the server did not authenticate.
+     * <P>
+     * Note: The returned value may not be a valid certificate chain
+     * and should not be relied on for trust decisions.
+     *
      * @return the server certificate chain
      */
     public abstract Certificate[] getServerCertificates()
--- a/jdk/src/java.base/share/classes/java/io/File.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/io/File.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1962,6 +1962,9 @@
                 name = sb.toString();
             }
 
+            // Normalize the path component
+            name = fs.normalize(name);
+
             File f = new File(dir, name);
             if (!name.equals(f.getName()) || f.isInvalid()) {
                 if (System.getSecurityManager() != null)
--- a/jdk/src/java.base/share/classes/java/lang/Class.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java	Tue Jan 24 00:30:25 2017 +0100
@@ -508,8 +508,9 @@
     public T newInstance()
         throws InstantiationException, IllegalAccessException
     {
-        if (System.getSecurityManager() != null) {
-            checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), false);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false);
         }
 
         // NOTE: the following code may not be strictly correct under
@@ -1223,38 +1224,27 @@
 
             // Perform access check
             final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
-            enclosingCandidate.checkMemberAccess(Member.DECLARED,
-                                                 Reflection.getCallerClass(), true);
-            // Client is ok to access declared methods but j.l.Class might not be.
-            Method[] candidates = AccessController.doPrivileged(
-                    new PrivilegedAction<>() {
-                        @Override
-                        public Method[] run() {
-                            return enclosingCandidate.getDeclaredMethods();
-                        }
-                    });
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                enclosingCandidate.checkMemberAccess(sm, Member.DECLARED,
+                                                     Reflection.getCallerClass(), true);
+            }
+            Method[] candidates = enclosingCandidate.privateGetDeclaredMethods(false);
+
             /*
              * Loop over all declared methods; match method name,
              * number of and type of parameters, *and* return
              * type.  Matching return type is also necessary
              * because of covariant returns, etc.
              */
-            for(Method m: candidates) {
-                if (m.getName().equals(enclosingInfo.getName()) ) {
-                    Class<?>[] candidateParamClasses = m.getParameterTypes();
-                    if (candidateParamClasses.length == parameterClasses.length) {
-                        boolean matches = true;
-                        for(int i = 0; i < candidateParamClasses.length; i++) {
-                            if (!candidateParamClasses[i].equals(parameterClasses[i])) {
-                                matches = false;
-                                break;
-                            }
-                        }
-
-                        if (matches) { // finally, check return type
-                            if (m.getReturnType().equals(returnType) )
-                                return m;
-                        }
+            ReflectionFactory fact = getReflectionFactory();
+            for (Method m : candidates) {
+                if (m.getName().equals(enclosingInfo.getName()) &&
+                    arrayContentsEq(parameterClasses,
+                                    fact.getExecutableSharedParameterTypes(m))) {
+                    // finally, check return type
+                    if (m.getReturnType().equals(returnType)) {
+                        return fact.copyMethod(m);
                     }
                 }
             }
@@ -1390,33 +1380,23 @@
 
             // Perform access check
             final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
-            enclosingCandidate.checkMemberAccess(Member.DECLARED,
-                                                 Reflection.getCallerClass(), true);
-            // Client is ok to access declared methods but j.l.Class might not be.
-            Constructor<?>[] candidates = AccessController.doPrivileged(
-                    new PrivilegedAction<>() {
-                        @Override
-                        public Constructor<?>[] run() {
-                            return enclosingCandidate.getDeclaredConstructors();
-                        }
-                    });
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                enclosingCandidate.checkMemberAccess(sm, Member.DECLARED,
+                                                     Reflection.getCallerClass(), true);
+            }
+
+            Constructor<?>[] candidates = enclosingCandidate
+                    .privateGetDeclaredConstructors(false);
             /*
              * Loop over all declared constructors; match number
              * of and type of parameters.
              */
-            for(Constructor<?> c: candidates) {
-                Class<?>[] candidateParamClasses = c.getParameterTypes();
-                if (candidateParamClasses.length == parameterClasses.length) {
-                    boolean matches = true;
-                    for(int i = 0; i < candidateParamClasses.length; i++) {
-                        if (!candidateParamClasses[i].equals(parameterClasses[i])) {
-                            matches = false;
-                            break;
-                        }
-                    }
-
-                    if (matches)
-                        return c;
+            ReflectionFactory fact = getReflectionFactory();
+            for (Constructor<?> c : candidates) {
+                if (arrayContentsEq(parameterClasses,
+                                    fact.getExecutableSharedParameterTypes(c))) {
+                    return fact.copyConstructor(c);
                 }
             }
 
@@ -1446,9 +1426,13 @@
     public Class<?> getDeclaringClass() throws SecurityException {
         final Class<?> candidate = getDeclaringClass0();
 
-        if (candidate != null)
-            candidate.checkPackageAccess(
+        if (candidate != null) {
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                candidate.checkPackageAccess(sm,
                     ClassLoader.getClassLoader(Reflection.getCallerClass()), true);
+            }
+        }
         return candidate;
     }
 
@@ -1496,9 +1480,13 @@
                 enclosingCandidate = enclosingClass;
         }
 
-        if (enclosingCandidate != null)
-            enclosingCandidate.checkPackageAccess(
+        if (enclosingCandidate != null) {
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                enclosingCandidate.checkPackageAccess(sm,
                     ClassLoader.getClassLoader(Reflection.getCallerClass()), true);
+            }
+        }
         return enclosingCandidate;
     }
 
@@ -1688,7 +1676,10 @@
      */
     @CallerSensitive
     public Class<?>[] getClasses() {
-        checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), false);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false);
+        }
 
         // Privileged so this implementation can look at DECLARED classes,
         // something the caller might not have privilege to do.  The code here
@@ -1754,7 +1745,10 @@
      */
     @CallerSensitive
     public Field[] getFields() throws SecurityException {
-        checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
+        }
         return copyFields(privateGetPublicFields(null));
     }
 
@@ -1841,7 +1835,10 @@
      */
     @CallerSensitive
     public Method[] getMethods() throws SecurityException {
-        checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
+        }
         return copyMethods(privateGetPublicMethods());
     }
 
@@ -1877,7 +1874,10 @@
      */
     @CallerSensitive
     public Constructor<?>[] getConstructors() throws SecurityException {
-        checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
+        }
         return copyConstructors(privateGetDeclaredConstructors(true));
     }
 
@@ -1928,7 +1928,10 @@
     public Field getField(String name)
         throws NoSuchFieldException, SecurityException {
         Objects.requireNonNull(name);
-        checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
+        }
         Field field = getField0(name);
         if (field == null) {
             throw new NoSuchFieldException(name);
@@ -2034,10 +2037,13 @@
     public Method getMethod(String name, Class<?>... parameterTypes)
         throws NoSuchMethodException, SecurityException {
         Objects.requireNonNull(name);
-        checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
+        }
         Method method = getMethod0(name, parameterTypes);
         if (method == null) {
-            throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes));
+            throw new NoSuchMethodException(methodToString(name, parameterTypes));
         }
         return getReflectionFactory().copyMethod(method);
     }
@@ -2092,8 +2098,12 @@
      */
     @CallerSensitive
     public Constructor<T> getConstructor(Class<?>... parameterTypes)
-        throws NoSuchMethodException, SecurityException {
-        checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+        throws NoSuchMethodException, SecurityException
+    {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
+        }
         return getReflectionFactory().copyConstructor(
             getConstructor0(parameterTypes, Member.PUBLIC));
     }
@@ -2136,7 +2146,10 @@
      */
     @CallerSensitive
     public Class<?>[] getDeclaredClasses() throws SecurityException {
-        checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), false);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), false);
+        }
         return getDeclaredClasses0();
     }
 
@@ -2185,7 +2198,10 @@
      */
     @CallerSensitive
     public Field[] getDeclaredFields() throws SecurityException {
-        checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
+        }
         return copyFields(privateGetDeclaredFields(false));
     }
 
@@ -2244,7 +2260,10 @@
      */
     @CallerSensitive
     public Method[] getDeclaredMethods() throws SecurityException {
-        checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
+        }
         return copyMethods(privateGetDeclaredMethods(false));
     }
 
@@ -2289,7 +2308,10 @@
      */
     @CallerSensitive
     public Constructor<?>[] getDeclaredConstructors() throws SecurityException {
-        checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
+        }
         return copyConstructors(privateGetDeclaredConstructors(false));
     }
 
@@ -2338,7 +2360,10 @@
     public Field getDeclaredField(String name)
         throws NoSuchFieldException, SecurityException {
         Objects.requireNonNull(name);
-        checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
+        }
         Field field = searchFields(privateGetDeclaredFields(false), name);
         if (field == null) {
             throw new NoSuchFieldException(name);
@@ -2399,10 +2424,13 @@
     public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
         throws NoSuchMethodException, SecurityException {
         Objects.requireNonNull(name);
-        checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
+        }
         Method method = searchMethods(privateGetDeclaredMethods(false), name, parameterTypes);
         if (method == null) {
-            throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes));
+            throw new NoSuchMethodException(methodToString(name, parameterTypes));
         }
         return getReflectionFactory().copyMethod(method);
     }
@@ -2448,8 +2476,13 @@
      */
     @CallerSensitive
     public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
-        throws NoSuchMethodException, SecurityException {
-        checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+        throws NoSuchMethodException, SecurityException
+    {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
+        }
+
         return getReflectionFactory().copyConstructor(
             getConstructor0(parameterTypes, Member.DECLARED));
     }
@@ -2697,51 +2730,49 @@
      *
      * <p> Default policy: allow all clients access with normal Java access
      * control.
+     *
+     * <p> NOTE: should only be called if a SecurityManager is installed
      */
-    private void checkMemberAccess(int which, Class<?> caller, boolean checkProxyInterfaces) {
-        final SecurityManager s = System.getSecurityManager();
-        if (s != null) {
-            /* Default policy allows access to all {@link Member#PUBLIC} members,
-             * as well as access to classes that have the same class loader as the caller.
-             * In all other cases, it requires RuntimePermission("accessDeclaredMembers")
-             * permission.
-             */
-            final ClassLoader ccl = ClassLoader.getClassLoader(caller);
+    private void checkMemberAccess(SecurityManager sm, int which,
+                                   Class<?> caller, boolean checkProxyInterfaces) {
+        /* Default policy allows access to all {@link Member#PUBLIC} members,
+         * as well as access to classes that have the same class loader as the caller.
+         * In all other cases, it requires RuntimePermission("accessDeclaredMembers")
+         * permission.
+         */
+        final ClassLoader ccl = caller.getClassLoader0();
+        if (which != Member.PUBLIC) {
             final ClassLoader cl = getClassLoader0();
-            if (which != Member.PUBLIC) {
-                if (ccl != cl) {
-                    s.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
-                }
+            if (ccl != cl) {
+                sm.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
             }
-            this.checkPackageAccess(ccl, checkProxyInterfaces);
         }
+        this.checkPackageAccess(sm, ccl, checkProxyInterfaces);
     }
 
     /*
      * Checks if a client loaded in ClassLoader ccl is allowed to access this
      * class under the current package access policy. If access is denied,
      * throw a SecurityException.
+     *
+     * NOTE: this method should only be called if a SecurityManager is active
      */
-    private void checkPackageAccess(final ClassLoader ccl, boolean checkProxyInterfaces) {
-        final SecurityManager s = System.getSecurityManager();
-        if (s != null) {
-            final ClassLoader cl = getClassLoader0();
-
-            if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
-                String name = this.getName();
-                int i = name.lastIndexOf('.');
-                if (i != -1) {
-                    // skip the package access check on a proxy class in default proxy package
-                    String pkg = name.substring(0, i);
-                    if (!Proxy.isProxyClass(this) || ReflectUtil.isNonPublicProxyClass(this)) {
-                        s.checkPackageAccess(pkg);
-                    }
+    private void checkPackageAccess(SecurityManager sm, final ClassLoader ccl,
+                                    boolean checkProxyInterfaces) {
+        final ClassLoader cl = getClassLoader0();
+
+        if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
+            String pkg = this.getPackageName();
+            if (pkg != null && !pkg.isEmpty()) {
+                // skip the package access check on a proxy class in default proxy package
+                if (!Proxy.isProxyClass(this) || ReflectUtil.isNonPublicProxyClass(this)) {
+                    sm.checkPackageAccess(pkg);
                 }
             }
-            // check package access on the proxy interfaces
-            if (checkProxyInterfaces && Proxy.isProxyClass(this)) {
-                ReflectUtil.checkProxyPackageAccess(ccl, this.getInterfaces());
-            }
+        }
+        // check package access on the proxy interfaces
+        if (checkProxyInterfaces && Proxy.isProxyClass(this)) {
+            ReflectUtil.checkProxyPackageAccess(ccl, this.getInterfaces());
         }
     }
 
@@ -2755,11 +2786,9 @@
             while (c.isArray()) {
                 c = c.getComponentType();
             }
-            String baseName = c.getName();
-            int index = baseName.lastIndexOf('.');
-            if (index != -1) {
-                name = baseName.substring(0, index).replace('.', '/')
-                    +"/"+name;
+            String baseName = c.getPackageName();
+            if (baseName != null && !baseName.isEmpty()) {
+                name = baseName.replace('.', '/') + "/" + name;
             }
         } else {
             name = name.substring(1);
@@ -3233,7 +3262,7 @@
                 return constructor;
             }
         }
-        throw new NoSuchMethodException(getName() + ".<init>" + argumentTypesToString(parameterTypes));
+        throw new NoSuchMethodException(methodToString("<init>", parameterTypes));
     }
 
     //
@@ -3294,8 +3323,11 @@
     private native Constructor<T>[] getDeclaredConstructors0(boolean publicOnly);
     private native Class<?>[]   getDeclaredClasses0();
 
-    private static String        argumentTypesToString(Class<?>[] argTypes) {
-        StringJoiner sj = new StringJoiner(", ", "(", ")");
+    /**
+     * Helper method to get the method name from arguments.
+     */
+    private String methodToString(String name, Class<?>[] argTypes) {
+        StringJoiner sj = new StringJoiner(", ", getName() + "." + name + "(", ")");
         if (argTypes != null) {
             for (int i = 0; i < argTypes.length; i++) {
                 Class<?> c = argTypes[i];
--- a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,18 +25,30 @@
 
 package java.lang;
 
-import java.security.*;
+import java.lang.RuntimePermission;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.ModuleDescriptor.Opens;
+import java.lang.reflect.Layer;
+import java.lang.reflect.Member;
+import java.lang.reflect.Module;
 import java.io.FileDescriptor;
 import java.io.File;
 import java.io.FilePermission;
-import java.util.PropertyPermission;
-import java.lang.RuntimePermission;
+import java.net.InetAddress;
 import java.net.SocketPermission;
-import java.net.NetPermission;
-import java.util.Hashtable;
-import java.net.InetAddress;
-import java.lang.reflect.*;
-import java.net.URL;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PrivilegedAction;
+import java.security.Security;
+import java.security.SecurityPermission;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.PropertyPermission;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import jdk.internal.reflect.CallerSensitive;
 import sun.security.util.SecurityConstants;
@@ -1415,46 +1427,108 @@
             }
         }
 
-        if (packages == null)
+        if (packages == null) {
             packages = new String[0];
+        }
         return packages;
     }
 
+    // The non-exported packages of the modules in the boot layer that are
+    // loaded by the platform class loader or its ancestors. A non-exported
+    // package is a package that either is not exported at all by its containing
+    // module or is exported in a qualified fashion by its containing module.
+    private static final Set<String> nonExportedPkgs;
+
+    static {
+        // Get the modules in the boot layer
+        Stream<Module> bootLayerModules = Layer.boot().modules().stream();
+
+        // Filter out the modules loaded by the boot or platform loader
+        PrivilegedAction<Set<Module>> pa = () ->
+            bootLayerModules.filter(SecurityManager::isBootOrPlatformModule)
+                            .collect(Collectors.toSet());
+        Set<Module> modules = AccessController.doPrivileged(pa);
+
+        // Filter out the non-exported packages
+        nonExportedPkgs = modules.stream()
+                                 .map(Module::getDescriptor)
+                                 .map(SecurityManager::nonExportedPkgs)
+                                 .flatMap(Set::stream)
+                                 .collect(Collectors.toSet());
+    }
+
+    /**
+     * Returns true if the module's loader is the boot or platform loader.
+     */
+    private static boolean isBootOrPlatformModule(Module m) {
+        return m.getClassLoader() == null ||
+               m.getClassLoader() == ClassLoader.getPlatformClassLoader();
+    }
+
     /**
-     * Throws a <code>SecurityException</code> if the
-     * calling thread is not allowed to access the package specified by
-     * the argument.
-     * <p>
-     * This method is used by the <code>loadClass</code> method of class
-     * loaders.
+     * Returns the non-exported packages of the specified module.
+     */
+    private static Set<String> nonExportedPkgs(ModuleDescriptor md) {
+        // start with all packages in the module
+        Set<String> pkgs = new HashSet<>(md.packages());
+
+        // remove the non-qualified exported packages
+        md.exports().stream()
+                    .filter(p -> !p.isQualified())
+                    .map(Exports::source)
+                    .forEach(pkgs::remove);
+
+        // remove the non-qualified open packages
+        md.opens().stream()
+                  .filter(p -> !p.isQualified())
+                  .map(Opens::source)
+                  .forEach(pkgs::remove);
+
+        return pkgs;
+    }
+
+    /**
+     * Throws a {@code SecurityException} if the calling thread is not allowed
+     * to access the specified package.
      * <p>
-     * This method first gets a list of
-     * restricted packages by obtaining a comma-separated list from
-     * a call to
-     * <code>java.security.Security.getProperty("package.access")</code>,
-     * and checks to see if <code>pkg</code> starts with or equals
-     * any of the restricted packages. If it does, then
-     * <code>checkPermission</code> gets called with the
-     * <code>RuntimePermission("accessClassInPackage."+pkg)</code>
-     * permission.
+     * This method is called by the {@code loadClass} method of class loaders.
+     * <p>
+     * This method checks if the specified package starts with or equals
+     * any of the packages in the {@code package.access} Security Property.
+     * An implementation may also check the package against an additional
+     * list of restricted packages as noted below. If the package is restricted,
+     * {@link #checkPermission(Permission)} is called with a
+     * {@code RuntimePermission("accessClassInPackage."+pkg)} permission.
      * <p>
-     * If this method is overridden, then
-     * <code>super.checkPackageAccess</code> should be called
-     * as the first line in the overridden method.
+     * If this method is overridden, then {@code super.checkPackageAccess}
+     * should be called as the first line in the overridden method.
+     *
+     * @implNote
+     * This implementation also restricts all non-exported packages of modules
+     * loaded by {@linkplain ClassLoader#getPlatformClassLoader
+     * the platform class loader} or its ancestors. A "non-exported package"
+     * refers to a package that is not exported to all modules. Specifically,
+     * it refers to a package that either is not exported at all by its
+     * containing module or is exported in a qualified fashion by its
+     * containing module.
      *
      * @param      pkg   the package name.
-     * @exception  SecurityException  if the calling thread does not have
+     * @throws     SecurityException  if the calling thread does not have
      *             permission to access the specified package.
-     * @exception  NullPointerException if the package name argument is
-     *             <code>null</code>.
-     * @see        java.lang.ClassLoader#loadClass(java.lang.String, boolean)
-     *  loadClass
+     * @throws     NullPointerException if the package name argument is
+     *             {@code null}.
+     * @see        java.lang.ClassLoader#loadClass(String, boolean) loadClass
      * @see        java.security.Security#getProperty getProperty
-     * @see        #checkPermission(java.security.Permission) checkPermission
+     * @see        #checkPermission(Permission) checkPermission
      */
     public void checkPackageAccess(String pkg) {
-        if (pkg == null) {
-            throw new NullPointerException("package name can't be null");
+        Objects.requireNonNull(pkg, "package name can't be null");
+
+        // check if pkg is not exported to all modules
+        if (nonExportedPkgs.contains(pkg)) {
+            checkPermission(
+                new RuntimePermission("accessClassInPackage." + pkg));
+            return;
         }
 
         String[] restrictedPkgs;
@@ -1512,36 +1586,48 @@
     }
 
     /**
-     * Throws a <code>SecurityException</code> if the
-     * calling thread is not allowed to define classes in the package
-     * specified by the argument.
+     * Throws a {@code SecurityException} if the calling thread is not
+     * allowed to define classes in the specified package.
      * <p>
-     * This method is used by the <code>loadClass</code> method of some
+     * This method is called by the {@code loadClass} method of some
      * class loaders.
      * <p>
-     * This method first gets a list of restricted packages by
-     * obtaining a comma-separated list from a call to
-     * <code>java.security.Security.getProperty("package.definition")</code>,
-     * and checks to see if <code>pkg</code> starts with or equals
-     * any of the restricted packages. If it does, then
-     * <code>checkPermission</code> gets called with the
-     * <code>RuntimePermission("defineClassInPackage."+pkg)</code>
-     * permission.
+     * This method checks if the specified package starts with or equals
+     * any of the packages in the {@code package.definition} Security
+     * Property. An implementation may also check the package against an
+     * additional list of restricted packages as noted below. If the package
+     * is restricted, {@link #checkPermission(Permission)} is called with a
+     * {@code RuntimePermission("defineClassInPackage."+pkg)} permission.
      * <p>
-     * If this method is overridden, then
-     * <code>super.checkPackageDefinition</code> should be called
-     * as the first line in the overridden method.
+     * If this method is overridden, then {@code super.checkPackageDefinition}
+     * should be called as the first line in the overridden method.
+     *
+     * @implNote
+     * This implementation also restricts all non-exported packages of modules
+     * loaded by {@linkplain ClassLoader#getPlatformClassLoader
+     * the platform class loader} or its ancestors. A "non-exported package"
+     * refers to a package that is not exported to all modules. Specifically,
+     * it refers to a package that either is not exported at all by its
+     * containing module or is exported in a qualified fashion by its
+     * containing module.
      *
      * @param      pkg   the package name.
-     * @exception  SecurityException  if the calling thread does not have
+     * @throws     SecurityException  if the calling thread does not have
      *             permission to define classes in the specified package.
-     * @see        java.lang.ClassLoader#loadClass(java.lang.String, boolean)
+     * @throws     NullPointerException if the package name argument is
+     *             {@code null}.
+     * @see        java.lang.ClassLoader#loadClass(String, boolean)
      * @see        java.security.Security#getProperty getProperty
-     * @see        #checkPermission(java.security.Permission) checkPermission
+     * @see        #checkPermission(Permission) checkPermission
      */
     public void checkPackageDefinition(String pkg) {
-        if (pkg == null) {
-            throw new NullPointerException("package name can't be null");
+        Objects.requireNonNull(pkg, "package name can't be null");
+
+        // check if pkg is not exported to all modules
+        if (nonExportedPkgs.contains(pkg)) {
+            checkPermission(
+                new RuntimePermission("defineClassInPackage." + pkg));
+            return;
         }
 
         String[] pkgs;
--- a/jdk/src/java.base/share/classes/java/lang/System.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/lang/System.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -310,12 +310,13 @@
      * @see SecurityManager#checkPermission
      * @see java.lang.RuntimePermission
      */
-    public static
-    void setSecurityManager(final SecurityManager s) {
-        try {
-            s.checkPackageAccess("java.lang");
-        } catch (Exception e) {
-            // no-op
+    public static void setSecurityManager(final SecurityManager s) {
+        if (s != null) {
+            try {
+                s.checkPackageAccess("java.lang");
+            } catch (Exception e) {
+                // no-op
+            }
         }
         setSecurityManager0(s);
     }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/CallSite.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/CallSite.java	Tue Jan 24 00:30:25 2017 +0100
@@ -28,6 +28,8 @@
 import static java.lang.invoke.MethodHandleStatics.*;
 import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
+import jdk.internal.vm.annotation.Stable;
+
 /**
  * A {@code CallSite} is a holder for a variable {@link MethodHandle},
  * which is called its {@code target}.
@@ -215,19 +217,36 @@
     public abstract MethodHandle dynamicInvoker();
 
     /*non-public*/ MethodHandle makeDynamicInvoker() {
-        MethodHandle getTarget = GET_TARGET.bindArgumentL(0, this);
+        MethodHandle getTarget = getTargetHandle().bindArgumentL(0, this);
         MethodHandle invoker = MethodHandles.exactInvoker(this.type());
         return MethodHandles.foldArguments(invoker, getTarget);
     }
 
-    private static final MethodHandle GET_TARGET;
-    private static final MethodHandle THROW_UCS;
-    static {
+    private static @Stable MethodHandle GET_TARGET;
+    private static MethodHandle getTargetHandle() {
+        MethodHandle handle = GET_TARGET;
+        if (handle != null) {
+            return handle;
+        }
         try {
-            GET_TARGET = IMPL_LOOKUP.
-                findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class));
-            THROW_UCS = IMPL_LOOKUP.
-                findStatic(CallSite.class, "uninitializedCallSite", MethodType.methodType(Object.class, Object[].class));
+            return GET_TARGET = IMPL_LOOKUP.
+                    findVirtual(CallSite.class, "getTarget",
+                                MethodType.methodType(MethodHandle.class));
+        } catch (ReflectiveOperationException e) {
+            throw newInternalError(e);
+        }
+    }
+
+    private static @Stable MethodHandle THROW_UCS;
+    private static MethodHandle uninitializedCallSiteHandle() {
+        MethodHandle handle = THROW_UCS;
+        if (handle != null) {
+            return handle;
+        }
+        try {
+            return THROW_UCS = IMPL_LOOKUP.
+                findStatic(CallSite.class, "uninitializedCallSite",
+                           MethodType.methodType(Object.class, Object[].class));
         } catch (ReflectiveOperationException e) {
             throw newInternalError(e);
         }
@@ -242,7 +261,7 @@
         MethodType basicType = targetType.basicType();
         MethodHandle invoker = basicType.form().cachedMethodHandle(MethodTypeForm.MH_UNINIT_CS);
         if (invoker == null) {
-            invoker = THROW_UCS.asType(basicType);
+            invoker = uninitializedCallSiteHandle().asType(basicType);
             invoker = basicType.form().setCachedMethodHandle(MethodTypeForm.MH_UNINIT_CS, invoker);
         }
         // unchecked view is OK since no values will be received or returned
@@ -250,12 +269,16 @@
     }
 
     // unsafe stuff:
-    private static final long  TARGET_OFFSET;
-    private static final long CONTEXT_OFFSET;
-    static {
+    private static @Stable long TARGET_OFFSET;
+    private static long getTargetOffset() {
+        long offset = TARGET_OFFSET;
+        if (offset > 0) {
+            return offset;
+        }
         try {
-            TARGET_OFFSET  = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("target"));
-            CONTEXT_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("context"));
+            offset = TARGET_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("target"));
+            assert(offset > 0);
+            return offset;
         } catch (Exception ex) { throw newInternalError(ex); }
     }
 
@@ -265,7 +288,7 @@
     }
     /*package-private*/
     MethodHandle getTargetVolatile() {
-        return (MethodHandle) UNSAFE.getObjectVolatile(this, TARGET_OFFSET);
+        return (MethodHandle) UNSAFE.getObjectVolatile(this, getTargetOffset());
     }
     /*package-private*/
     void setTargetVolatile(MethodHandle newTarget) {
@@ -324,7 +347,7 @@
                         final int NON_SPREAD_ARG_COUNT = 3;  // (caller, name, type)
                         if (NON_SPREAD_ARG_COUNT + argv.length > MethodType.MAX_MH_ARITY)
                             throw new BootstrapMethodError("too many bootstrap method arguments");
-                        MethodType bsmType = bootstrapMethod.type();
+
                         MethodType invocationType = MethodType.genericMethodType(NON_SPREAD_ARG_COUNT + argv.length);
                         MethodHandle typedBSM = bootstrapMethod.asType(invocationType);
                         MethodHandle spreader = invocationType.invokers().spreadInvoker(NON_SPREAD_ARG_COUNT);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -846,8 +846,11 @@
             // that does not bluntly restrict classes under packages within
             // java.base from looking up MethodHandles or VarHandles.
             if (allowedModes == ALL_MODES && lookupClass.getClassLoader() == null) {
-                if ((name.startsWith("java.") && !name.startsWith("java.util.concurrent.")) ||
-                        (name.startsWith("sun.") && !name.startsWith("sun.invoke."))) {
+                if ((name.startsWith("java.") &&
+                     !name.equals("java.lang.Thread") &&
+                     !name.startsWith("java.util.concurrent.")) ||
+                    (name.startsWith("sun.") &&
+                     !name.startsWith("sun.invoke."))) {
                     throw newIllegalArgumentException("illegal lookupClass: " + lookupClass);
                 }
             }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1128,7 +1128,7 @@
     public String toMethodDescriptorString() {
         String desc = methodDescriptor;
         if (desc == null) {
-            desc = BytecodeDescriptor.unparse(this);
+            desc = BytecodeDescriptor.unparseMethod(this.rtype, this.ptypes);
             methodDescriptor = desc;
         }
         return desc;
@@ -1256,7 +1256,7 @@
         private final ReferenceQueue<T> stale;
 
         public ConcurrentWeakInternSet() {
-            this.map = new ConcurrentHashMap<>();
+            this.map = new ConcurrentHashMap<>(512);
             this.stale = new ReferenceQueue<>();
         }
 
--- a/jdk/src/java.base/share/classes/java/net/SocketInputStream.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/net/SocketInputStream.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, 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
@@ -155,11 +155,12 @@
         }
 
         // bounds check
-        if (length <= 0 || off < 0 || off + length > b.length) {
+        if (length <= 0 || off < 0 || length > b.length - off) {
             if (length == 0) {
                 return 0;
             }
-            throw new ArrayIndexOutOfBoundsException();
+            throw new ArrayIndexOutOfBoundsException("length == " + length
+                    + " off == " + off + " buffer length == " + b.length);
         }
 
         boolean gotReset = false;
--- a/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, 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
@@ -97,11 +97,13 @@
      */
     private void socketWrite(byte b[], int off, int len) throws IOException {
 
-        if (len <= 0 || off < 0 || off + len > b.length) {
+
+        if (len <= 0 || off < 0 || len > b.length - off) {
             if (len == 0) {
                 return;
             }
-            throw new ArrayIndexOutOfBoundsException();
+            throw new ArrayIndexOutOfBoundsException("len == " + len
+                    + " off == " + off + " buffer length == " + b.length);
         }
 
         FileDescriptor fd = impl.acquireFD();
--- a/jdk/src/java.base/share/classes/java/net/URL.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/net/URL.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1556,9 +1556,6 @@
                 path = file;
         }
 
-        if (port == -1) {
-            port = 0;
-        }
         // Set the object fields.
         this.protocol = protocol;
         this.host = host;
--- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Tue Jan 24 00:30:25 2017 +0100
@@ -115,8 +115,8 @@
         if (security != null) {
             security.checkCreateClassLoader();
         }
-        this.ucp = new URLClassPath(urls);
         this.acc = AccessController.getContext();
+        this.ucp = new URLClassPath(urls, acc);
     }
 
     URLClassLoader(String name, URL[] urls, ClassLoader parent,
@@ -127,8 +127,8 @@
         if (security != null) {
             security.checkCreateClassLoader();
         }
-        this.ucp = new URLClassPath(urls);
         this.acc = acc;
+        this.ucp = new URLClassPath(urls, acc);
     }
 
     /**
@@ -159,8 +159,8 @@
         if (security != null) {
             security.checkCreateClassLoader();
         }
-        this.ucp = new URLClassPath(urls);
         this.acc = AccessController.getContext();
+        this.ucp = new URLClassPath(urls, acc);
     }
 
     URLClassLoader(URL[] urls, AccessControlContext acc) {
@@ -170,8 +170,8 @@
         if (security != null) {
             security.checkCreateClassLoader();
         }
-        this.ucp = new URLClassPath(urls);
         this.acc = acc;
+        this.ucp = new URLClassPath(urls, acc);
     }
 
     /**
@@ -203,8 +203,8 @@
         if (security != null) {
             security.checkCreateClassLoader();
         }
-        this.ucp = new URLClassPath(urls, factory);
         this.acc = AccessController.getContext();
+        this.ucp = new URLClassPath(urls, factory, acc);
     }
 
 
@@ -238,8 +238,8 @@
         if (security != null) {
             security.checkCreateClassLoader();
         }
-        this.ucp = new URLClassPath(urls);
         this.acc = AccessController.getContext();
+        this.ucp = new URLClassPath(urls, acc);
     }
 
     /**
@@ -271,8 +271,8 @@
         if (security != null) {
             security.checkCreateClassLoader();
         }
-        this.ucp = new URLClassPath(urls, factory);
         this.acc = AccessController.getContext();
+        this.ucp = new URLClassPath(urls, factory, acc);
     }
 
     /* A map (used as a set) to keep track of closeable local resources
--- a/jdk/src/java.base/share/classes/java/net/URLConnection.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/net/URLConnection.java	Tue Jan 24 00:30:25 2017 +0100
@@ -30,8 +30,10 @@
 import java.io.OutputStream;
 import java.security.PrivilegedAction;
 import java.util.Hashtable;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.Objects;
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
@@ -231,7 +233,7 @@
      */
     protected boolean allowUserInteraction = defaultAllowUserInteraction;
 
-    private static boolean defaultUseCaches = true;
+    private static volatile boolean defaultUseCaches = true;
 
    /**
      * If {@code true}, the protocol is allowed to use caching
@@ -243,12 +245,18 @@
      * <p>
      * Its default value is the value given in the last invocation of the
      * {@code setDefaultUseCaches} method.
+     * <p>
+     * The default setting may be overridden per protocol with
+     * {@link #setDefaultUseCaches(String,boolean)}.
      *
      * @see     java.net.URLConnection#setUseCaches(boolean)
      * @see     java.net.URLConnection#getUseCaches()
      * @see     java.net.URLConnection#setDefaultUseCaches(boolean)
      */
-    protected boolean useCaches = defaultUseCaches;
+    protected boolean useCaches;
+
+    private static final ConcurrentHashMap<String,Boolean> defaultCaching =
+        new ConcurrentHashMap<>();
 
    /**
      * Some protocols support skipping the fetching of the object unless
@@ -460,6 +468,11 @@
      */
     protected URLConnection(URL url) {
         this.url = url;
+        if (url == null) {
+            this.useCaches = defaultUseCaches;
+        } else {
+            this.useCaches = getDefaultUseCaches(url.getProtocol());
+        }
     }
 
     /**
@@ -981,7 +994,8 @@
      * is true, the connection is allowed to use whatever caches it can.
      *  If false, caches are to be ignored.
      *  The default value comes from DefaultUseCaches, which defaults to
-     * true.
+     * true. A default value can also be set per-protocol using
+     * {@link #setDefaultUseCaches(String,boolean)}.
      *
      * @param usecaches a {@code boolean} indicating whether
      * or not to allow caching
@@ -1032,9 +1046,10 @@
      * Returns the default value of a {@code URLConnection}'s
      * {@code useCaches} flag.
      * <p>
-     * Ths default is "sticky", being a part of the static state of all
+     * This default is "sticky", being a part of the static state of all
      * URLConnections.  This flag applies to the next, and all following
-     * URLConnections that are created.
+     * URLConnections that are created. This default value can be over-ridden
+     * per protocol using {@link #setDefaultUseCaches(String,boolean)}
      *
      * @return  the default value of a {@code URLConnection}'s
      *          {@code useCaches} flag.
@@ -1046,7 +1061,8 @@
 
    /**
      * Sets the default value of the {@code useCaches} field to the
-     * specified value.
+     * specified value. This default value can be over-ridden
+     * per protocol using {@link #setDefaultUseCaches(String,boolean)}
      *
      * @param   defaultusecaches   the new value.
      * @see     #getDefaultUseCaches()
@@ -1055,6 +1071,43 @@
         defaultUseCaches = defaultusecaches;
     }
 
+   /**
+     * Sets the default value of the {@code useCaches} field for the named
+     * protocol to the given value. This value overrides any default setting
+     * set by {@link #setDefaultUseCaches(boolean)} for the given protocol.
+     * Successive calls to this method change the setting and affect the
+     * default value for all future connections of that protocol. The protocol
+     * name is case insensitive.
+     *
+     * @param   protocol the protocol to set the default for
+     * @param   defaultVal whether caching is enabled by default for the given protocol
+     * @since 9
+     */
+    public static void setDefaultUseCaches(String protocol, boolean defaultVal) {
+        protocol = protocol.toLowerCase(Locale.US);
+        defaultCaching.put(protocol, defaultVal);
+    }
+
+   /**
+     * Returns the default value of the {@code useCaches} flag for the given protocol. If
+     * {@link #setDefaultUseCaches(String,boolean)} was called for the given protocol,
+     * then that value is returned. Otherwise, if {@link #setDefaultUseCaches(boolean)}
+     * was called, then that value is returned. If neither method was called,
+     * the return value is {@code true}. The protocol name is case insensitive.
+     *
+     * @param protocol the protocol whose defaultUseCaches setting is required
+     * @return  the default value of the {@code useCaches} flag for the given protocol.
+     * @since 9
+     */
+    public static boolean getDefaultUseCaches(String protocol) {
+        Boolean protoDefault = defaultCaching.get(protocol.toLowerCase(Locale.US));
+        if (protoDefault != null) {
+            return protoDefault.booleanValue();
+        } else {
+            return defaultUseCaches;
+        }
+    }
+
     /**
      * Sets the general request property. If a property with the key already
      * exists, overwrite its value with the new value.
--- a/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java	Tue Jan 24 00:30:25 2017 +0100
@@ -161,9 +161,9 @@
             (spec.charAt(start + 1) == '/')) {
             start += 2;
             i = spec.indexOf('/', start);
-            if (i < 0) {
+            if (i < 0 || i > limit) {
                 i = spec.indexOf('?', start);
-                if (i < 0)
+                if (i < 0 || i > limit)
                     i = limit;
             }
 
@@ -171,8 +171,14 @@
 
             int ind = authority.indexOf('@');
             if (ind != -1) {
-                userInfo = authority.substring(0, ind);
-                host = authority.substring(ind+1);
+                if (ind != authority.lastIndexOf('@')) {
+                    // more than one '@' in authority. This is not server based
+                    userInfo = null;
+                    host = null;
+                } else {
+                    userInfo = authority.substring(0, ind);
+                    host = authority.substring(ind+1);
+                }
             } else {
                 userInfo = null;
             }
--- a/jdk/src/java.base/share/classes/java/util/Collections.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/Collections.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -4354,6 +4354,11 @@
         private Object readResolve() {
             return EMPTY_SET;
         }
+
+        @Override
+        public int hashCode() {
+            return 0;
+        }
     }
 
     /**
@@ -4786,6 +4791,10 @@
         public boolean removeIf(Predicate<? super E> filter) {
             throw new UnsupportedOperationException();
         }
+        @Override
+        public int hashCode() {
+            return Objects.hashCode(element);
+        }
     }
 
     /**
@@ -4848,6 +4857,10 @@
         public Spliterator<E> spliterator() {
             return singletonSpliterator(element);
         }
+        @Override
+        public int hashCode() {
+            return 31 + Objects.hashCode(element);
+        }
     }
 
     /**
@@ -4970,6 +4983,11 @@
                 BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
             throw new UnsupportedOperationException();
         }
+
+        @Override
+        public int hashCode() {
+            return Objects.hashCode(k) ^ Objects.hashCode(v);
+        }
     }
 
     // Miscellaneous
--- a/jdk/src/java.base/share/classes/java/util/Date.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/Date.java	Tue Jan 24 00:30:25 2017 +0100
@@ -82,17 +82,19 @@
  * well; for example, the time scale used by the satellite-based
  * global positioning system (GPS) is synchronized to UTC but is
  * <i>not</i> adjusted for leap seconds. An interesting source of
- * further information is the U.S. Naval Observatory, particularly
- * the Directorate of Time at:
+ * further information is the United States Naval Observatory (USNO):
  * <blockquote><pre>
- *     <a href="http://www.usno.navy.mil">http://www.usno.navy.mil</a>
+ *     <a href="http://www.usno.navy.mil/USNO">http://www.usno.navy.mil/USNO</a>
  * </pre></blockquote>
  * <p>
- * and their definitions of "Systems of Time" at:
+ * and the material regarding "Systems of Time" at:
  * <blockquote><pre>
  *     <a href="http://www.usno.navy.mil/USNO/time/master-clock/systems-of-time">http://www.usno.navy.mil/USNO/time/master-clock/systems-of-time</a>
  * </pre></blockquote>
  * <p>
+ * which has descriptions of various different time systems including
+ * UT, UT1, and UTC.
+ * <p>
  * In all methods of class {@code Date} that accept or return
  * year, month, date, hours, minutes, and seconds values, the
  * following representations are used:
--- a/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
 import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.UnaryOperator;
+import jdk.internal.vm.annotation.Stable;
 
 /**
  * Container class for immutable collections. Not part of the public API.
@@ -105,6 +106,11 @@
             return null;                  // but the compiler doesn't know this
         }
 
+        @Override
+        public Iterator<E> iterator() {
+            return Collections.emptyIterator();
+        }
+
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
@@ -112,9 +118,26 @@
         private Object writeReplace() {
             return new CollSer(CollSer.IMM_LIST);
         }
+
+        @Override
+        public boolean contains(Object o) {
+            Objects.requireNonNull(o);
+            return false;
+        }
+
+        @Override
+        public boolean containsAll(Collection<?> o) {
+            return o.isEmpty(); // implicit nullcheck of o
+        }
+
+        @Override
+        public int hashCode() {
+            return 1;
+        }
     }
 
     static final class List1<E> extends AbstractImmutableList<E> {
+        @Stable
         private final E e0;
 
         List1(E e0) {
@@ -129,7 +152,6 @@
         @Override
         public E get(int index) {
             Objects.checkIndex(index, 1);
-            // assert index == 0
             return e0;
         }
 
@@ -140,10 +162,22 @@
         private Object writeReplace() {
             return new CollSer(CollSer.IMM_LIST, e0);
         }
+
+        @Override
+        public boolean contains(Object o) {
+            return o.equals(e0); // implicit nullcheck of o
+        }
+
+        @Override
+        public int hashCode() {
+            return 31 + e0.hashCode();
+        }
     }
 
     static final class List2<E> extends AbstractImmutableList<E> {
+        @Stable
         private final E e0;
+        @Stable
         private final E e1;
 
         List2(E e0, E e1) {
@@ -166,6 +200,17 @@
             }
         }
 
+        @Override
+        public boolean contains(Object o) {
+            return o.equals(e0) || o.equals(e1); // implicit nullcheck of o
+        }
+
+        @Override
+        public int hashCode() {
+            int hash = 31 + e0.hashCode();
+            return 31 * hash + e1.hashCode();
+        }
+
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
@@ -176,6 +221,7 @@
     }
 
     static final class ListN<E> extends AbstractImmutableList<E> {
+        @Stable
         private final E[] elements;
 
         @SafeVarargs
@@ -200,6 +246,25 @@
             return elements[index];
         }
 
+        @Override
+        public boolean contains(Object o) {
+            for (E e : elements) {
+                if (o.equals(e)) { // implicit nullcheck of o
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            int hash = 1;
+            for (E e : elements) {
+                hash = 31 * hash + e.hashCode();
+            }
+            return hash;
+        }
+
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
@@ -238,7 +303,13 @@
 
         @Override
         public boolean contains(Object o) {
-            return super.contains(Objects.requireNonNull(o));
+            Objects.requireNonNull(o);
+            return false;
+        }
+
+        @Override
+        public boolean containsAll(Collection<?> o) {
+            return o.isEmpty(); // implicit nullcheck of o
         }
 
         @Override
@@ -253,9 +324,15 @@
         private Object writeReplace() {
             return new CollSer(CollSer.IMM_SET);
         }
+
+        @Override
+        public int hashCode() {
+            return 0;
+        }
     }
 
     static final class Set1<E> extends AbstractImmutableSet<E> {
+        @Stable
         private final E e0;
 
         Set1(E e0) {
@@ -269,7 +346,7 @@
 
         @Override
         public boolean contains(Object o) {
-            return super.contains(Objects.requireNonNull(o));
+            return o.equals(e0); // implicit nullcheck of o
         }
 
         @Override
@@ -284,17 +361,21 @@
         private Object writeReplace() {
             return new CollSer(CollSer.IMM_SET, e0);
         }
+
+        @Override
+        public int hashCode() {
+            return e0.hashCode();
+        }
     }
 
     static final class Set2<E> extends AbstractImmutableSet<E> {
-        private final E e0;
-        private final E e1;
+        @Stable
+        final E e0;
+        @Stable
+        final E e1;
 
         Set2(E e0, E e1) {
-            Objects.requireNonNull(e0);
-            Objects.requireNonNull(e1);
-
-            if (e0.equals(e1)) {
+            if (e0.equals(Objects.requireNonNull(e1))) { // implicit nullcheck of e0
                 throw new IllegalArgumentException("duplicate element: " + e0);
             }
 
@@ -314,7 +395,12 @@
 
         @Override
         public boolean contains(Object o) {
-            return super.contains(Objects.requireNonNull(o));
+            return o.equals(e0) || o.equals(e1); // implicit nullcheck of o
+        }
+
+        @Override
+        public int hashCode() {
+            return e0.hashCode() + e1.hashCode();
         }
 
         @Override
@@ -358,8 +444,10 @@
      * @param <E> the element type
      */
     static final class SetN<E> extends AbstractImmutableSet<E> {
-        private final E[] elements;
-        private final int size;
+        @Stable
+        final E[] elements;
+        @Stable
+        final int size;
 
         @SafeVarargs
         @SuppressWarnings("unchecked")
@@ -368,8 +456,8 @@
 
             elements = (E[])new Object[EXPAND_FACTOR * input.length];
             for (int i = 0; i < input.length; i++) {
-                E e = Objects.requireNonNull(input[i]);
-                int idx = probe(e);
+                E e = input[i];
+                int idx = probe(e); // implicit nullcheck of e
                 if (idx >= 0) {
                     throw new IllegalArgumentException("duplicate element: " + e);
                 } else {
@@ -385,8 +473,7 @@
 
         @Override
         public boolean contains(Object o) {
-            Objects.requireNonNull(o);
-            return probe(o) >= 0;
+            return probe(o) >= 0; // implicit nullcheck of o
         }
 
         @Override
@@ -414,8 +501,21 @@
             };
         }
 
+        @Override
+        public int hashCode() {
+            int h = 0;
+            for (E e : elements) {
+                if (e != null) {
+                    h += e.hashCode();
+                }
+            }
+            return h;
+        }
+
         // returns index at which element is present; or if absent,
-        // (-i - 1) where i is location where element should be inserted
+        // (-i - 1) where i is location where element should be inserted.
+        // Callers are relying on this method to perform an implicit nullcheck
+        // of pe
         private int probe(Object pe) {
             int idx = Math.floorMod(pe.hashCode() ^ SALT, elements.length);
             while (true) {
@@ -481,12 +581,14 @@
 
         @Override
         public boolean containsKey(Object o) {
-            return super.containsKey(Objects.requireNonNull(o));
+            Objects.requireNonNull(o);
+            return false;
         }
 
         @Override
         public boolean containsValue(Object o) {
-            return super.containsValue(Objects.requireNonNull(o));
+            Objects.requireNonNull(o);
+            return false;
         }
 
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
@@ -496,10 +598,17 @@
         private Object writeReplace() {
             return new CollSer(CollSer.IMM_MAP);
         }
+
+        @Override
+        public int hashCode() {
+            return 0;
+        }
     }
 
     static final class Map1<K,V> extends AbstractImmutableMap<K,V> {
+        @Stable
         private final K k0;
+        @Stable
         private final V v0;
 
         Map1(K k0, V v0) {
@@ -514,12 +623,12 @@
 
         @Override
         public boolean containsKey(Object o) {
-            return super.containsKey(Objects.requireNonNull(o));
+            return o.equals(k0); // implicit nullcheck of o
         }
 
         @Override
         public boolean containsValue(Object o) {
-            return super.containsValue(Objects.requireNonNull(o));
+            return o.equals(v0); // implicit nullcheck of o
         }
 
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
@@ -529,6 +638,11 @@
         private Object writeReplace() {
             return new CollSer(CollSer.IMM_MAP, k0, v0);
         }
+
+        @Override
+        public int hashCode() {
+            return k0.hashCode() ^ v0.hashCode();
+        }
     }
 
     /**
@@ -541,12 +655,13 @@
      * @param <V> the value type
      */
     static final class MapN<K,V> extends AbstractImmutableMap<K,V> {
-        private final Object[] table; // pairs of key, value
-        private final int size; // number of pairs
+        @Stable
+        final Object[] table; // pairs of key, value
+        @Stable
+        final int size; // number of pairs
 
         MapN(Object... input) {
-            Objects.requireNonNull(input);
-            if ((input.length & 1) != 0) {
+            if ((input.length & 1) != 0) { // implicit nullcheck of input
                 throw new InternalError("length is odd");
             }
             size = input.length >> 1;
@@ -573,12 +688,30 @@
 
         @Override
         public boolean containsKey(Object o) {
-            return probe(Objects.requireNonNull(o)) >= 0;
+            return probe(o) >= 0; // implicit nullcheck of o
         }
 
         @Override
         public boolean containsValue(Object o) {
-            return super.containsValue(Objects.requireNonNull(o));
+            for (int i = 1; i < table.length; i += 2) {
+                Object v = table[i];
+                if (v != null && o.equals(v)) { // implicit nullcheck of o
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            int hash = 0;
+            for (int i = 0; i < table.length; i += 2) {
+                Object k = table[i];
+                if (k != null) {
+                    hash += k.hashCode() ^ table[i + 1].hashCode();
+                }
+            }
+            return hash;
         }
 
         @Override
@@ -638,7 +771,9 @@
         }
 
         // returns index at which the probe key is present; or if absent,
-        // (-i - 1) where i is location where element should be inserted
+        // (-i - 1) where i is location where element should be inserted.
+        // Callers are relying on this method to perform an implicit nullcheck
+        // of pk.
         private int probe(Object pk) {
             int idx = Math.floorMod(pk.hashCode() ^ SALT, table.length >> 1) << 1;
             while (true) {
--- a/jdk/src/java.base/share/classes/java/util/KeyValueHolder.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/KeyValueHolder.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
 
 package java.util;
 
+import jdk.internal.vm.annotation.Stable;
+
 /**
  * An immutable container for a key and a value, suitable for use
  * in creating and populating {@code Map} instances.
@@ -48,7 +50,9 @@
  * @since 9
  */
 final class KeyValueHolder<K,V> implements Map.Entry<K,V> {
+    @Stable
     final K key;
+    @Stable
     final V value;
 
     KeyValueHolder(K k, V v) {
--- a/jdk/src/java.base/share/classes/java/util/List.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/List.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1027,8 +1027,7 @@
     @SafeVarargs
     @SuppressWarnings("varargs")
     static <E> List<E> of(E... elements) {
-        Objects.requireNonNull(elements);
-        switch (elements.length) {
+        switch (elements.length) { // implicit null check of elements
             case 0:
                 return ImmutableCollections.List0.instance();
             case 1:
--- a/jdk/src/java.base/share/classes/java/util/Map.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/Map.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1602,8 +1602,7 @@
     @SafeVarargs
     @SuppressWarnings("varargs")
     static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
-        Objects.requireNonNull(entries);
-        if (entries.length == 0) {
+        if (entries.length == 0) { // implicit null check of entries
             return ImmutableCollections.Map0.instance();
         } else if (entries.length == 1) {
             return new ImmutableCollections.Map1<>(entries[0].getKey(),
--- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UncheckedIOException;
+import java.lang.ref.Reference;
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.SoftReference;
 import java.lang.ref.WeakReference;
@@ -365,7 +366,7 @@
                 @Override
                 public ResourceBundle getBundle(String baseName, Locale locale, Module module) {
                     // use the given module as the caller to bypass the access check
-                    return getBundleImpl(module, module, getLoader(module),
+                    return getBundleImpl(module, module,
                                          baseName, locale, Control.INSTANCE);
                 }
 
@@ -537,63 +538,19 @@
         return locale;
     }
 
-    /*
-     * Automatic determination of the ClassLoader to be used to load
-     * resources on behalf of the client.
-     */
-    private static ClassLoader getLoader(Class<?> caller) {
-        ClassLoader cl = caller == null ? null : caller.getClassLoader();
-        if (cl == null) {
-            // When the caller's loader is the boot class loader, cl is null
-            // here. In that case, ClassLoader.getSystemClassLoader() may
-            // return the same class loader that the application is
-            // using. We therefore use a wrapper ClassLoader to create a
-            // separate scope for bundles loaded on behalf of the Java
-            // runtime so that these bundles cannot be returned from the
-            // cache to the application (5048280).
-            cl = RBClassLoader.INSTANCE;
-        }
-        return cl;
-    }
-
     private static ClassLoader getLoader(Module module) {
         PrivilegedAction<ClassLoader> pa = module::getClassLoader;
         return AccessController.doPrivileged(pa);
     }
 
     /**
-     * A wrapper of ClassLoader.getSystemClassLoader().
+     * @param module a non-null-screened module form the {@link CacheKey#getModule()}.
+     * @return the ClassLoader to use in {@link Control#needsReload}
+     *         and {@link Control#newBundle}
      */
-    private static class RBClassLoader extends ClassLoader {
-        private static final RBClassLoader INSTANCE = AccessController.doPrivileged(
-                    new PrivilegedAction<RBClassLoader>() {
-                        public RBClassLoader run() {
-                            return new RBClassLoader();
-                        }
-                    });
-        private RBClassLoader() {
-        }
-        public Class<?> loadClass(String name) throws ClassNotFoundException {
-            ClassLoader loader = ClassLoader.getSystemClassLoader();
-            if (loader != null) {
-                return loader.loadClass(name);
-            }
-            return Class.forName(name);
-        }
-        public URL getResource(String name) {
-            ClassLoader loader = ClassLoader.getSystemClassLoader();
-            if (loader != null) {
-                return loader.getResource(name);
-            }
-            return ClassLoader.getSystemResource(name);
-        }
-        public InputStream getResourceAsStream(String name) {
-            ClassLoader loader = ClassLoader.getSystemClassLoader();
-            if (loader != null) {
-                return loader.getResourceAsStream(name);
-            }
-            return ClassLoader.getSystemResourceAsStream(name);
-        }
+    private static ClassLoader getLoaderForControl(Module module) {
+        ClassLoader loader = getLoader(module);
+        return loader == null ? ClassLoader.getSystemClassLoader() : loader;
     }
 
     /**
@@ -610,23 +567,23 @@
 
     /**
      * Key used for cached resource bundles.  The key checks the base
-     * name, the locale, the class loader, and the caller module
+     * name, the locale, the bundle module, and the caller module
      * to determine if the resource is a match to the requested one.
-     * The loader may be null, but the base name, the locale and
-     * module must have a non-null value.
+     * The base name, the locale and both modules must have a non-null value.
      */
-    private static class CacheKey implements Cloneable {
+    private static final class CacheKey {
         // These four are the actual keys for lookup in Map.
-        private String name;
-        private Locale locale;
-        private KeyElementReference<ClassLoader> loaderRef;
-        private KeyElementReference<Module> moduleRef;
-        private KeyElementReference<Module> callerRef;
-
+        private final String name;
+        private volatile Locale locale;
+        private final KeyElementReference<Module> moduleRef;
+        private final KeyElementReference<Module> callerRef;
+        // this is the part of hashCode that pertains to module and callerModule
+        // which can be GCed..
+        private final int modulesHash;
 
         // bundle format which is necessary for calling
         // Control.needsReload().
-        private String format;
+        private volatile String format;
 
         // These time values are in CacheKey so that NONEXISTENT_BUNDLE
         // doesn't need to be cloned for caching.
@@ -639,63 +596,55 @@
         private volatile long expirationTime;
 
         // Placeholder for an error report by a Throwable
-        private Throwable cause;
-
-        // Hash code value cache to avoid recalculating the hash code
-        // of this instance.
-        private int hashCodeCache;
+        private volatile Throwable cause;
 
         // ResourceBundleProviders for loading ResourceBundles
-        private ServiceLoader<ResourceBundleProvider> providers;
-        private boolean providersChecked;
+        private volatile ServiceLoader<ResourceBundleProvider> providers;
+        private volatile boolean providersChecked;
 
         // Boolean.TRUE if the factory method caller provides a ResourceBundleProvier.
-        private Boolean callerHasProvider;
+        private volatile Boolean callerHasProvider;
 
-        CacheKey(String baseName, Locale locale, ClassLoader loader, Module module, Module caller) {
+        CacheKey(String baseName, Locale locale, Module module, Module caller) {
             Objects.requireNonNull(module);
+            Objects.requireNonNull(caller);
 
             this.name = baseName;
             this.locale = locale;
-            if (loader == null) {
-                this.loaderRef = null;
-            } else {
-                this.loaderRef = new KeyElementReference<>(loader, referenceQueue, this);
-            }
             this.moduleRef = new KeyElementReference<>(module, referenceQueue, this);
             this.callerRef = new KeyElementReference<>(caller, referenceQueue, this);
+            this.modulesHash = module.hashCode() ^ caller.hashCode();
+        }
 
-            calculateHashCode();
+        CacheKey(CacheKey src) {
+            // Create References to src's modules
+            this.moduleRef = new KeyElementReference<>(
+                Objects.requireNonNull(src.getModule()), referenceQueue, this);
+            this.callerRef = new KeyElementReference<>(
+                Objects.requireNonNull(src.getCallerModule()), referenceQueue, this);
+            // Copy fields from src. ResourceBundleProviders related fields
+            // and "cause" should not be copied.
+            this.name = src.name;
+            this.locale = src.locale;
+            this.modulesHash = src.modulesHash;
+            this.format = src.format;
+            this.loadTime = src.loadTime;
+            this.expirationTime = src.expirationTime;
         }
 
         String getName() {
             return name;
         }
 
-        CacheKey setName(String baseName) {
-            if (!this.name.equals(baseName)) {
-                this.name = baseName;
-                calculateHashCode();
-            }
-            return this;
-        }
-
         Locale getLocale() {
             return locale;
         }
 
         CacheKey setLocale(Locale locale) {
-            if (!this.locale.equals(locale)) {
-                this.locale = locale;
-                calculateHashCode();
-            }
+            this.locale = locale;
             return this;
         }
 
-        ClassLoader getLoader() {
-            return (loaderRef != null) ? loaderRef.get() : null;
-        }
-
         Module getModule() {
             return moduleRef.get();
         }
@@ -728,7 +677,7 @@
             try {
                 final CacheKey otherEntry = (CacheKey)other;
                 //quick check to see if they are not equal
-                if (hashCodeCache != otherEntry.hashCodeCache) {
+                if (modulesHash != otherEntry.modulesHash) {
                     return false;
                 }
                 //are the names the same?
@@ -739,24 +688,11 @@
                 if (!locale.equals(otherEntry.locale)) {
                     return false;
                 }
-                //are refs (both non-null) or (both null)?
-                if (loaderRef == null) {
-                    return otherEntry.loaderRef == null;
-                }
-                ClassLoader loader = getLoader();
+                // are modules and callerModules the same and non-null?
                 Module module = getModule();
                 Module caller = getCallerModule();
-
-                return (otherEntry.loaderRef != null)
-                        // with a null reference we can no longer find
-                        // out which class loader or module was referenced; so
-                        // treat it as unequal
-                        && (loader != null)
-                        && (loader == otherEntry.getLoader())
-                        && (module != null)
-                        && (module.equals(otherEntry.getModule()))
-                        && (caller != null)
-                        && (caller.equals(otherEntry.getCallerModule()));
+                return ((module != null) && (module.equals(otherEntry.getModule())) &&
+                        (caller != null) && (caller.equals(otherEntry.getCallerModule())));
             } catch (NullPointerException | ClassCastException e) {
             }
             return false;
@@ -764,51 +700,7 @@
 
         @Override
         public int hashCode() {
-            return hashCodeCache;
-        }
-
-        private void calculateHashCode() {
-            hashCodeCache = name.hashCode() << 3;
-            hashCodeCache ^= locale.hashCode();
-            ClassLoader loader = getLoader();
-            if (loader != null) {
-                hashCodeCache ^= loader.hashCode();
-            }
-            Module module = getModule();
-            if (module != null) {
-                hashCodeCache ^= module.hashCode();
-            }
-            Module caller = getCallerModule();
-            if (caller != null) {
-                hashCodeCache ^= caller.hashCode();
-            }
-        }
-
-        @Override
-        public Object clone() {
-            try {
-                CacheKey clone = (CacheKey) super.clone();
-                if (loaderRef != null) {
-                    clone.loaderRef = new KeyElementReference<>(getLoader(),
-                                                                referenceQueue, clone);
-                }
-                clone.moduleRef = new KeyElementReference<>(getModule(),
-                                                            referenceQueue, clone);
-                clone.callerRef = new KeyElementReference<>(getCallerModule(),
-                                                            referenceQueue, clone);
-
-                // Clear the reference to ResourceBundleProviders and the flag
-                clone.providers = null;
-                clone.providersChecked = false;
-                // Clear the reference to a Throwable
-                clone.cause = null;
-                // Clear callerHasProvider
-                clone.callerHasProvider = null;
-                return clone;
-            } catch (CloneNotSupportedException e) {
-                //this should never happen
-                throw new InternalError(e);
-            }
+            return (name.hashCode() << 3) ^ locale.hashCode() ^ modulesHash;
         }
 
         String getFormat() {
@@ -845,8 +737,12 @@
                     l = "\"\"";
                 }
             }
-            return "CacheKey[" + name + ", lc=" + l + ", ldr=" + getLoader()
-                + "(format=" + format + ")]";
+            return "CacheKey[" + name +
+                   ", locale=" + l +
+                   ", module=" + getModule() +
+                   ", callerModule=" + getCallerModule() +
+                   ", format=" + format +
+                   "]";
         }
     }
 
@@ -1568,7 +1464,7 @@
                                                 Locale locale,
                                                 Class<?> caller,
                                                 Control control) {
-        return getBundleImpl(baseName, locale, caller, getLoader(caller), control);
+        return getBundleImpl(baseName, locale, caller, caller.getClassLoader(), control);
     }
 
     /**
@@ -1587,26 +1483,25 @@
                                                 Class<?> caller,
                                                 ClassLoader loader,
                                                 Control control) {
-        if (caller != null && caller.getModule().isNamed()) {
-            Module module = caller.getModule();
-            ClassLoader ml = getLoader(module);
-            // get resource bundles for a named module only
-            // if loader is the module's class loader
-            if (loader == ml || (ml == null && loader == RBClassLoader.INSTANCE)) {
-                return getBundleImpl(module, module, loader, baseName, locale, control);
-            }
-        }
-        // find resource bundles from unnamed module
-        Module unnamedModule = loader != null
-            ? loader.getUnnamedModule()
-            : ClassLoader.getSystemClassLoader().getUnnamedModule();
-
         if (caller == null) {
             throw new InternalError("null caller");
         }
+        Module callerModule = caller.getModule();
 
-        Module callerModule = caller.getModule();
-        return getBundleImpl(callerModule, unnamedModule, loader, baseName, locale, control);
+        // get resource bundles for a named module only if loader is the module's class loader
+        if (callerModule.isNamed() && loader == getLoader(callerModule)) {
+            return getBundleImpl(callerModule, callerModule, baseName, locale, control);
+        }
+
+        // find resource bundles from unnamed module of given class loader
+        // Java agent can add to the bootclasspath e.g. via
+        // java.lang.instrument.Instrumentation and load classes in unnamed module.
+        // It may call RB::getBundle that will end up here with loader == null.
+        Module unnamedModule = loader != null
+            ? loader.getUnnamedModule()
+            : BootLoader.getUnnamedModule();
+
+        return getBundleImpl(callerModule, unnamedModule, baseName, locale, control);
     }
 
     private static ResourceBundle getBundleFromModule(Class<?> caller,
@@ -1622,12 +1517,11 @@
                 sm.checkPermission(GET_CLASSLOADER_PERMISSION);
             }
         }
-        return getBundleImpl(callerModule, module, getLoader(module), baseName, locale, control);
+        return getBundleImpl(callerModule, module, baseName, locale, control);
     }
 
     private static ResourceBundle getBundleImpl(Module callerModule,
                                                 Module module,
-                                                ClassLoader loader,
                                                 String baseName,
                                                 Locale locale,
                                                 Control control) {
@@ -1636,10 +1530,10 @@
         }
 
         // We create a CacheKey here for use by this call. The base name
-        // loader, and module will never change during the bundle loading
+        // and modules will never change during the bundle loading
         // process. We have to make sure that the locale is set before
         // using it as a cache key.
-        CacheKey cacheKey = new CacheKey(baseName, locale, loader, module, callerModule);
+        CacheKey cacheKey = new CacheKey(baseName, locale, module, callerModule);
         ResourceBundle bundle = null;
 
         // Quick lookup of the cache.
@@ -1708,6 +1602,11 @@
             bundle = baseBundle;
         }
 
+        // keep callerModule and module reachable for as long as we are operating
+        // with WeakReference(s) to them (in CacheKey)...
+        Reference.reachabilityFence(callerModule);
+        Reference.reachabilityFence(module);
+
         return bundle;
     }
 
@@ -1745,7 +1644,7 @@
         }
 
         // Before we do the real loading work, see whether we need to
-        // do some housekeeping: If references to class loaders or
+        // do some housekeeping: If references to modules or
         // resource bundles have been nulled out, remove all related
         // information from the cache.
         Object ref;
@@ -1781,31 +1680,24 @@
         }
 
         if (bundle != NONEXISTENT_BUNDLE) {
-            CacheKey constKey = (CacheKey) cacheKey.clone();
             trace("findBundle: %d %s %s formats: %s%n", index, candidateLocales, cacheKey, formats);
-            try {
-                if (module.isNamed()) {
-                    bundle = loadBundle(cacheKey, formats, control, module, callerModule);
-                } else {
-                    bundle = loadBundle(cacheKey, formats, control, expiredBundle);
+            if (module.isNamed()) {
+                bundle = loadBundle(cacheKey, formats, control, module, callerModule);
+            } else {
+                bundle = loadBundle(cacheKey, formats, control, expiredBundle);
+            }
+            if (bundle != null) {
+                if (bundle.parent == null) {
+                    bundle.setParent(parent);
                 }
-                if (bundle != null) {
-                    if (bundle.parent == null) {
-                        bundle.setParent(parent);
-                    }
-                    bundle.locale = targetLocale;
-                    bundle = putBundleInCache(cacheKey, bundle, control);
-                    return bundle;
-                }
+                bundle.locale = targetLocale;
+                bundle = putBundleInCache(cacheKey, bundle, control);
+                return bundle;
+            }
 
-                // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle
-                // instance for the locale.
-                putBundleInCache(cacheKey, NONEXISTENT_BUNDLE, control);
-            } finally {
-                if (constKey.getCause() instanceof InterruptedException) {
-                    Thread.currentThread().interrupt();
-                }
-            }
+            // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle
+            // instance for the locale.
+            putBundleInCache(cacheKey, NONEXISTENT_BUNDLE, control);
         }
         return parent;
     }
@@ -1991,12 +1883,20 @@
         // specified by the getFormats() value.
         Locale targetLocale = cacheKey.getLocale();
 
+        Module module = cacheKey.getModule();
+        if (module == null) {
+            // should not happen
+            throw new InternalError(
+                "Module for cache key: " + cacheKey + " has been GCed.");
+        }
+        ClassLoader loader = getLoaderForControl(module);
+
         ResourceBundle bundle = null;
         for (String format : formats) {
             try {
                 // ResourceBundle.Control.newBundle may be overridden
                 bundle = control.newBundle(cacheKey.getName(), targetLocale, format,
-                                           cacheKey.getLoader(), reload);
+                                           loader, reload);
             } catch (LinkageError | Exception error) {
                 // We need to handle the LinkageError case due to
                 // inconsistent case-sensitivity in ClassLoader.
@@ -2138,12 +2038,15 @@
                         if (!bundle.expired && expirationTime >= 0 &&
                             expirationTime <= System.currentTimeMillis()) {
                             try {
-                                bundle.expired = control.needsReload(key.getName(),
-                                                                     key.getLocale(),
-                                                                     key.getFormat(),
-                                                                     key.getLoader(),
-                                                                     bundle,
-                                                                     key.loadTime);
+                                Module module = cacheKey.getModule();
+                                bundle.expired =
+                                    module == null || // already GCed
+                                    control.needsReload(key.getName(),
+                                                        key.getLocale(),
+                                                        key.getFormat(),
+                                                        getLoaderForControl(module),
+                                                        bundle,
+                                                        key.loadTime);
                             } catch (Exception e) {
                                 cacheKey.setCause(e);
                             }
@@ -2185,7 +2088,7 @@
                                                    Control control) {
         setExpirationTime(cacheKey, control);
         if (cacheKey.expirationTime != Control.TTL_DONT_CACHE) {
-            CacheKey key = (CacheKey) cacheKey.clone();
+            CacheKey key = new CacheKey(cacheKey);
             BundleReference bundleRef = new BundleReference(bundle, referenceQueue, key);
             bundle.cacheKey = key;
 
@@ -2231,7 +2134,7 @@
 
     /**
      * Removes all resource bundles from the cache that have been loaded
-     * by the caller's module using the caller's class loader.
+     * by the caller's module.
      *
      * @since 1.6
      * @see ResourceBundle.Control#getTimeToLive(String,Locale)
@@ -2239,47 +2142,29 @@
     @CallerSensitive
     public static final void clearCache() {
         Class<?> caller = Reflection.getCallerClass();
-        clearCache(getLoader(caller), caller.getModule());
+        cacheList.keySet().removeIf(
+            key -> key.getCallerModule() == caller.getModule()
+        );
     }
 
     /**
      * Removes all resource bundles from the cache that have been loaded
-     * by the caller's module using the given class loader.
+     * by the given class loader.
      *
      * @param loader the class loader
      * @exception NullPointerException if <code>loader</code> is null
      * @since 1.6
      * @see ResourceBundle.Control#getTimeToLive(String,Locale)
      */
-    @CallerSensitive
     public static final void clearCache(ClassLoader loader) {
         Objects.requireNonNull(loader);
-        clearCache(loader, Reflection.getCallerClass().getModule());
-    }
-
-    /**
-     * Removes all resource bundles from the cache that have been loaded by the
-     * given {@code module}.
-     *
-     * @param module the module
-     * @throws NullPointerException
-     *         if {@code module} is {@code null}
-     * @throws SecurityException
-     *         if the caller doesn't have the permission to
-     *         {@linkplain Module#getClassLoader() get the class loader}
-     *         of the given {@code module}
-     * @since 9
-     * @see ResourceBundle.Control#getTimeToLive(String,Locale)
-     */
-    public static final void clearCache(Module module) {
-        clearCache(module.getClassLoader(), module);
-    }
-
-    private static void clearCache(ClassLoader loader, Module module) {
-        Set<CacheKey> set = cacheList.keySet();
-        set.stream()
-           .filter((key) -> (key.getLoader() == loader && key.getModule() == module))
-           .forEach(set::remove);
+        cacheList.keySet().removeIf(
+            key -> {
+                Module m;
+                return (m = key.getModule()) != null &&
+                       getLoader(m) == loader;
+            }
+        );
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/util/Set.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/Set.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -689,8 +689,7 @@
     @SafeVarargs
     @SuppressWarnings("varargs")
     static <E> Set<E> of(E... elements) {
-        Objects.requireNonNull(elements);
-        switch (elements.length) {
+        switch (elements.length) { // implicit null check of elements
             case 0:
                 return ImmutableCollections.Set0.instance();
             case 1:
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java	Tue Jan 24 00:30:25 2017 +0100
@@ -185,7 +185,14 @@
     static final class InnocuousForkJoinWorkerThread extends ForkJoinWorkerThread {
         /** The ThreadGroup for all InnocuousForkJoinWorkerThreads */
         private static final ThreadGroup innocuousThreadGroup =
-            ThreadLocalRandom.createThreadGroup("InnocuousForkJoinWorkerThreadGroup");
+                java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedAction<>() {
+                        public ThreadGroup run() {
+                            ThreadGroup group = Thread.currentThread().getThreadGroup();
+                            for (ThreadGroup p; (p = group.getParent()) != null; )
+                                group = p;
+                            return new ThreadGroup(group, "InnocuousForkJoinWorkerThreadGroup");
+                        }});
 
         /** An AccessControlContext supporting no privileges */
         private static final AccessControlContext INNOCUOUS_ACC =
@@ -215,6 +222,5 @@
         public void setContextClassLoader(ClassLoader cl) {
             throw new SecurityException("setContextClassLoader");
         }
-
     }
 }
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java	Tue Jan 24 00:30:25 2017 +0100
@@ -985,34 +985,6 @@
         U.putObjectRelease(thread, INHERITEDACCESSCONTROLCONTEXT, acc);
     }
 
-    /**
-     * Returns a new group with the system ThreadGroup (the
-     * topmost, parent-less group) as parent.  Uses Unsafe to
-     * traverse Thread.group and ThreadGroup.parent fields.
-     */
-    static final ThreadGroup createThreadGroup(String name) {
-        if (name == null)
-            throw new NullPointerException();
-        try {
-            long tg = U.objectFieldOffset
-                (Thread.class.getDeclaredField("group"));
-            long gp = U.objectFieldOffset
-                (ThreadGroup.class.getDeclaredField("parent"));
-            ThreadGroup group = (ThreadGroup)
-                U.getObject(Thread.currentThread(), tg);
-            while (group != null) {
-                ThreadGroup parent = (ThreadGroup)U.getObject(group, gp);
-                if (parent == null)
-                    return new ThreadGroup(group, name);
-                group = parent;
-            }
-        } catch (ReflectiveOperationException e) {
-            throw new Error(e);
-        }
-        // fall through if null as cannot-happen safeguard
-        throw new Error("Cannot create ThreadGroup");
-    }
-
     // Serialization support
 
     private static final long serialVersionUID = -5851777807851030925L;
@@ -1087,17 +1059,17 @@
     static {
         try {
             SEED = U.objectFieldOffset
-                (Thread.class.getDeclaredField("threadLocalRandomSeed"));
+                    (Thread.class.getDeclaredField("threadLocalRandomSeed"));
             PROBE = U.objectFieldOffset
-                (Thread.class.getDeclaredField("threadLocalRandomProbe"));
+                    (Thread.class.getDeclaredField("threadLocalRandomProbe"));
             SECONDARY = U.objectFieldOffset
-                (Thread.class.getDeclaredField("threadLocalRandomSecondarySeed"));
+                    (Thread.class.getDeclaredField("threadLocalRandomSecondarySeed"));
             THREADLOCALS = U.objectFieldOffset
-                (Thread.class.getDeclaredField("threadLocals"));
+                    (Thread.class.getDeclaredField("threadLocals"));
             INHERITABLETHREADLOCALS = U.objectFieldOffset
-                (Thread.class.getDeclaredField("inheritableThreadLocals"));
+                    (Thread.class.getDeclaredField("inheritableThreadLocals"));
             INHERITEDACCESSCONTROLCONTEXT = U.objectFieldOffset
-                (Thread.class.getDeclaredField("inheritedAccessControlContext"));
+                    (Thread.class.getDeclaredField("inheritedAccessControlContext"));
         } catch (ReflectiveOperationException e) {
             throw new Error(e);
         }
@@ -1123,7 +1095,7 @@
     // at end of <clinit> to survive static initialization circularity
     static {
         if (java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<Boolean>() {
+            new java.security.PrivilegedAction<>() {
                 public Boolean run() {
                     return Boolean.getBoolean("java.util.secureRandomSeed");
                 }})) {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Tue Jan 24 00:30:25 2017 +0100
@@ -40,6 +40,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.Objects;
 import java.util.function.IntBinaryOperator;
 import java.util.function.IntUnaryOperator;
 import jdk.internal.misc.Unsafe;
@@ -411,7 +412,17 @@
             if (!Modifier.isVolatile(modifiers))
                 throw new IllegalArgumentException("Must be volatile type");
 
-            this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass;
+            // Access to protected field members is restricted to receivers only
+            // of the accessing class, or one of its subclasses, and the
+            // accessing class must in turn be a subclass (or package sibling)
+            // of the protected member's defining class.
+            // If the updater refers to a protected field of a declaring class
+            // outside the current package, the receiver argument will be
+            // narrowed to the type of the accessing class.
+            this.cclass = (Modifier.isProtected(modifiers) &&
+                           tclass.isAssignableFrom(caller) &&
+                           !isSamePackage(tclass, caller))
+                          ? caller : tclass;
             this.tclass = tclass;
             this.offset = U.objectFieldOffset(field);
         }
@@ -433,6 +444,15 @@
         }
 
         /**
+         * Returns true if the two classes have the same class loader and
+         * package qualifier
+         */
+        private static boolean isSamePackage(Class<?> class1, Class<?> class2) {
+            return class1.getClassLoader() == class2.getClassLoader()
+                   && Objects.equals(class1.getPackageName(), class2.getPackageName());
+        }
+
+        /**
          * Checks that target argument is instance of cclass.  On
          * failure, throws cause.
          */
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Tue Jan 24 00:30:25 2017 +0100
@@ -40,6 +40,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.Objects;
 import java.util.function.LongBinaryOperator;
 import java.util.function.LongUnaryOperator;
 import jdk.internal.misc.Unsafe;
@@ -409,7 +410,17 @@
             if (!Modifier.isVolatile(modifiers))
                 throw new IllegalArgumentException("Must be volatile type");
 
-            this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass;
+            // Access to protected field members is restricted to receivers only
+            // of the accessing class, or one of its subclasses, and the
+            // accessing class must in turn be a subclass (or package sibling)
+            // of the protected member's defining class.
+            // If the updater refers to a protected field of a declaring class
+            // outside the current package, the receiver argument will be
+            // narrowed to the type of the accessing class.
+            this.cclass = (Modifier.isProtected(modifiers) &&
+                           tclass.isAssignableFrom(caller) &&
+                           !isSamePackage(tclass, caller))
+                          ? caller : tclass;
             this.tclass = tclass;
             this.offset = U.objectFieldOffset(field);
         }
@@ -540,7 +551,17 @@
             if (!Modifier.isVolatile(modifiers))
                 throw new IllegalArgumentException("Must be volatile type");
 
-            this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass;
+            // Access to protected field members is restricted to receivers only
+            // of the accessing class, or one of its subclasses, and the
+            // accessing class must in turn be a subclass (or package sibling)
+            // of the protected member's defining class.
+            // If the updater refers to a protected field of a declaring class
+            // outside the current package, the receiver argument will be
+            // narrowed to the type of the accessing class.
+            this.cclass = (Modifier.isProtected(modifiers) &&
+                           tclass.isAssignableFrom(caller) &&
+                           !isSamePackage(tclass, caller))
+                          ? caller : tclass;
             this.tclass = tclass;
             this.offset = U.objectFieldOffset(field);
         }
@@ -621,4 +642,13 @@
         } while (acl != null);
         return false;
     }
+
+    /**
+     * Returns true if the two classes have the same class loader and
+     * package qualifier
+     */
+    static boolean isSamePackage(Class<?> class1, Class<?> class2) {
+        return class1.getClassLoader() == class2.getClassLoader()
+               && Objects.equals(class1.getPackageName(), class2.getPackageName());
+    }
 }
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Tue Jan 24 00:30:25 2017 +0100
@@ -40,6 +40,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.Objects;
 import java.util.function.BinaryOperator;
 import java.util.function.UnaryOperator;
 import jdk.internal.misc.Unsafe;
@@ -351,7 +352,17 @@
             if (!Modifier.isVolatile(modifiers))
                 throw new IllegalArgumentException("Must be volatile type");
 
-            this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass;
+            // Access to protected field members is restricted to receivers only
+            // of the accessing class, or one of its subclasses, and the
+            // accessing class must in turn be a subclass (or package sibling)
+            // of the protected member's defining class.
+            // If the updater refers to a protected field of a declaring class
+            // outside the current package, the receiver argument will be
+            // narrowed to the type of the accessing class.
+            this.cclass = (Modifier.isProtected(modifiers) &&
+                           tclass.isAssignableFrom(caller) &&
+                           !isSamePackage(tclass, caller))
+                          ? caller : tclass;
             this.tclass = tclass;
             this.vclass = vclass;
             this.offset = U.objectFieldOffset(field);
@@ -374,6 +385,15 @@
         }
 
         /**
+         * Returns true if the two classes have the same class loader and
+         * package qualifier
+         */
+        private static boolean isSamePackage(Class<?> class1, Class<?> class2) {
+            return class1.getClassLoader() == class2.getClassLoader()
+                   && Objects.equals(class1.getPackageName(), class2.getPackageName());
+        }
+
+        /**
          * Checks that target argument is instance of cclass.  On
          * failure, throws cause.
          */
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java	Tue Jan 24 00:30:25 2017 +0100
@@ -41,7 +41,6 @@
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.function.DoubleBinaryOperator;
 import java.util.function.LongBinaryOperator;
-import jdk.internal.misc.Unsafe;
 
 /**
  * A package-local class holding common representation and mechanics
@@ -191,7 +190,7 @@
      * Duplicated from ThreadLocalRandom because of packaging restrictions.
      */
     static final int getProbe() {
-        return U.getInt(Thread.currentThread(), PROBE);
+        return (int) THREAD_PROBE.get(Thread.currentThread());
     }
 
     /**
@@ -203,7 +202,7 @@
         probe ^= probe << 13;   // xorshift
         probe ^= probe >>> 17;
         probe ^= probe << 5;
-        U.putInt(Thread.currentThread(), PROBE, probe);
+        THREAD_PROBE.set(Thread.currentThread(), probe);
         return probe;
     }
 
@@ -373,18 +372,28 @@
         }
     }
 
-    // Unsafe and VarHandle mechanics
-    private static final Unsafe U = Unsafe.getUnsafe();
+    // VarHandle mechanics
     private static final VarHandle BASE;
     private static final VarHandle CELLSBUSY;
-    private static final long PROBE;
+    private static final VarHandle THREAD_PROBE;
     static {
         try {
             MethodHandles.Lookup l = MethodHandles.lookup();
-            BASE = l.findVarHandle(Striped64.class, "base", long.class);
-            CELLSBUSY = l.findVarHandle(Striped64.class, "cellsBusy", int.class);
-            PROBE = U.objectFieldOffset
-                (Thread.class.getDeclaredField("threadLocalRandomProbe"));
+            BASE = l.findVarHandle(Striped64.class,
+                    "base", long.class);
+            CELLSBUSY = l.findVarHandle(Striped64.class,
+                    "cellsBusy", int.class);
+            l = java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedAction<>() {
+                        public MethodHandles.Lookup run() {
+                            try {
+                                return MethodHandles.privateLookupIn(Thread.class, MethodHandles.lookup());
+                            } catch (ReflectiveOperationException e) {
+                                throw new Error(e);
+                            }
+                        }});
+            THREAD_PROBE = l.findVarHandle(Thread.class,
+                    "threadLocalRandomProbe", int.class);
         } catch (ReflectiveOperationException e) {
             throw new Error(e);
         }
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java	Tue Jan 24 00:30:25 2017 +0100
@@ -425,11 +425,11 @@
     static {
         try {
             PARKBLOCKER = U.objectFieldOffset
-                (Thread.class.getDeclaredField("parkBlocker"));
+                    (Thread.class.getDeclaredField("parkBlocker"));
             SECONDARY = U.objectFieldOffset
-                (Thread.class.getDeclaredField("threadLocalRandomSecondarySeed"));
+                    (Thread.class.getDeclaredField("threadLocalRandomSecondarySeed"));
             TID = U.objectFieldOffset
-                (Thread.class.getDeclaredField("tid"));
+                    (Thread.class.getDeclaredField("tid"));
 
         } catch (ReflectiveOperationException e) {
             throw new Error(e);
--- a/jdk/src/java.base/share/classes/javax/net/ssl/HandshakeCompletedEvent.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/HandshakeCompletedEvent.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, 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
@@ -120,6 +120,9 @@
      * Note: This method can be used only when using certificate-based
      * cipher suites; using it with non-certificate-based cipher suites,
      * such as Kerberos, will throw an SSLPeerUnverifiedException.
+     * <P>
+     * Note: The returned value may not be a valid certificate chain
+     * and should not be relied on for trust decisions.
      *
      * @return an ordered array of the peer certificates,
      *          with the peer's own certificate first followed by
@@ -140,6 +143,9 @@
      * Note: This method can be used only when using certificate-based
      * cipher suites; using it with non-certificate-based cipher suites,
      * such as Kerberos, will throw an SSLPeerUnverifiedException.
+     * <P>
+     * Note: The returned value may not be a valid certificate chain
+     * and should not be relied on for trust decisions.
      *
      * <p><em>Note: this method exists for compatibility with previous
      * releases. New applications should use
--- a/jdk/src/java.base/share/classes/javax/net/ssl/HttpsURLConnection.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/HttpsURLConnection.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, 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
@@ -104,6 +104,9 @@
      * Note: This method can be used only when using certificate-based
      * cipher suites; using it with non-certificate-based cipher suites,
      * such as Kerberos, will throw an SSLPeerUnverifiedException.
+     * <P>
+     * Note: The returned value may not be a valid certificate chain
+     * and should not be relied on for trust decisions.
      *
      * @return an ordered array of server certificates,
      *          with the peer's own certificate first followed by
--- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLSession.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLSession.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, 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
@@ -219,6 +219,9 @@
      * Note: This method can be used only when using certificate-based
      * cipher suites; using it with non-certificate-based cipher suites,
      * such as Kerberos, will throw an SSLPeerUnverifiedException.
+     * <P>
+     * Note: The returned value may not be a valid certificate chain
+     * and should not be relied on for trust decisions.
      *
      * @return an ordered array of peer certificates,
      *          with the peer's own certificate first followed by any
@@ -259,6 +262,9 @@
      * Note: This method can be used only when using certificate-based
      * cipher suites; using it with non-certificate-based cipher suites,
      * such as Kerberos, will throw an SSLPeerUnverifiedException.
+     * <P>
+     * Note: The returned value may not be a valid certificate chain
+     * and should not be relied on for trust decisions.
      *
      * <p><em>Note: this method exists for compatibility with previous
      * releases. New applications should use
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java	Tue Jan 24 00:30:25 2017 +0100
@@ -38,6 +38,7 @@
 import java.net.URLConnection;
 import java.net.URLStreamHandler;
 import java.net.URLStreamHandlerFactory;
+import java.security.AccessControlContext;
 import java.security.AccessControlException;
 import java.security.AccessController;
 import java.security.CodeSigner;
@@ -83,6 +84,7 @@
     private static final String JAVA_VERSION;
     private static final boolean DEBUG;
     private static final boolean DISABLE_JAR_CHECKING;
+    private static final boolean DISABLE_ACC_CHECKING;
 
     static {
         Properties props = GetPropertyAction.privilegedGetProperties();
@@ -90,6 +92,9 @@
         DEBUG = (props.getProperty("sun.misc.URLClassPath.debug") != null);
         String p = props.getProperty("sun.misc.URLClassPath.disableJarChecking");
         DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
+
+        p = props.getProperty("jdk.net.URLClassPath.disableRestrictedPermissions");
+        DISABLE_ACC_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
     }
 
     /* The original search path of URLs. */
@@ -110,6 +115,11 @@
     /* Whether this URLClassLoader has been closed yet */
     private boolean closed = false;
 
+    /* The context to be used when loading classes and resources.  If non-null
+     * this is the context that was captured during the creation of the
+     * URLClassLoader. null implies no additional security restrictions. */
+    private final AccessControlContext acc;
+
     /**
      * Creates a new URLClassPath for the given URLs. The URLs will be
      * searched in the order specified for classes and resources. A URL
@@ -119,8 +129,12 @@
      * @param urls the directory and JAR file URLs to search for classes
      *        and resources
      * @param factory the URLStreamHandlerFactory to use when creating new URLs
+     * @param acc the context to be used when loading classes and resources, may
+     *            be null
      */
-    public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) {
+    public URLClassPath(URL[] urls,
+                        URLStreamHandlerFactory factory,
+                        AccessControlContext acc) {
         for (int i = 0; i < urls.length; i++) {
             path.add(urls[i]);
         }
@@ -128,10 +142,22 @@
         if (factory != null) {
             jarHandler = factory.createURLStreamHandler("jar");
         }
+        if (DISABLE_ACC_CHECKING)
+            this.acc = null;
+        else
+            this.acc = acc;
     }
 
+    /**
+     * Constructs a URLClassPath with no additional security restrictions.
+     * Used by code that implements the class path.
+     */
     public URLClassPath(URL[] urls) {
-        this(urls, null);
+        this(urls, null, null);
+    }
+
+    public URLClassPath(URL[] urls, AccessControlContext acc) {
+        this(urls, null, acc);
     }
 
     public synchronized List<IOException> closeLoaders() {
@@ -356,6 +382,14 @@
             } catch (IOException e) {
                 // Silently ignore for now...
                 continue;
+            } catch (SecurityException se) {
+                // Always silently ignore. The context, if there is one, that
+                // this URLClassPath was given during construction will never
+                // have permission to access the URL.
+                if (DEBUG) {
+                    System.err.println("Failed to access " + url + ", " + se );
+                }
+                continue;
             }
             // Finally, add the Loader to the search path.
             loaders.add(loader);
@@ -378,7 +412,7 @@
                             && file != null && (file.indexOf("!/") == file.length() - 2)) {
                         // extract the nested URL
                         URL nestedUrl = new URL(file.substring(0, file.length() - 2));
-                        return new JarLoader(nestedUrl, jarHandler, lmap);
+                        return new JarLoader(nestedUrl, jarHandler, lmap, acc);
                     } else if (file != null && file.endsWith("/")) {
                         if ("file".equals(protocol)) {
                             return new FileLoader(url);
@@ -386,10 +420,10 @@
                             return new Loader(url);
                         }
                     } else {
-                        return new JarLoader(url, jarHandler, lmap);
+                        return new JarLoader(url, jarHandler, lmap, acc);
                     }
                 }
-            });
+            }, acc);
         } catch (java.security.PrivilegedActionException pae) {
             throw (IOException)pae.getException();
         }
@@ -585,10 +619,11 @@
      */
     static class JarLoader extends Loader {
         private JarFile jar;
-        private URL csu;
+        private final URL csu;
         private JarIndex index;
         private URLStreamHandler handler;
-        private HashMap<String, Loader> lmap;
+        private final HashMap<String, Loader> lmap;
+        private final AccessControlContext acc;
         private boolean closed = false;
         private static final JavaUtilZipFileAccess zipAccess =
                 SharedSecrets.getJavaUtilZipFileAccess();
@@ -598,13 +633,15 @@
          * a JAR file.
          */
         JarLoader(URL url, URLStreamHandler jarHandler,
-                  HashMap<String, Loader> loaderMap)
+                  HashMap<String, Loader> loaderMap,
+                  AccessControlContext acc)
             throws IOException
         {
             super(new URL("jar", "", -1, url + "!/", jarHandler));
             csu = url;
             handler = jarHandler;
             lmap = loaderMap;
+            this.acc = acc;
 
             ensureOpen();
         }
@@ -663,8 +700,7 @@
                                 }
                                 return null;
                             }
-                        }
-                    );
+                        }, acc);
                 } catch (java.security.PrivilegedActionException pae) {
                     throw (IOException)pae.getException();
                 }
@@ -859,9 +895,9 @@
                                 new PrivilegedExceptionAction<>() {
                                     public JarLoader run() throws IOException {
                                         return new JarLoader(url, handler,
-                                            lmap);
+                                            lmap, acc);
                                     }
-                                });
+                                }, acc);
 
                             /* this newly opened jar file has its own index,
                              * merge it into the parent's index, taking into
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.module;
+
+import java.io.PrintStream;
+import java.lang.module.Configuration;
+import java.lang.module.ResolvedModule;
+import java.net.URI;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayDeque;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import static java.util.stream.Collectors.*;
+
+/**
+ * A Builder to compute ModuleHashes from a given configuration
+ */
+public class ModuleHashesBuilder {
+    private final Configuration configuration;
+    private final Set<String> hashModuleCandidates;
+
+    /**
+     * Constructs a ModuleHashesBuilder that finds the packaged modules
+     * from the location of ModuleReference found from the given Configuration.
+     *
+     * @param config Configuration for building module hashes
+     * @param modules the candidate modules to be hashed
+     */
+    public ModuleHashesBuilder(Configuration config, Set<String> modules) {
+        this.configuration = config;
+        this.hashModuleCandidates = modules;
+    }
+
+    /**
+     * Returns a map of a module M to ModuleHashes for the modules
+     * that depend upon M directly or indirectly.
+     *
+     * The key for each entry in the returned map is a module M that has
+     * no outgoing edges to any of the candidate modules to be hashed
+     * i.e. M is a leaf node in a connected subgraph containing M and
+     * other candidate modules from the module graph filtering
+     * the outgoing edges from M to non-candidate modules.
+     */
+    public Map<String, ModuleHashes> computeHashes(Set<String> roots) {
+        // build a graph containing the the packaged modules and
+        // its transitive dependences matching --hash-modules
+        Graph.Builder<String> builder = new Graph.Builder<>();
+        Deque<ResolvedModule> deque = new ArrayDeque<>(configuration.modules());
+        Set<ResolvedModule> visited = new HashSet<>();
+        while (!deque.isEmpty()) {
+            ResolvedModule rm = deque.pop();
+            if (!visited.contains(rm)) {
+                visited.add(rm);
+                builder.addNode(rm.name());
+                for (ResolvedModule dm : rm.reads()) {
+                    if (!visited.contains(dm)) {
+                        deque.push(dm);
+                    }
+                    builder.addEdge(rm.name(), dm.name());
+                }
+            }
+        }
+
+        // each node in a transposed graph is a matching packaged module
+        // in which the hash of the modules that depend upon it is recorded
+        Graph<String> transposedGraph = builder.build().transpose();
+
+        // traverse the modules in topological order that will identify
+        // the modules to record the hashes - it is the first matching
+        // module and has not been hashed during the traversal.
+        Set<String> mods = new HashSet<>();
+        Map<String, ModuleHashes> hashes = new HashMap<>();
+        builder.build()
+               .orderedNodes()
+               .filter(mn -> roots.contains(mn) && !mods.contains(mn))
+               .forEach(mn -> {
+                   // Compute hashes of the modules that depend on mn directly and
+                   // indirectly excluding itself.
+                   Set<String> ns = transposedGraph.dfs(mn)
+                       .stream()
+                       .filter(n -> !n.equals(mn) && hashModuleCandidates.contains(n))
+                       .collect(toSet());
+                   mods.add(mn);
+                   mods.addAll(ns);
+
+                   if (!ns.isEmpty()) {
+                       Map<String, Path> moduleToPath = ns.stream()
+                           .collect(toMap(Function.identity(), this::moduleToPath));
+                       hashes.put(mn, ModuleHashes.generate(moduleToPath, "SHA-256"));
+                   }
+               });
+        return hashes;
+    }
+
+    private Path moduleToPath(String name) {
+        ResolvedModule rm = configuration.findModule(name).orElseThrow(
+            () -> new InternalError("Selected module " + name + " not on module path"));
+
+        URI uri = rm.reference().location().get();
+        Path path = Paths.get(uri);
+        String fn = path.getFileName().toString();
+        if (!fn.endsWith(".jar") && !fn.endsWith(".jmod")) {
+            throw new UnsupportedOperationException(path + " is not a modular JAR or jmod file");
+        }
+        return path;
+    }
+
+    /*
+     * Utilty class
+     */
+    static class Graph<T> {
+        private final Set<T> nodes;
+        private final Map<T, Set<T>> edges;
+
+        public Graph(Set<T> nodes, Map<T, Set<T>> edges) {
+            this.nodes = Collections.unmodifiableSet(nodes);
+            this.edges = Collections.unmodifiableMap(edges);
+        }
+
+        public Set<T> nodes() {
+            return nodes;
+        }
+
+        public Map<T, Set<T>> edges() {
+            return edges;
+        }
+
+        public Set<T> adjacentNodes(T u) {
+            return edges.get(u);
+        }
+
+        public boolean contains(T u) {
+            return nodes.contains(u);
+        }
+
+        /**
+         * Returns nodes sorted in topological order.
+         */
+        public Stream<T> orderedNodes() {
+            TopoSorter<T> sorter = new TopoSorter<>(this);
+            return sorter.result.stream();
+        }
+
+        /**
+         * Traverse this graph and performs the given action in topological order
+         */
+        public void ordered(Consumer<T> action) {
+            TopoSorter<T> sorter = new TopoSorter<>(this);
+            sorter.ordered(action);
+        }
+
+        /**
+         * Traverses this graph and performs the given action in reverse topological order
+         */
+        public void reverse(Consumer<T> action) {
+            TopoSorter<T> sorter = new TopoSorter<>(this);
+            sorter.reverse(action);
+        }
+
+        /**
+         * Returns a transposed graph from this graph
+         */
+        public Graph<T> transpose() {
+            Builder<T> builder = new Builder<>();
+            nodes.stream().forEach(builder::addNode);
+            // reverse edges
+            edges.keySet().forEach(u -> {
+                edges.get(u).stream()
+                    .forEach(v -> builder.addEdge(v, u));
+            });
+            return builder.build();
+        }
+
+        /**
+         * Returns all nodes reachable from the given root.
+         */
+        public Set<T> dfs(T root) {
+            return dfs(Set.of(root));
+        }
+
+        /**
+         * Returns all nodes reachable from the given set of roots.
+         */
+        public Set<T> dfs(Set<T> roots) {
+            Deque<T> deque = new LinkedList<>(roots);
+            Set<T> visited = new HashSet<>();
+            while (!deque.isEmpty()) {
+                T u = deque.pop();
+                if (!visited.contains(u)) {
+                    visited.add(u);
+                    if (contains(u)) {
+                        adjacentNodes(u).stream()
+                            .filter(v -> !visited.contains(v))
+                            .forEach(deque::push);
+                    }
+                }
+            }
+            return visited;
+        }
+
+        public void printGraph(PrintStream out) {
+            out.println("graph for " + nodes);
+            nodes.stream()
+                .forEach(u -> adjacentNodes(u).stream()
+                    .forEach(v -> out.format("  %s -> %s%n", u, v)));
+        }
+
+        static class Builder<T> {
+            final Set<T> nodes = new HashSet<>();
+            final Map<T, Set<T>> edges = new HashMap<>();
+
+            public void addNode(T node) {
+                if (nodes.contains(node)) {
+                    return;
+                }
+                nodes.add(node);
+                edges.computeIfAbsent(node, _e -> new HashSet<>());
+            }
+
+            public void addEdge(T u, T v) {
+                addNode(u);
+                addNode(v);
+                edges.get(u).add(v);
+            }
+
+            public Graph<T> build() {
+                return new Graph<T>(nodes, edges);
+            }
+        }
+    }
+
+    /**
+     * Topological sort
+     */
+    private static class TopoSorter<T> {
+        final Deque<T> result = new LinkedList<>();
+        final Deque<T> nodes;
+        final Graph<T> graph;
+
+        TopoSorter(Graph<T> graph) {
+            this.graph = graph;
+            this.nodes = new LinkedList<>(graph.nodes);
+            sort();
+        }
+
+        public void ordered(Consumer<T> action) {
+            result.iterator().forEachRemaining(action);
+        }
+
+        public void reverse(Consumer<T> action) {
+            result.descendingIterator().forEachRemaining(action);
+        }
+
+        private void sort() {
+            Deque<T> visited = new LinkedList<>();
+            Deque<T> done = new LinkedList<>();
+            T node;
+            while ((node = nodes.poll()) != null) {
+                if (!visited.contains(node)) {
+                    visit(node, visited, done);
+                }
+            }
+        }
+
+        private void visit(T node, Deque<T> visited, Deque<T> done) {
+            if (visited.contains(node)) {
+                if (!done.contains(node)) {
+                    throw new IllegalArgumentException("Cyclic detected: " +
+                        node + " " + graph.edges().get(node));
+                }
+                return;
+            }
+            visited.add(node);
+            graph.edges().get(node).stream()
+                .forEach(x -> visit(x, visited, done));
+            done.add(node);
+            result.addLast(node);
+        }
+    }
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java	Tue Jan 24 00:30:25 2017 +0100
@@ -29,6 +29,7 @@
 import java.util.*;
 import java.util.jar.*;
 import java.util.zip.*;
+import static sun.security.action.GetPropertyAction.privilegedGetProperty;
 
 /**
  * This class is used to maintain mappings from packages, classes
@@ -72,7 +73,7 @@
      * be added to the index. Otherwise, just the directory names are added.
      */
     private static final boolean metaInfFilenames =
-        "true".equals(System.getProperty("sun.misc.JarIndex.metaInfFilenames"));
+        "true".equals(privilegedGetProperty("sun.misc.JarIndex.metaInfFilenames"));
 
     /**
      * Constructs a new, empty jar index.
--- a/jdk/src/java.base/share/classes/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -249,7 +249,6 @@
         jdk.crypto.token;
     exports sun.security.jca to
         java.smartcardio,
-        java.xml.crypto,
         jdk.crypto.ec,
         jdk.crypto.token,
         jdk.naming.dns;
@@ -279,6 +278,7 @@
         java.security.jgss,
         java.security.sasl,
         java.smartcardio,
+        java.xml.crypto,
         jdk.crypto.ec,
         jdk.crypto.token,
         jdk.jartool,
@@ -290,6 +290,8 @@
         jdk.crypto.token,
         jdk.jartool,
         jdk.security.auth;
+    exports sun.security.validator to
+        jdk.jartool;
     exports sun.text.resources to
         jdk.localedata;
     exports sun.util.cldr to
@@ -308,7 +310,6 @@
     // JDK-internal service types
     uses jdk.internal.logger.DefaultLoggerFinder;
     uses sun.security.ssl.ClientKeyExchangeService;
-    uses sun.security.util.AuthResourcesProvider;
     uses sun.text.spi.JavaTimeDateTimePatternProvider;
     uses sun.util.spi.CalendarProvider;
     uses sun.util.locale.provider.LocaleDataMetaInfo;
@@ -320,6 +321,4 @@
 
     provides java.nio.file.spi.FileSystemProvider with
         jdk.internal.jrtfs.JrtFileSystemProvider;
-    provides sun.security.util.AuthResourcesProvider with
-        sun.security.util.AuthResourcesProviderImpl;
 }
--- a/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java	Tue Jan 24 00:30:25 2017 +0100
@@ -96,7 +96,7 @@
 
         final Class<?> declaringClass = m.getDeclaringClass();
 
-        checkPackageAccess(declaringClass);
+        privateCheckPackageAccess(sm, declaringClass);
 
         if (Modifier.isPublic(m.getModifiers()) &&
                 Modifier.isPublic(declaringClass.getModifiers()))
@@ -114,9 +114,27 @@
      * also check the package access on the proxy interfaces.
      */
     public static void checkPackageAccess(Class<?> clazz) {
-        checkPackageAccess(clazz.getName());
+        SecurityManager s = System.getSecurityManager();
+        if (s != null) {
+            privateCheckPackageAccess(s, clazz);
+        }
+    }
+
+    /**
+     * NOTE: should only be called if a SecurityManager is installed
+     */
+    private static void privateCheckPackageAccess(SecurityManager s, Class<?> clazz) {
+        while (clazz.isArray()) {
+            clazz = clazz.getComponentType();
+        }
+
+        String pkg = clazz.getPackageName();
+        if (pkg != null && !pkg.isEmpty()) {
+            s.checkPackageAccess(pkg);
+        }
+
         if (isNonPublicProxyClass(clazz)) {
-            checkProxyPackageAccess(clazz);
+            privateCheckProxyPackageAccess(s, clazz);
         }
     }
 
@@ -195,15 +213,21 @@
     public static void checkProxyPackageAccess(Class<?> clazz) {
         SecurityManager s = System.getSecurityManager();
         if (s != null) {
-            // check proxy interfaces if the given class is a proxy class
-            if (Proxy.isProxyClass(clazz)) {
-                for (Class<?> intf : clazz.getInterfaces()) {
-                    checkPackageAccess(intf);
-                }
+            privateCheckProxyPackageAccess(s, clazz);
+        }
+    }
+
+    /**
+     * NOTE: should only be called if a SecurityManager is installed
+     */
+    private static void privateCheckProxyPackageAccess(SecurityManager s, Class<?> clazz) {
+        // check proxy interfaces if the given class is a proxy class
+        if (Proxy.isProxyClass(clazz)) {
+            for (Class<?> intf : clazz.getInterfaces()) {
+                privateCheckPackageAccess(s, intf);
             }
         }
     }
-
     /**
      * Access check on the interfaces that a proxy class implements and throw
      * {@code SecurityException} if it accesses a restricted package from
@@ -220,7 +244,7 @@
             for (Class<?> intf : interfaces) {
                 ClassLoader cl = intf.getClassLoader();
                 if (needsPackageAccessCheck(ccl, cl)) {
-                    checkPackageAccess(intf);
+                    privateCheckPackageAccess(sm, intf);
                 }
             }
         }
@@ -236,10 +260,11 @@
      * package that bypasses checkPackageAccess.
      */
     public static boolean isNonPublicProxyClass(Class<?> cls) {
-        String name = cls.getName();
-        int i = name.lastIndexOf('.');
-        String pkg = (i != -1) ? name.substring(0, i) : "";
-        return Proxy.isProxyClass(cls) && !pkg.startsWith(PROXY_PACKAGE);
+        if (!Proxy.isProxyClass(cls)) {
+            return false;
+        }
+        String pkg = cls.getPackageName();
+        return pkg == null || !pkg.startsWith(PROXY_PACKAGE);
     }
 
     /**
@@ -255,7 +280,7 @@
         // check if it is a valid proxy instance
         if (proxy == null || !Proxy.isProxyClass(proxy.getClass())) {
             throw new IllegalArgumentException("Not a Proxy instance");
-}
+        }
         if (Modifier.isStatic(method.getModifiers())) {
             throw new IllegalArgumentException("Can't handle static method");
         }
--- a/jdk/src/java.base/share/classes/sun/security/provider/ConfigFile.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/provider/ConfigFile.java	Tue Jan 24 00:30:25 2017 +0100
@@ -331,9 +331,8 @@
                 if (debugConfig != null) {
                     debugConfig.println(fnfe.toString());
                 }
-                throw new IOException(ResourcesMgr.getString
-                    ("Configuration.Error.No.such.file.or.directory",
-                    "sun.security.util.AuthResources"));
+                throw new IOException(ResourcesMgr.getAuthResourceString
+                    ("Configuration.Error.No.such.file.or.directory"));
             }
         }
 
@@ -661,8 +660,8 @@
         }
 
         private IOException ioException(String resourceKey, Object... args) {
-            MessageFormat form = new MessageFormat(ResourcesMgr.getString
-                (resourceKey, "sun.security.util.AuthResources"));
+            MessageFormat form = new MessageFormat(
+                ResourcesMgr.getAuthResourceString(resourceKey));
             return new IOException(form.format(args));
         }
     }
--- a/jdk/src/java.base/share/classes/sun/security/provider/DSA.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/provider/DSA.java	Tue Jan 24 00:30:25 2017 +0100
@@ -322,19 +322,20 @@
         } else {
             // first decode the signature.
             try {
-                DerInputStream in = new DerInputStream(signature, offset,
-                                                       length);
+                // Enforce strict DER checking for signatures
+                DerInputStream in =
+                    new DerInputStream(signature, offset, length, false);
                 DerValue[] values = in.getSequence(2);
 
+                // check number of components in the read sequence
+                // and trailing data
+                if ((values.length != 2) || (in.available() != 0)) {
+                    throw new IOException("Invalid encoding for signature");
+                }
                 r = values[0].getBigInteger();
                 s = values[1].getBigInteger();
-
-                // Check for trailing signature data
-                if (in.available() != 0) {
-                    throw new IOException("Incorrect signature length");
-                }
             } catch (IOException e) {
-                throw new SignatureException("invalid encoding for signature");
+                throw new SignatureException("Invalid encoding for signature", e);
             }
         }
 
@@ -427,13 +428,49 @@
         return t5.mod(q);
     }
 
-    // NOTE: This following impl is defined in FIPS 186-4 AppendixB.2.1.
     protected BigInteger generateK(BigInteger q) {
+        // Implementation defined in FIPS 186-4 AppendixB.2.1.
         SecureRandom random = getSigningRandom();
         byte[] kValue = new byte[(q.bitLength() + 7)/8 + 8];
 
         random.nextBytes(kValue);
-        return new BigInteger(1, kValue).mod(q.subtract(BigInteger.ONE)).add(BigInteger.ONE);
+        BigInteger k = new BigInteger(1, kValue).mod(
+                q.subtract(BigInteger.ONE)).add(BigInteger.ONE);
+
+        // Using an equivalent exponent of fixed length (same as q or 1 bit
+        // less than q) to keep the kG timing relatively constant.
+        //
+        // Note that this is an extra step on top of the approach defined in
+        // FIPS 186-4 AppendixB.2.1 so as to make a fixed length K.
+        k = k.add(q).divide(BigInteger.TWO);
+
+        // An alternative implementation based on FIPS 186-4 AppendixB2.2
+        // with fixed-length K.
+        //
+        // Please keep it here as we may need to switch to it in the future.
+        //
+        // SecureRandom random = getSigningRandom();
+        // byte[] kValue = new byte[(q.bitLength() + 7)/8];
+        // BigInteger d = q.subtract(BigInteger.TWO);
+        // BigInteger k;
+        // do {
+        //     random.nextBytes(kValue);
+        //     BigInteger c = new BigInteger(1, kValue);
+        //     if (c.compareTo(d) <= 0) {
+        //         k = c.add(BigInteger.ONE);
+        //         // Using an equivalent exponent of fixed length to keep
+        //         // the g^k timing relatively constant.
+        //         //
+        //         // Note that this is an extra step on top of the approach
+        //         // defined in FIPS 186-4 AppendixB.2.2 so as to make a
+        //         // fixed length K.
+        //         if (k.bitLength() >= q.bitLength()) {
+        //             break;
+        //         }
+        //     }
+        // } while (true);
+
+        return k;
     }
 
     // Use the application-specified SecureRandom Object if provided.
--- a/jdk/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java	Tue Jan 24 00:30:25 2017 +0100
@@ -34,6 +34,7 @@
 
 import javax.security.auth.Subject;
 import sun.security.provider.PolicyParser.PrincipalEntry;
+import sun.security.util.ResourcesMgr;
 
 /**
  * <p> This <code>SubjectCodeSource</code> class contains
@@ -47,15 +48,6 @@
 
     private static final long serialVersionUID = 6039418085604715275L;
 
-    private static final java.util.ResourceBundle rb =
-        java.security.AccessController.doPrivileged
-        (new java.security.PrivilegedAction<java.util.ResourceBundle>() {
-            public java.util.ResourceBundle run() {
-                return (java.util.ResourceBundle.getBundle
-                        ("sun.security.util.AuthResources"));
-            }
-        });
-
     private Subject subject;
     private LinkedList<PrincipalEntry> principals;
     private static final Class<?>[] PARAMS = { String.class };
@@ -391,7 +383,7 @@
             ListIterator<PrincipalEntry> li = principals.listIterator();
             while (li.hasNext()) {
                 PrincipalEntry pppe = li.next();
-                returnMe = returnMe + rb.getString("NEWLINE") +
+                returnMe = returnMe + ResourcesMgr.getAuthResourceString("NEWLINE") +
                         pppe.getPrincipalClass() + " " +
                         pppe.getPrincipalName();
             }
--- a/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java	Tue Jan 24 00:30:25 2017 +0100
@@ -226,9 +226,10 @@
      * Decode the signature data. Verify that the object identifier matches
      * and return the message digest.
      */
-    public static byte[] decodeSignature(ObjectIdentifier oid, byte[] signature)
+    public static byte[] decodeSignature(ObjectIdentifier oid, byte[] sig)
             throws IOException {
-        DerInputStream in = new DerInputStream(signature);
+        // Enforce strict DER checking for signatures
+        DerInputStream in = new DerInputStream(sig, 0, sig.length, false);
         DerValue[] values = in.getSequence(2);
         if ((values.length != 2) || (in.available() != 0)) {
             throw new IOException("SEQUENCE length error");
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java	Tue Jan 24 00:30:25 2017 +0100
@@ -673,8 +673,11 @@
             } else {
                 // we wanted to resume, but the server refused
                 //
-                // Invalidate the session in case of reusing next time.
-                session.invalidate();
+                // Invalidate the session for initial handshake in case
+                // of reusing next time.
+                if (isInitialHandshake) {
+                    session.invalidate();
+                }
                 session = null;
                 if (!enableNewSession) {
                     throw new SSLException("New session creation is disabled");
--- a/jdk/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -818,6 +818,11 @@
             checker.init(false);
         } catch (CertPathValidatorException cpve) {
             // unlikely to happen
+            if (useDebug) {
+                debug.println(
+                    "Cannot initialize algorithm constraints checker: " + cpve);
+            }
+
             return false;
         }
 
@@ -828,6 +833,11 @@
                 // We don't care about the unresolved critical extensions.
                 checker.check(cert, Collections.<String>emptySet());
             } catch (CertPathValidatorException cpve) {
+                if (useDebug) {
+                    debug.println("Certificate (" + cert +
+                        ") does not conform to algorithm constraints: " + cpve);
+                }
+
                 return false;
             }
         }
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3522,7 +3522,8 @@
             System.err.flush();
             reply = (new BufferedReader(new InputStreamReader
                                         (System.in))).readLine();
-            if (collator.compare(reply, "") == 0 ||
+            if (reply == null ||
+                collator.compare(reply, "") == 0 ||
                 collator.compare(reply, rb.getString("n")) == 0 ||
                 collator.compare(reply, rb.getString("no")) == 0) {
                 reply = "NO";
--- a/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProvider.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.util;
-
-public interface AuthResourcesProvider extends java.util.spi.ResourceBundleProvider {
-}
--- a/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProviderImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.util;
-
-import java.util.spi.AbstractResourceBundleProvider;
-
-public final class AuthResourcesProviderImpl extends AbstractResourceBundleProvider
-       implements AuthResourcesProvider {
-    public AuthResourcesProviderImpl() {
-        super("java.class");
-    }
-}
\ No newline at end of file
--- a/jdk/src/java.base/share/classes/sun/security/util/DerInputBuffer.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/util/DerInputBuffer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -147,6 +147,11 @@
         System.arraycopy(buf, pos, bytes, 0, len);
         skip(len);
 
+        // check to make sure no extra leading 0s for DER
+        if (len >= 2 && (bytes[0] == 0) && (bytes[1] >= 0)) {
+            throw new IOException("Invalid encoding: redundant leading 0s");
+        }
+
         if (makePositive) {
             return new BigInteger(1, bytes);
         } else {
--- a/jdk/src/java.base/share/classes/sun/security/util/DerInputStream.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/util/DerInputStream.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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,7 +77,7 @@
      * @param data the buffer from which to create the string (CONSUMED)
      */
     public DerInputStream(byte[] data) throws IOException {
-        init(data, 0, data.length);
+        init(data, 0, data.length, true);
     }
 
     /**
@@ -92,23 +92,48 @@
      *          starting at "offset"
      */
     public DerInputStream(byte[] data, int offset, int len) throws IOException {
-        init(data, offset, len);
+        init(data, offset, len, true);
+    }
+
+    /**
+     * Create a DER input stream from part of a data buffer with
+     * additional arg to indicate whether to allow constructed
+     * indefinite-length encoding.
+     * The buffer is not copied, it is shared.  Accordingly, the
+     * buffer should be treated as read-only.
+     *
+     * @param data the buffer from which to create the string (CONSUMED)
+     * @param offset the first index of <em>data</em> which will
+     *          be read as DER input in the new stream
+     * @param len how long a chunk of the buffer to use,
+     *          starting at "offset"
+     * @param allowIndefiniteLength whether to allow constructed
+     *          indefinite-length encoding
+     */
+    public DerInputStream(byte[] data, int offset, int len,
+        boolean allowIndefiniteLength) throws IOException {
+        init(data, offset, len, allowIndefiniteLength);
     }
 
     /*
      * private helper routine
      */
-    private void init(byte[] data, int offset, int len) throws IOException {
+    private void init(byte[] data, int offset, int len,
+        boolean allowIndefiniteLength) throws IOException {
         if ((offset+2 > data.length) || (offset+len > data.length)) {
             throw new IOException("Encoding bytes too short");
         }
         // check for indefinite length encoding
         if (DerIndefLenConverter.isIndefinite(data[offset+1])) {
-            byte[] inData = new byte[len];
-            System.arraycopy(data, offset, inData, 0, len);
+            if (!allowIndefiniteLength) {
+                throw new IOException("Indefinite length BER encoding found");
+            } else {
+                byte[] inData = new byte[len];
+                System.arraycopy(data, offset, inData, 0, len);
 
-            DerIndefLenConverter derIn = new DerIndefLenConverter();
-            buffer = new DerInputBuffer(derIn.convert(inData));
+                DerIndefLenConverter derIn = new DerIndefLenConverter();
+                buffer = new DerInputBuffer(derIn.convert(inData));
+            }
         } else
             buffer = new DerInputBuffer(data, offset, len);
         buffer.mark(Integer.MAX_VALUE);
@@ -239,15 +264,19 @@
          * representation.
          */
         length--;
-        int validBits = length*8 - buffer.read();
+        int excessBits = buffer.read();
+        if (excessBits < 0) {
+            throw new IOException("Unused bits of bit string invalid");
+        }
+        int validBits = length*8 - excessBits;
         if (validBits < 0) {
-            throw new IOException("valid bits of bit string invalid");
+            throw new IOException("Valid bits of bit string invalid");
         }
 
         byte[] repn = new byte[length];
 
         if ((length != 0) && (buffer.read(repn) != length)) {
-            throw new IOException("short read of DER bit string");
+            throw new IOException("Short read of DER bit string");
         }
 
         return new BitArray(validBits, repn);
@@ -263,7 +292,7 @@
         int length = getDefiniteLength(buffer);
         byte[] retval = new byte[length];
         if ((length != 0) && (buffer.read(retval) != length))
-            throw new IOException("short read of DER octet string");
+            throw new IOException("Short read of DER octet string");
 
         return retval;
     }
@@ -273,7 +302,7 @@
      */
     public void getBytes(byte[] val) throws IOException {
         if ((val.length != 0) && (buffer.read(val) != val.length)) {
-            throw new IOException("short read of DER octet string");
+            throw new IOException("Short read of DER octet string");
         }
     }
 
@@ -357,7 +386,7 @@
         DerInputStream  newstr;
 
         byte lenByte = (byte)buffer.read();
-        int len = getLength((lenByte & 0xff), buffer);
+        int len = getLength(lenByte, buffer);
 
         if (len == -1) {
            // indefinite length encoding found
@@ -403,7 +432,7 @@
         } while (newstr.available() > 0);
 
         if (newstr.available() != 0)
-            throw new IOException("extra data at end of vector");
+            throw new IOException("Extra data at end of vector");
 
         /*
          * Now stick them into the array we're returning.
@@ -494,7 +523,7 @@
         int length = getDefiniteLength(buffer);
         byte[] retval = new byte[length];
         if ((length != 0) && (buffer.read(retval) != length))
-            throw new IOException("short read of DER " +
+            throw new IOException("Short read of DER " +
                                   stringName + " string");
 
         return new String(retval, enc);
@@ -555,7 +584,11 @@
      */
     static int getLength(int lenByte, InputStream in) throws IOException {
         int value, tmp;
+        if (lenByte == -1) {
+            throw new IOException("Short read of DER length");
+        }
 
+        String mdName = "DerInputStream.getLength(): ";
         tmp = lenByte;
         if ((tmp & 0x080) == 0x00) { // short form, 1 byte datum
             value = tmp;
@@ -569,17 +602,23 @@
             if (tmp == 0)
                 return -1;
             if (tmp < 0 || tmp > 4)
-                throw new IOException("DerInputStream.getLength(): lengthTag="
-                    + tmp + ", "
+                throw new IOException(mdName + "lengthTag=" + tmp + ", "
                     + ((tmp < 0) ? "incorrect DER encoding." : "too big."));
 
-            for (value = 0; tmp > 0; tmp --) {
+            value = 0x0ff & in.read();
+            tmp--;
+            if (value == 0) {
+                // DER requires length value be encoded in minimum number of bytes
+                throw new IOException(mdName + "Redundant length bytes found");
+            }
+            while (tmp-- > 0) {
                 value <<= 8;
                 value += 0x0ff & in.read();
             }
             if (value < 0) {
-                throw new IOException("DerInputStream.getLength(): "
-                        + "Invalid length bytes");
+                throw new IOException(mdName + "Invalid length bytes");
+            } else if (value <= 127) {
+                throw new IOException(mdName + "Should use short form for length");
             }
         }
         return value;
--- a/jdk/src/java.base/share/classes/sun/security/util/DerValue.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/util/DerValue.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -248,7 +248,7 @@
 
         tag = (byte)in.read();
         byte lenByte = (byte)in.read();
-        length = DerInputStream.getLength((lenByte & 0xff), in);
+        length = DerInputStream.getLength(lenByte, in);
         if (length == -1) {  // indefinite length encoding found
             DerInputBuffer inbuf = in.dup();
             int readLen = inbuf.available();
@@ -361,7 +361,7 @@
 
         tag = (byte)in.read();
         byte lenByte = (byte)in.read();
-        length = DerInputStream.getLength((lenByte & 0xff), in);
+        length = DerInputStream.getLength(lenByte, in);
         if (length == -1) { // indefinite length encoding found
             int readLen = in.available();
             int offset = 2;     // for tag and length bytes
--- a/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java	Tue Jan 24 00:30:25 2017 +0100
@@ -255,7 +255,13 @@
                 + " (tag = " +  type_id + ")"
                 );
 
-        encoding = new byte[in.getDefiniteLength()];
+        int len = in.getDefiniteLength();
+        if (len > in.available()) {
+            throw new IOException("ObjectIdentifier() -- length exceeds" +
+                    "data available.  Length: " + len + ", Available: " +
+                    in.available());
+        }
+        encoding = new byte[len];
         in.getBytes(encoding);
         check(encoding);
     }
--- a/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java	Tue Jan 24 00:30:25 2017 +0100
@@ -25,18 +25,22 @@
 
 package sun.security.util;
 
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentHashMap;
+import jdk.internal.misc.VM;
+
 /**
  */
 public class ResourcesMgr {
+    // intended for java.security, javax.security and sun.security resources
+    private final static String RESOURCES = "sun.security.util.Resources";
+    private final static String AUTH_RESOURCES = "sun.security.util.AuthResources";
 
-    // intended for java.security, javax.security and sun.security resources
-    private static java.util.ResourceBundle bundle;
-
-    // intended for com.sun.security resources
-    private static java.util.ResourceBundle altBundle;
+    private final static Map<String, ResourceBundle> bundles = new ConcurrentHashMap<>();
 
     public static String getString(String s) {
-
+        ResourceBundle bundle = bundles.get(RESOURCES);
         if (bundle == null) {
 
             // only load if/when needed
@@ -52,19 +56,15 @@
         return bundle.getString(s);
     }
 
-    public static String getString(String s, final String altBundleName) {
-
-        if (altBundle == null) {
-
-            // only load if/when needed
-            altBundle = java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<java.util.ResourceBundle>() {
-                public java.util.ResourceBundle run() {
-                    return (java.util.ResourceBundle.getBundle(altBundleName));
-                }
-            });
+    public static String getAuthResourceString(String s) {
+        if (VM.initLevel() == 3) {
+            // cannot trigger loading of any resource bundle as
+            // it depends on the system class loader fully initialized.
+            throw new InternalError("system class loader is being initialized");
         }
 
-        return altBundle.getString(s);
+        return bundles.computeIfAbsent(AUTH_RESOURCES, ResourceBundle::getBundle)
+                      .getString(s);
     }
+
 }
--- a/jdk/src/java.base/share/conf/security/java.security	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/conf/security/java.security	Tue Jan 24 00:30:25 2017 +0100
@@ -298,111 +298,24 @@
 
 #
 # List of comma-separated packages that start with or equal this string
-# will cause a security exception to be thrown when
-# passed to checkPackageAccess unless the
-# corresponding RuntimePermission ("accessClassInPackage."+package) has
-# been granted.
-package.access=sun.,\
-               com.sun.xml.internal.,\
-               com.sun.imageio.,\
-               com.sun.istack.internal.,\
-               com.sun.jmx.,\
-               com.sun.media.sound.,\
-               com.sun.naming.internal.,\
-               com.sun.proxy.,\
-               com.sun.corba.se.,\
-               com.sun.org.apache.bcel.internal.,\
-               com.sun.org.apache.regexp.internal.,\
-               com.sun.org.apache.xerces.internal.,\
-               com.sun.org.apache.xpath.internal.,\
-               com.sun.org.apache.xalan.internal.extensions.,\
-               com.sun.org.apache.xalan.internal.lib.,\
-               com.sun.org.apache.xalan.internal.res.,\
-               com.sun.org.apache.xalan.internal.templates.,\
-               com.sun.org.apache.xalan.internal.utils.,\
-               com.sun.org.apache.xalan.internal.xslt.,\
-               com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
-               com.sun.org.apache.xalan.internal.xsltc.compiler.,\
-               com.sun.org.apache.xalan.internal.xsltc.trax.,\
-               com.sun.org.apache.xalan.internal.xsltc.util.,\
-               com.sun.org.apache.xml.internal.res.,\
-               com.sun.org.apache.xml.internal.security.,\
-               com.sun.org.apache.xml.internal.serializer.dom3.,\
-               com.sun.org.apache.xml.internal.serializer.utils.,\
-               com.sun.org.apache.xml.internal.utils.,\
-               com.sun.org.glassfish.,\
-               com.sun.tools.script.,\
-               com.oracle.xmlns.internal.,\
-               com.oracle.webservices.internal.,\
-               org.jcp.xml.dsig.internal.,\
-               jdk.internal.,\
-               jdk.nashorn.internal.,\
-               jdk.nashorn.tools.,\
-               jdk.tools.jimage.,\
-               com.sun.activation.registries.,\
-               com.sun.java.accessibility.util.internal.,\
-#ifdef windows
-               com.sun.java.accessibility.internal.,\
-#endif
-#ifdef macosx
-               apple.,\
-#endif
+# will cause a security exception to be thrown when passed to the
+# SecurityManager::checkPackageAccess method unless the corresponding
+# RuntimePermission("accessClassInPackage."+package) has been granted.
+#
+package.access=sun.misc.,\
+               sun.reflect.,\
 
 #
 # List of comma-separated packages that start with or equal this string
-# will cause a security exception to be thrown when
-# passed to checkPackageDefinition unless the
-# corresponding RuntimePermission ("defineClassInPackage."+package) has
-# been granted.
+# will cause a security exception to be thrown when passed to the
+# SecurityManager::checkPackageDefinition method unless the corresponding
+# RuntimePermission("defineClassInPackage."+package) has been granted.
 #
-# by default, none of the class loaders supplied with the JDK call
+# By default, none of the class loaders supplied with the JDK call
 # checkPackageDefinition.
 #
-package.definition=sun.,\
-                   com.sun.xml.internal.,\
-                   com.sun.imageio.,\
-                   com.sun.istack.internal.,\
-                   com.sun.jmx.,\
-                   com.sun.media.sound.,\
-                   com.sun.naming.internal.,\
-                   com.sun.proxy.,\
-                   com.sun.corba.se.,\
-                   com.sun.org.apache.bcel.internal.,\
-                   com.sun.org.apache.regexp.internal.,\
-                   com.sun.org.apache.xerces.internal.,\
-                   com.sun.org.apache.xpath.internal.,\
-                   com.sun.org.apache.xalan.internal.extensions.,\
-                   com.sun.org.apache.xalan.internal.lib.,\
-                   com.sun.org.apache.xalan.internal.res.,\
-                   com.sun.org.apache.xalan.internal.templates.,\
-                   com.sun.org.apache.xalan.internal.utils.,\
-                   com.sun.org.apache.xalan.internal.xslt.,\
-                   com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
-                   com.sun.org.apache.xalan.internal.xsltc.compiler.,\
-                   com.sun.org.apache.xalan.internal.xsltc.trax.,\
-                   com.sun.org.apache.xalan.internal.xsltc.util.,\
-                   com.sun.org.apache.xml.internal.res.,\
-                   com.sun.org.apache.xml.internal.security.,\
-                   com.sun.org.apache.xml.internal.serializer.dom3.,\
-                   com.sun.org.apache.xml.internal.serializer.utils.,\
-                   com.sun.org.apache.xml.internal.utils.,\
-                   com.sun.org.glassfish.,\
-                   com.sun.tools.script.,\
-                   com.oracle.xmlns.internal.,\
-                   com.oracle.webservices.internal.,\
-                   org.jcp.xml.dsig.internal.,\
-                   jdk.internal.,\
-                   jdk.nashorn.internal.,\
-                   jdk.nashorn.tools.,\
-                   jdk.tools.jimage.,\
-                   com.sun.activation.registries.,\
-                   com.sun.java.accessibility.util.internal.,\
-#ifdef windows
-                   com.sun.java.accessibility.internal.,\
-#endif
-#ifdef macosx
-                   apple.,\
-#endif
+package.definition=sun.misc.,\
+                   sun.reflect.,\
 
 #
 # Determines whether this properties file can be appended to
@@ -658,6 +571,36 @@
 jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & denyAfter 2017-01-01, \
     RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224
 
+#
+# RMI Registry Serial Filter
+#
+# The filter pattern uses the same format as jdk.serialFilter.
+# This filter can override the builtin filter if additional types need to be
+# allowed or rejected from the RMI Registry.
+#
+# Note: This property is currently used by the JDK Reference implementation.
+# It is not guaranteed to be examined and used by other implementations.
+#
+#sun.rmi.registry.registryFilter=pattern;pattern
+#
+# RMI Distributed Garbage Collector (DGC) Serial Filter
+#
+# The filter pattern uses the same format as jdk.serialFilter.
+# This filter can override the builtin filter if additional types need to be
+# allowed or rejected from the RMI DGC.
+#
+# Note: This property is currently used by the JDK Reference implementation.
+# It is not guaranteed to be examined and used by other implementations.
+#
+# The builtin DGC filter can approximately be represented as the filter pattern:
+#
+#sun.rmi.transport.dgcFilter=\
+#    java.rmi.server.ObjID;\
+#    java.rmi.server.UID;\
+#    java.rmi.dgc.VMID;\
+#    java.rmi.dgc.Lease;\
+#    maxdepth=5;maxarray=10000
+
 # Algorithm restrictions for signed JAR files
 #
 # In some environments, certain algorithms or key lengths may be undesirable
@@ -720,7 +663,7 @@
 # Note: The algorithm restrictions do not apply to trust anchors or
 # self-signed certificates.
 #
-# Note: This property is currently used by Oracle's JSSE implementation.
+# Note: This property is currently used by the JDK Reference implementation.
 # It is not guaranteed to be examined and used by other implementations.
 #
 # Example:
@@ -740,7 +683,7 @@
 # During SSL/TLS security parameters negotiation, legacy algorithms will
 # not be negotiated unless there are no other candidates.
 #
-# The syntax of the disabled algorithm string is described as this Java
+# The syntax of the legacy algorithms string is described as this Java
 # BNF-style:
 #   LegacyAlgorithms:
 #       " LegacyAlgorithm { , LegacyAlgorithm } "
@@ -776,7 +719,7 @@
 # javax.net.ssl.SSLParameters.setAlgorithmConstraints()),
 # then the algorithm is completely disabled and will not be negotiated.
 #
-# Note: This property is currently used by Oracle's JSSE implementation.
+# Note: This property is currently used by the JDK Reference implementation.
 # It is not guaranteed to be examined and used by other implementations.
 # There is no guarantee the property will continue to exist or be of the
 # same syntax in future releases.
@@ -789,7 +732,8 @@
         DHE_DSS_EXPORT, DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, \
         DH_RSA_EXPORT, RSA_EXPORT, \
         DH_anon, ECDH_anon, \
-        RC4_128, RC4_40, DES_CBC, DES40_CBC
+        RC4_128, RC4_40, DES_CBC, DES40_CBC, \
+        3DES_EDE_CBC
 
 # The pre-defined default finite field Diffie-Hellman ephemeral (DHE)
 # parameters for Transport Layer Security (SSL/TLS/DTLS) processing.
@@ -912,7 +856,7 @@
 #       Constraint {"," Constraint }
 #   Constraint:
 #       AlgConstraint | MaxTransformsConstraint | MaxReferencesConstraint |
-#       ReferenceUriSchemeConstraint | OtherConstraint
+#       ReferenceUriSchemeConstraint | KeySizeConstraint | OtherConstraint
 #   AlgConstraint
 #       "disallowAlg" Uri
 #   MaxTransformsConstraint:
@@ -921,12 +865,16 @@
 #       "maxReferences" Integer
 #   ReferenceUriSchemeConstraint:
 #       "disallowReferenceUriSchemes" String { String }
+#   KeySizeConstraint:
+#       "minKeySize" KeyAlg Integer
 #   OtherConstraint:
 #       "noDuplicateIds" | "noRetrievalMethodLoops"
 #
 # For AlgConstraint, Uri is the algorithm URI String that is not allowed.
 # See the XML Signature Recommendation for more information on algorithm
-# URI Identifiers. If the MaxTransformsConstraint or MaxReferencesConstraint is
+# URI Identifiers. For KeySizeConstraint, KeyAlg is the standard algorithm
+# name of the key type (ex: "RSA"). If the MaxTransformsConstraint,
+# MaxReferencesConstraint or KeySizeConstraint (for the same key type) is
 # specified more than once, only the last entry is enforced.
 #
 # Note: This property is currently used by the JDK Reference implementation. It
@@ -940,6 +888,8 @@
     maxTransforms 5,\
     maxReferences 30,\
     disallowReferenceUriSchemes file http https,\
+    minKeySize RSA 1024,\
+    minKeySize DSA 1024,\
     noDuplicateIds,\
     noRetrievalMethodLoops
 
--- a/jdk/src/java.base/share/lib/security/default.policy	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/lib/security/default.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -81,6 +81,8 @@
 };
 
 grant codeBase "jrt:/java.xml.crypto" {
+    permission java.lang.RuntimePermission
+                   "accessClassInPackage.sun.security.util";
     permission java.util.PropertyPermission "*", "read";
     permission java.security.SecurityPermission "putProviderProperty.XMLDSig";
     permission java.security.SecurityPermission
@@ -91,10 +93,20 @@
                    "com.sun.org.apache.xml.internal.security.register";
     permission java.security.SecurityPermission
                    "getProperty.jdk.xml.dsig.secureValidationPolicy";
+    permission java.lang.RuntimePermission
+                   "accessClassInPackage.com.sun.org.apache.xml.internal.*";
+    permission java.lang.RuntimePermission
+                   "accessClassInPackage.com.sun.org.apache.xpath.internal";
+    permission java.lang.RuntimePermission
+                   "accessClassInPackage.com.sun.org.apache.xpath.internal.*";
 };
 
 grant codeBase "jrt:/java.xml.ws" {
     permission java.lang.RuntimePermission
+                   "accessClassInPackage.com.sun.org.apache.xml.internal.resolver";
+    permission java.lang.RuntimePermission
+                   "accessClassInPackage.com.sun.org.apache.xml.internal.resolver.tools";
+    permission java.lang.RuntimePermission
                    "accessClassInPackage.com.sun.xml.internal.*";
     permission java.lang.RuntimePermission
                    "accessClassInPackage.com.sun.istack.internal";
@@ -186,3 +198,18 @@
     permission java.util.PropertyPermission "os.name", "read";
 };
 
+grant codeBase "jrt:/jdk.accessibility" {
+    permission java.lang.RuntimePermission "accessClassInPackage.sun.awt";
+};
+
+grant codeBase "jrt:/jdk.desktop" {
+    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.awt";
+};
+
+// permissions needed by applications using java.desktop module
+grant {
+    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.beans";
+    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.beans.*";
+    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.java.swing.plaf.*";
+    permission java.lang.RuntimePermission "accessClassInPackage.com.apple.*";
+};
--- a/jdk/src/java.base/share/native/libnet/net_util.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/native/libnet/net_util.c	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,10 +64,10 @@
     preferIPv4Stack = (*env)->CallStaticBooleanMethod(env, iCls, mid, s);
 
     /*
-       Since we have initialized and loaded the Socket library we will
-       check now to whether we have IPv6 on this platform and if the
-       supporting socket APIs are available
-    */
+     * Since we have initialized and loaded the socket library we will
+     * check now whether we have IPv6 on this platform and if the
+     * supporting socket APIs are available
+     */
     IPv6_available = IPv6_supported() & (!preferIPv4Stack);
 
     /* check if SO_REUSEPORT is supported on this platform */
@@ -120,16 +120,16 @@
     return JNI_TRUE;
 }
 
-int getInet6Address_scopeid_set(JNIEnv *env, jobject iaObj) {
+jboolean getInet6Address_scopeid_set(JNIEnv *env, jobject iaObj) {
     jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
-    CHECK_NULL_RETURN(holder, -1);
+    CHECK_NULL_RETURN(holder, JNI_FALSE);
     return (*env)->GetBooleanField(env, holder, ia6_scopeidsetID);
 }
 
-int getInet6Address_scopeid(JNIEnv *env, jobject iaObj) {
+unsigned int getInet6Address_scopeid(JNIEnv *env, jobject iaObj) {
     jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
-    CHECK_NULL_RETURN(holder, -1);
-    return (*env)->GetIntField(env, holder, ia6_scopeidID);
+    CHECK_NULL_RETURN(holder, 0);
+    return (unsigned int)(*env)->GetIntField(env, holder, ia6_scopeidID);
 }
 
 jboolean setInet6Address_scopeid(JNIEnv *env, jobject iaObj, int scopeid) {
@@ -201,11 +201,10 @@
 }
 
 JNIEXPORT jobject JNICALL
-NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
+NET_SockaddrToInetAddress(JNIEnv *env, SOCKETADDRESS *sa, int *port) {
     jobject iaObj;
-    if (him->sa_family == AF_INET6) {
-        struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-        jbyte *caddr = (jbyte *)&(him6->sin6_addr);
+    if (sa->sa.sa_family == AF_INET6) {
+        jbyte *caddr = (jbyte *)&sa->sa6.sin6_addr;
         if (NET_IsIPv4Mapped(caddr)) {
             int address;
             iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
@@ -214,42 +213,35 @@
             setInetAddress_addr(env, iaObj, address);
             setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
         } else {
-            jint scope;
             jboolean ret;
             iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
             CHECK_NULL_RETURN(iaObj, NULL);
-            ret = setInet6Address_ipaddress(env, iaObj, (char *)&(him6->sin6_addr));
+            ret = setInet6Address_ipaddress(env, iaObj, (char *)&sa->sa6.sin6_addr);
             if (ret == JNI_FALSE)
                 return NULL;
             setInetAddress_family(env, iaObj, java_net_InetAddress_IPv6);
-            scope = getScopeID(him);
-            setInet6Address_scopeid(env, iaObj, scope);
+            setInet6Address_scopeid(env, iaObj, sa->sa6.sin6_scope_id);
         }
-        *port = ntohs(him6->sin6_port);
+        *port = ntohs(sa->sa6.sin6_port);
     } else {
-        struct sockaddr_in *him4 = (struct sockaddr_in *)him;
         iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
         CHECK_NULL_RETURN(iaObj, NULL);
         setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
-        setInetAddress_addr(env, iaObj, ntohl(him4->sin_addr.s_addr));
-        *port = ntohs(him4->sin_port);
+        setInetAddress_addr(env, iaObj, ntohl(sa->sa4.sin_addr.s_addr));
+        *port = ntohs(sa->sa4.sin_port);
     }
     return iaObj;
 }
 
-JNIEXPORT jint JNICALL
-NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj)
+JNIEXPORT jboolean JNICALL
+NET_SockaddrEqualsInetAddress(JNIEnv *env, SOCKETADDRESS *sa, jobject iaObj)
 {
-    jint family = AF_INET;
-
-    family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
-        AF_INET : AF_INET6;
-    if (him->sa_family == AF_INET6) {
-        struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-        jbyte *caddrNew = (jbyte *)&(him6->sin6_addr);
+    jint family = getInetAddress_family(env, iaObj) ==
+        java_net_InetAddress_IPv4 ? AF_INET : AF_INET6;
+    if (sa->sa.sa_family == AF_INET6) {
+        jbyte *caddrNew = (jbyte *)&sa->sa6.sin6_addr;
         if (NET_IsIPv4Mapped(caddrNew)) {
-            int addrNew;
-            int addrCur;
+            int addrNew, addrCur;
             if (family == AF_INET6) {
                 return JNI_FALSE;
             }
@@ -262,26 +254,24 @@
             }
         } else {
             jbyte caddrCur[16];
-            int scope;
-
             if (family == AF_INET) {
                 return JNI_FALSE;
             }
-            scope = getInet6Address_scopeid(env, iaObj);
             getInet6Address_ipaddress(env, iaObj, (char *)caddrCur);
-            if (NET_IsEqual(caddrNew, caddrCur) && cmpScopeID(scope, him)) {
+            if (NET_IsEqual(caddrNew, caddrCur) &&
+                sa->sa6.sin6_scope_id == getInet6Address_scopeid(env, iaObj))
+            {
                 return JNI_TRUE;
             } else {
                 return JNI_FALSE;
             }
         }
     } else {
-        struct sockaddr_in *him4 = (struct sockaddr_in *)him;
         int addrNew, addrCur;
         if (family != AF_INET) {
             return JNI_FALSE;
         }
-        addrNew = ntohl(him4->sin_addr.s_addr);
+        addrNew = ntohl(sa->sa4.sin_addr.s_addr);
         addrCur = getInetAddress_addr(env, iaObj);
         if (addrNew == addrCur) {
             return JNI_TRUE;
@@ -291,6 +281,15 @@
     }
 }
 
+JNIEXPORT jint JNICALL
+NET_GetPortFromSockaddr(SOCKETADDRESS *sa) {
+    if (sa->sa.sa_family == AF_INET6) {
+        return ntohs(sa->sa6.sin6_port);
+    } else {
+        return ntohs(sa->sa4.sin_port);
+    }
+}
+
 unsigned short
 in_cksum(unsigned short *addr, int len) {
     int nleft = len;
--- a/jdk/src/java.base/share/native/libnet/net_util.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/share/native/libnet/net_util.h	Tue Jan 24 00:30:25 2017 +0100
@@ -63,8 +63,8 @@
  */
 extern jobject getInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj);
 extern jboolean setInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj, jobject scopeifname);
-extern int getInet6Address_scopeid_set(JNIEnv *env, jobject ia6Obj);
-extern int getInet6Address_scopeid(JNIEnv *env, jobject ia6Obj);
+extern jboolean getInet6Address_scopeid_set(JNIEnv *env, jobject ia6Obj);
+extern unsigned int getInet6Address_scopeid(JNIEnv *env, jobject ia6Obj);
 extern jboolean setInet6Address_scopeid(JNIEnv *env, jobject ia6Obj, int scopeid);
 extern jboolean getInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *dest);
 extern jboolean setInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *address);
@@ -132,24 +132,41 @@
 
 JNIEXPORT jint JNICALL reuseport_available();
 
+/**
+ * This function will fill a SOCKETADDRESS structure from an InetAddress
+ * object.
+ *
+ * The parameter 'sa' must point to valid storage of size
+ * 'sizeof(SOCKETADDRESS)'.
+ *
+ * The parameter 'len' is a pointer to an int and is used for returning
+ * the actual sockaddr length, e.g. 'sizeof(struct sockaddr_in)' or
+ * 'sizeof(struct sockaddr_in6)'.
+ *
+ * If the type of the InetAddress object is IPv6, the function will fill a
+ * sockaddr_in6 structure. IPv6 must be available in that case, otherwise an
+ * exception is thrown.
+ * In the case of an IPv4 InetAddress, when IPv6 is available and
+ * v4MappedAddress is TRUE, this method will fill a sockaddr_in6 structure
+ * containing an IPv4 mapped IPv6 address. Otherwise a sockaddr_in
+ * structure will be filled.
+ */
 JNIEXPORT int JNICALL
 NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
-                          struct sockaddr *him, int *len,
+                          SOCKETADDRESS *sa, int *len,
                           jboolean v4MappedAddress);
 
 JNIEXPORT jobject JNICALL
-NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port);
+NET_SockaddrToInetAddress(JNIEnv *env, SOCKETADDRESS *sa, int *port);
 
 void platformInit();
 
 void parseExclusiveBindProperty(JNIEnv *env);
 
-void NET_SetTrafficClass(struct sockaddr *him, int trafficClass);
+JNIEXPORT jint JNICALL NET_GetPortFromSockaddr(SOCKETADDRESS *sa);
 
-JNIEXPORT jint JNICALL NET_GetPortFromSockaddr(struct sockaddr *him);
-
-JNIEXPORT jint JNICALL
-NET_SockaddrEqualsInetAddress(JNIEnv *env,struct sockaddr *him, jobject iaObj);
+JNIEXPORT jboolean JNICALL
+NET_SockaddrEqualsInetAddress(JNIEnv *env, SOCKETADDRESS *sa, jobject iaObj);
 
 int NET_IsIPv4Mapped(jbyte* caddr);
 
@@ -172,7 +189,7 @@
 NET_SetSockOpt(int fd, int level, int opt, const void *arg, int len);
 
 JNIEXPORT int JNICALL
-NET_Bind(int fd, struct sockaddr *him, int len);
+NET_Bind(int fd, SOCKETADDRESS *sa, int len);
 
 JNIEXPORT int JNICALL
 NET_MapSocketOption(jint cmd, int *level, int *optname);
@@ -183,10 +200,6 @@
 JNIEXPORT jint JNICALL
 NET_EnableFastTcpLoopback(int fd);
 
-int getScopeID(struct sockaddr *);
-
-int cmpScopeID(unsigned int, struct sockaddr *);
-
 unsigned short in_cksum(unsigned short *addr, int len);
 
 jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
--- a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -211,7 +211,8 @@
         {
             int port;
             int index = (family == AF_INET) ? i++ : j++;
-            jobject o = NET_SockaddrToInetAddress(env, iter->ifa_addr, &port);
+            jobject o = NET_SockaddrToInetAddress(env,
+                            (SOCKETADDRESS *)iter->ifa_addr, &port);
             if (!o) {
                 freeifaddrs(ifa);
                 if (!(*env)->ExceptionCheck(env))
--- a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -791,7 +791,7 @@
     int sock;
 
     sock = openSocket(env, AF_INET);
-    if (sock < 0 && (*env)->ExceptionOccurred(env)) {
+    if (sock < 0) {
         return NULL;
     }
 
@@ -809,7 +809,7 @@
     // so we have to call ipv6_available()
     if (ipv6_available()) {
         sock = openSocket(env, AF_INET6);
-        if (sock < 0 && (*env)->ExceptionOccurred(env)) {
+        if (sock < 0) {
             freeif(ifs);
             return NULL;
         }
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -99,7 +99,7 @@
         CHECK_NULL_RETURN(i_class, NULL);
     }
 
-    return ( (*env)->NewObject(env, i_class, i_ctrID, i) );
+    return (*env)->NewObject(env, i_class, i_ctrID, i);
 }
 
 /*
@@ -118,10 +118,9 @@
         CHECK_NULL_RETURN(b_class, NULL);
     }
 
-    return( (*env)->NewObject(env, b_class, b_ctrID, (jboolean)(b!=0)) );
+    return (*env)->NewObject(env, b_class, b_ctrID, (jboolean)(b != 0));
 }
 
-
 /*
  * Returns the fd for a PlainDatagramSocketImpl or -1
  * if closed.
@@ -134,7 +133,6 @@
     return (*env)->GetIntField(env, fdObj, IO_fd_fdID);
 }
 
-
 /*
  * Class:     java_net_PlainDatagramSocketImpl
  * Method:    init
@@ -166,7 +164,6 @@
     initInetAddressIDs(env);
     JNU_CHECK_EXCEPTION(env);
     Java_java_net_NetworkInterface_init(env, 0);
-
 }
 
 /*
@@ -176,13 +173,13 @@
  */
 JNIEXPORT void JNICALL
 Java_java_net_PlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
-                                           jint localport, jobject iaObj) {
+                                            jint localport, jobject iaObj) {
     /* fdObj is the FileDescriptor field on this */
     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
     /* fd is an int field on fdObj */
     int fd;
     int len = 0;
-    SOCKETADDRESS him;
+    SOCKETADDRESS sa;
     socklen_t slen = sizeof(SOCKETADDRESS);
 
     if (IS_NULL(fdObj)) {
@@ -199,12 +196,13 @@
     }
 
     /* bind */
-    if (NET_InetAddressToSockaddr(env, iaObj, localport, &him.sa, &len, JNI_TRUE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, localport, &sa, &len,
+                                  JNI_TRUE) != 0) {
       return;
     }
-    setDefaultScopeID(env, &him.sa);
+    setDefaultScopeID(env, &sa.sa);
 
-    if (NET_Bind(fd, &him.sa, len) < 0)  {
+    if (NET_Bind(fd, &sa, len) < 0)  {
         if (errno == EADDRINUSE || errno == EADDRNOTAVAIL ||
             errno == EPERM || errno == EACCES) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
@@ -221,13 +219,13 @@
         /* Now that we're a connected socket, let's extract the port number
          * that the system chose for us and store it in the Socket object.
          */
-        if (getsockname(fd, &him.sa, &slen) == -1) {
+        if (getsockname(fd, &sa.sa, &slen) == -1) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return;
         }
 
-        localport = NET_GetPortFromSockaddr(&him.sa);
+        localport = NET_GetPortFromSockaddr(&sa);
 
         (*env)->SetIntField(env, this, pdsi_localPortID, localport);
     } else {
@@ -263,7 +261,8 @@
         return;
     }
 
-    if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr.sa, &len, JNI_TRUE) != 0) {
+    if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr, &len,
+                                  JNI_TRUE) != 0) {
       return;
     }
 
@@ -290,6 +289,9 @@
 #if defined(__linux__) || defined(_ALLBSD_SOURCE)
     SOCKETADDRESS addr;
     socklen_t len;
+#if defined(__linux__)
+    int localPort = 0;
+#endif
 #endif
 
     if (IS_NULL(fdObj)) {
@@ -298,32 +300,31 @@
     fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
 
 #if defined(__linux__) || defined(_ALLBSD_SOURCE)
-        memset(&addr, 0, sizeof(addr));
-        if (ipv6_available()) {
-            addr.sa6.sin6_family = AF_UNSPEC;
-            len = sizeof(struct sockaddr_in6);
-        } else {
-            addr.sa4.sin_family = AF_UNSPEC;
-            len = sizeof(struct sockaddr_in);
-        }
-        NET_Connect(fd, &addr.sa, len);
+    memset(&addr, 0, sizeof(addr));
+    if (ipv6_available()) {
+        addr.sa6.sin6_family = AF_UNSPEC;
+        len = sizeof(struct sockaddr_in6);
+    } else {
+        addr.sa4.sin_family = AF_UNSPEC;
+        len = sizeof(struct sockaddr_in);
+    }
+    NET_Connect(fd, &addr.sa, len);
 
-#ifdef __linux__
-        int localPort = 0;
-        if (getsockname(fd, &addr.sa, &len) == -1)
-            return;
+#if defined(__linux__)
+    if (getsockname(fd, &addr.sa, &len) == -1)
+        return;
 
-        localPort = NET_GetPortFromSockaddr(&addr.sa);
-        if (localPort == 0) {
-            localPort = (*env)->GetIntField(env, this, pdsi_localPortID);
-            if (addr.sa.sa_family == AF_INET6) {
-                addr.sa6.sin6_port = htons(localPort);
-            } else {
-                addr.sa4.sin_port = htons(localPort);
-            }
+    localPort = NET_GetPortFromSockaddr(&addr);
+    if (localPort == 0) {
+        localPort = (*env)->GetIntField(env, this, pdsi_localPortID);
+        if (addr.sa.sa_family == AF_INET6) {
+            addr.sa6.sin6_port = htons(localPort);
+        } else {
+            addr.sa4.sin_port = htons(localPort);
+        }
 
-            NET_Bind(fd, &addr.sa, len);
-        }
+        NET_Bind(fd, &addr, len);
+    }
 
 #endif
 #else
@@ -355,8 +356,9 @@
     /* The fdObj'fd */
     jint fd;
 
-    SOCKETADDRESS rmtaddr, *rmtaddrP = &rmtaddr;
-    int len;
+    SOCKETADDRESS rmtaddr;
+    struct sockaddr *rmtaddrP = 0;
+    int len = 0;
 
     if (IS_NULL(fdObj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -382,15 +384,14 @@
     packetBufferOffset = (*env)->GetIntField(env, packet, dp_offsetID);
     packetBufferLen = (*env)->GetIntField(env, packet, dp_lengthID);
 
-    if (connected) {
-        /* arg to NET_Sendto () null in this case */
-        len = 0;
-        rmtaddrP = 0;
-    } else {
+    // arg to NET_Sendto() null, if connected
+    if (!connected) {
         packetPort = (*env)->GetIntField(env, packet, dp_portID);
-        if (NET_InetAddressToSockaddr(env, packetAddress, packetPort, &rmtaddr.sa, &len, JNI_TRUE) != 0) {
+        if (NET_InetAddressToSockaddr(env, packetAddress, packetPort, &rmtaddr,
+                                      &len, JNI_TRUE) != 0) {
             return;
         }
+        rmtaddrP = &rmtaddr.sa;
     }
     setDefaultScopeID(env, &rmtaddr.sa);
 
@@ -427,7 +428,7 @@
     (*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset, packetBufferLen,
                                (jbyte *)fullPacket);
     if (trafficClass != 0 && ipv6_available()) {
-        NET_SetTrafficClass(&rmtaddr.sa, trafficClass);
+        NET_SetTrafficClass(&rmtaddr, trafficClass);
     }
 
     /*
@@ -437,8 +438,7 @@
      * ECONNREFUSED indicating that an ICMP port unreachable has
      * received.
      */
-    ret = NET_SendTo(fd, fullPacket, packetBufferLen, 0,
-                     (struct sockaddr *)rmtaddrP, len);
+    ret = NET_SendTo(fd, fullPacket, packetBufferLen, 0, rmtaddrP, len);
 
     if (ret < 0) {
         if (errno == ECONNREFUSED) {
@@ -510,7 +510,7 @@
 #ifdef __solaris__
         if (errno == ECONNREFUSED) {
             int orig_errno = errno;
-            (void) recv(fd, buf, 1, 0);
+            recv(fd, buf, 1, 0);
             errno = orig_errno;
         }
 #endif
@@ -528,7 +528,7 @@
         return 0;
     }
 
-    iaObj = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port);
+    iaObj = NET_SockaddrToInetAddress(env, &rmtaddr, &port);
     family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
         AF_INET : AF_INET6;
     if (family == AF_INET) { /* this API can't handle IPV6 addresses */
@@ -676,18 +676,18 @@
          */
         packetAddress = (*env)->GetObjectField(env, packet, dp_addressID);
         if (packetAddress != NULL) {
-            if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr.sa, packetAddress)) {
+            if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr, packetAddress)) {
                 /* force a new InetAddress to be created */
                 packetAddress = NULL;
             }
         }
         if (packetAddress == NULL) {
-            packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port);
+            packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port);
             /* stuff the new Inetaddress in the packet */
             (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
         } else {
             /* only get the new port number */
-            port = NET_GetPortFromSockaddr(&rmtaddr.sa);
+            port = NET_GetPortFromSockaddr(&rmtaddr);
         }
         /* and fill in the data, remote address/port and such */
         (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
@@ -857,18 +857,19 @@
              */
             packetAddress = (*env)->GetObjectField(env, packet, dp_addressID);
             if (packetAddress != NULL) {
-                if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr.sa, packetAddress)) {
+                if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr,
+                                                   packetAddress)) {
                     /* force a new InetAddress to be created */
                     packetAddress = NULL;
                 }
             }
             if (packetAddress == NULL) {
-                packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port);
+                packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port);
                 /* stuff the new Inetaddress in the packet */
                 (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
             } else {
                 /* only get the new port number */
-                port = NET_GetPortFromSockaddr(&rmtaddr.sa);
+                port = NET_GetPortFromSockaddr(&rmtaddr);
             }
             /* and fill in the data, remote address/port and such */
             (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
@@ -1040,6 +1041,7 @@
     /*
      * We need an ipv4 address here
      */
+    in.s_addr = 0;
     for (i = 0; i < len; i++) {
         addr = (*env)->GetObjectArrayElement(env, addrArray, i);
         if (getInetAddress_family(env, addr) == java_net_InetAddress_IPv4) {
@@ -1049,7 +1051,7 @@
     }
 
     if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
-                   (const char*)&in, sizeof(in)) < 0) {
+                   (const char *)&in, sizeof(in)) < 0) {
         JNU_ThrowByNameWithMessageAndLastError
             (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
     }
@@ -1670,17 +1672,17 @@
      */
     if (opt == java_net_SocketOptions_SO_BINDADDR) {
         /* find out local IP address */
-        SOCKETADDRESS him;
+        SOCKETADDRESS sa;
         socklen_t len = sizeof(SOCKETADDRESS);
         int port;
         jobject iaObj;
 
-        if (getsockname(fd, &him.sa, &len) == -1) {
+        if (getsockname(fd, &sa.sa, &len) == -1) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return NULL;
         }
-        iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
+        iaObj = NET_SockaddrToInetAddress(env, &sa, &port);
 
         return iaObj;
     }
@@ -1969,6 +1971,7 @@
                 mname.imr_multiaddr.s_addr = htonl(getInetAddress_addr(env, iaObj));
 #ifdef __linux__
                 mname.imr_address.s_addr = htonl(getInetAddress_addr(env, addr));
+                mname.imr_ifindex = 0;
 #else
                 mname.imr_interface.s_addr = htonl(getInetAddress_addr(env, addr));
 #endif
@@ -2023,7 +2026,7 @@
 
 #ifdef __linux__
                 mname.imr_address.s_addr = in.s_addr;
-
+                mname.imr_ifindex = 0;
 #else
                 mname.imr_interface.s_addr = in.s_addr;
 #endif
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -244,7 +244,7 @@
     /* fd is an int field on iaObj */
     jint fd;
 
-    SOCKETADDRESS him;
+    SOCKETADDRESS sa;
     /* The result of the connection */
     int connect_rv = -1;
 
@@ -260,17 +260,18 @@
     }
 
     /* connect */
-    if (NET_InetAddressToSockaddr(env, iaObj, port, &him.sa, &len, JNI_TRUE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, &len,
+                                  JNI_TRUE) != 0) {
         return;
     }
-    setDefaultScopeID(env, &him.sa);
+    setDefaultScopeID(env, &sa.sa);
 
     if (trafficClass != 0 && ipv6_available()) {
-        NET_SetTrafficClass(&him.sa, trafficClass);
+        NET_SetTrafficClass(&sa, trafficClass);
     }
 
     if (timeout <= 0) {
-        connect_rv = NET_Connect(fd, &him.sa, len);
+        connect_rv = NET_Connect(fd, &sa.sa, len);
 #ifdef __solaris__
         if (connect_rv == -1 && errno == EINPROGRESS ) {
 
@@ -319,7 +320,7 @@
         SET_NONBLOCKING(fd);
 
         /* no need to use NET_Connect as non-blocking */
-        connect_rv = connect(fd, &him.sa, len);
+        connect_rv = connect(fd, &sa.sa, len);
 
         /* connection not established immediately */
         if (connect_rv != 0) {
@@ -467,11 +468,11 @@
          * that the system chose for us and store it in the Socket object.
          */
         socklen_t slen = sizeof(SOCKETADDRESS);
-        if (getsockname(fd, &him.sa, &slen) == -1) {
+        if (getsockname(fd, &sa.sa, &slen) == -1) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
         } else {
-            localport = NET_GetPortFromSockaddr(&him.sa);
+            localport = NET_GetPortFromSockaddr(&sa);
             (*env)->SetIntField(env, this, psi_localportID, localport);
         }
     }
@@ -490,8 +491,8 @@
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
     /* fd is an int field on fdObj */
     int fd;
-    int len;
-    SOCKETADDRESS him;
+    int len = 0;
+    SOCKETADDRESS sa;
 
     if (IS_NULL(fdObj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -506,13 +507,13 @@
     }
 
     /* bind */
-    if (NET_InetAddressToSockaddr(env, iaObj, localport, &him.sa,
+    if (NET_InetAddressToSockaddr(env, iaObj, localport, &sa,
                                   &len, JNI_TRUE) != 0) {
         return;
     }
-    setDefaultScopeID(env, &him.sa);
+    setDefaultScopeID(env, &sa.sa);
 
-    if (NET_Bind(fd, &him.sa, len) < 0) {
+    if (NET_Bind(fd, &sa, len) < 0) {
         if (errno == EADDRINUSE || errno == EADDRNOTAVAIL ||
             errno == EPERM || errno == EACCES) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
@@ -533,12 +534,12 @@
         /* Now that we're a connected socket, let's extract the port number
          * that the system chose for us and store it in the Socket object.
          */
-        if (getsockname(fd, &him.sa, &slen) == -1) {
+        if (getsockname(fd, &sa.sa, &slen) == -1) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return;
         }
-        localport = NET_GetPortFromSockaddr(&him.sa);
+        localport = NET_GetPortFromSockaddr(&sa);
         (*env)->SetIntField(env, this, psi_localportID, localport);
     } else {
         (*env)->SetIntField(env, this, psi_localportID, localport);
@@ -606,7 +607,7 @@
     /* accepted fd */
     jint newfd;
 
-    SOCKETADDRESS him;
+    SOCKETADDRESS sa;
     socklen_t slen = sizeof(SOCKETADDRESS);
 
     if (IS_NULL(fdObj)) {
@@ -661,7 +662,7 @@
             return;
         }
 
-        newfd = NET_Accept(fd, &him.sa, &slen);
+        newfd = NET_Accept(fd, &sa.sa, &slen);
 
         /* connection accepted */
         if (newfd >= 0) {
@@ -709,7 +710,7 @@
     /*
      * fill up the remote peer port and address in the new socket structure.
      */
-    socketAddressObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
+    socketAddressObj = NET_SockaddrToInetAddress(env, &sa, &port);
     if (socketAddressObj == NULL) {
         /* should be pending exception */
         close(newfd);
@@ -944,19 +945,19 @@
      * SO_BINDADDR isn't a socket option
      */
     if (cmd == java_net_SocketOptions_SO_BINDADDR) {
-        SOCKETADDRESS him;
+        SOCKETADDRESS sa;
         socklen_t len = sizeof(SOCKETADDRESS);
         int port;
         jobject iaObj;
         jclass iaCntrClass;
         jfieldID iaFieldID;
 
-        if (getsockname(fd, &him.sa, &len) < 0) {
+        if (getsockname(fd, &sa.sa, &len) < 0) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return -1;
         }
-        iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
+        iaObj = NET_SockaddrToInetAddress(env, &sa, &port);
         CHECK_NULL_RETURN(iaObj, -1);
 
         iaCntrClass = (*env)->GetObjectClass(env, iaContainerObj);
--- a/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c	Tue Jan 24 00:30:25 2017 +0100
@@ -98,27 +98,31 @@
         int llen = chunkLen;
         (*env)->GetByteArrayRegion(env, data, off, chunkLen, (jbyte *)bufP);
 
-        while(llen > 0) {
-            int n = NET_Send(fd, bufP + loff, llen, 0);
-            if (n > 0) {
-                llen -= n;
-                loff += n;
-                continue;
+        if ((*env)->ExceptionCheck(env)) {
+            break;
+        } else {
+            while(llen > 0) {
+                int n = NET_Send(fd, bufP + loff, llen, 0);
+                if (n > 0) {
+                    llen -= n;
+                    loff += n;
+                    continue;
+                }
+                if (errno == ECONNRESET) {
+                    JNU_ThrowByName(env, "sun/net/ConnectionResetException",
+                        "Connection reset");
+                } else {
+                    JNU_ThrowByNameWithMessageAndLastError
+                        (env, "java/net/SocketException", "Write failed");
+                }
+                if (bufP != BUF) {
+                    free(bufP);
+                }
+                return;
             }
-            if (errno == ECONNRESET) {
-                JNU_ThrowByName(env, "sun/net/ConnectionResetException",
-                    "Connection reset");
-            } else {
-                JNU_ThrowByNameWithMessageAndLastError
-                    (env, "java/net/SocketException", "Write failed");
-            }
-            if (bufP != BUF) {
-                free(bufP);
-            }
-            return;
+            len -= chunkLen;
+            off += chunkLen;
         }
-        len -= chunkLen;
-        off += chunkLen;
     }
 
     if (bufP != BUF) {
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c	Tue Jan 24 00:30:25 2017 +0100
@@ -234,29 +234,6 @@
     }
     return kernelV24;
 }
-
-int getScopeID (struct sockaddr *him) {
-    struct sockaddr_in6 *hext = (struct sockaddr_in6 *)him;
-    return hext->sin6_scope_id;
-}
-
-int cmpScopeID (unsigned int scope, struct sockaddr *him) {
-    struct sockaddr_in6 *hext = (struct sockaddr_in6 *)him;
-    return hext->sin6_scope_id == scope;
-}
-
-#else
-
-int getScopeID (struct sockaddr *him) {
-    struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-    return him6->sin6_scope_id;
-}
-
-int cmpScopeID (unsigned int scope, struct sockaddr *him) {
-    struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-    return him6->sin6_scope_id == scope;
-}
-
 #endif
 
 void
@@ -775,30 +752,32 @@
     return 0;
 }
 
-/* In the case of an IPv4 Inetaddress this method will return an
- * IPv4 mapped address where IPv6 is available and v4MappedAddress is TRUE.
- * Otherwise it will return a sockaddr_in structure for an IPv4 InetAddress.
-*/
+/**
+ * See net_util.h for documentation
+ */
 JNIEXPORT int JNICALL
-NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him,
-                          int *len, jboolean v4MappedAddress) {
-    jint family;
-    family = getInetAddress_family(env, iaObj);
-    /* needs work. 1. family 2. clean up him6 etc deallocate memory */
-    if (ipv6_available() && !(family == java_net_InetAddress_IPv4 &&
-                              v4MappedAddress == JNI_FALSE)) {
-        struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
+NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
+                          SOCKETADDRESS *sa, int *len,
+                          jboolean v4MappedAddress)
+{
+    jint family = getInetAddress_family(env, iaObj);
+    memset((char *)sa, 0, sizeof(SOCKETADDRESS));
+
+    if (ipv6_available() &&
+        !(family == java_net_InetAddress_IPv4 &&
+          v4MappedAddress == JNI_FALSE))
+    {
         jbyte caddr[16];
         jint address;
 
         if (family == java_net_InetAddress_IPv4) {
             // convert to IPv4-mapped address
-            memset((char *) caddr, 0, 16);
+            memset((char *)caddr, 0, 16);
             address = getInetAddress_addr(env, iaObj);
             if (address == INADDR_ANY) {
                 /* we would always prefer IPv6 wildcard address
-                   caddr[10] = 0xff;
-                   caddr[11] = 0xff; */
+                 * caddr[10] = 0xff;
+                 * caddr[11] = 0xff; */
             } else {
                 caddr[10] = 0xff;
                 caddr[11] = 0xff;
@@ -810,22 +789,19 @@
         } else {
             getInet6Address_ipaddress(env, iaObj, (char *)caddr);
         }
-        memset((char *)him6, 0, sizeof(struct sockaddr_in6));
-        him6->sin6_port = htons(port);
-        memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) );
-        him6->sin6_family = AF_INET6;
-        *len = sizeof(struct sockaddr_in6);
+        sa->sa6.sin6_port = htons(port);
+        memcpy((void *)&sa->sa6.sin6_addr, caddr, sizeof(struct in6_addr));
+        sa->sa6.sin6_family = AF_INET6;
+        if (len != NULL) {
+            *len = sizeof(struct sockaddr_in6);
+        }
 
-#if defined(_ALLBSD_SOURCE)
-// XXXBSD: should we do something with scope id here ? see below linux comment
-/* MMM: Come back to this! */
-#endif
-
+#ifdef __linux__
         /*
          * On Linux if we are connecting to a link-local address
          * we need to specify the interface in the scope_id (2.4 kernel only)
          *
-         * If the scope was cached the we use the cached value. If not cached but
+         * If the scope was cached then we use the cached value. If not cached but
          * specified in the Inet6Address we use that, but we first check if the
          * address needs to be routed via the loopback interface. In this case,
          * we override the specified value with that of the loopback interface.
@@ -833,9 +809,8 @@
          * we try to determine a value from the routing table. In all these
          * cases the used value is cached for further use.
          */
-#ifdef __linux__
-        if (IN6_IS_ADDR_LINKLOCAL(&(him6->sin6_addr))) {
-            int cached_scope_id = 0, scope_id = 0;
+        if (IN6_IS_ADDR_LINKLOCAL(&sa->sa6.sin6_addr)) {
+            unsigned int cached_scope_id = 0, scope_id = 0;
 
             if (ia6_cachedscopeidID) {
                 cached_scope_id = (int)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID);
@@ -850,7 +825,7 @@
                         /* check user-specified value for loopback case
                          * that needs to be overridden
                          */
-                        if (kernelIsV24() && needsLoopbackRoute (&him6->sin6_addr)) {
+                        if (kernelIsV24() && needsLoopbackRoute(&sa->sa6.sin6_addr)) {
                             cached_scope_id = lo_scope_id;
                             (*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id);
                         }
@@ -860,11 +835,11 @@
                          * try determine the appropriate interface.
                          */
                         if (kernelIsV24()) {
-                            cached_scope_id = getDefaultIPv6Interface(&(him6->sin6_addr));
+                            cached_scope_id = getDefaultIPv6Interface(&sa->sa6.sin6_addr);
                         } else {
-                            cached_scope_id = getLocalScopeID((char *)&(him6->sin6_addr));
+                            cached_scope_id = getLocalScopeID((char *)&(sa->sa6.sin6_addr));
                             if (cached_scope_id == 0) {
-                                cached_scope_id = getDefaultIPv6Interface(&(him6->sin6_addr));
+                                cached_scope_id = getDefaultIPv6Interface(&sa->sa6.sin6_addr);
                             }
                         }
                         (*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id);
@@ -876,53 +851,37 @@
              * If we have a scope_id use the extended form
              * of sockaddr_in6.
              */
-
-            struct sockaddr_in6 *him6 =
-                    (struct sockaddr_in6 *)him;
-            him6->sin6_scope_id = cached_scope_id != 0 ?
-                                        cached_scope_id    : scope_id;
-            *len = sizeof(struct sockaddr_in6);
+            sa->sa6.sin6_scope_id = cached_scope_id == 0 ? scope_id : cached_scope_id;
         }
 #else
-        /* handle scope_id for solaris */
-
+        /* handle scope_id */
         if (family != java_net_InetAddress_IPv4) {
             if (ia6_scopeidID) {
-                him6->sin6_scope_id = getInet6Address_scopeid(env, iaObj);
+                sa->sa6.sin6_scope_id = getInet6Address_scopeid(env, iaObj);
             }
         }
 #endif
     } else {
-        struct sockaddr_in *him4 = (struct sockaddr_in *)him;
         jint address;
-        if (family == java_net_InetAddress_IPv6) {
+        if (family != java_net_InetAddress_IPv4) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable");
             return -1;
         }
-        memset((char *)him4, 0, sizeof(struct sockaddr_in));
         address = getInetAddress_addr(env, iaObj);
-        him4->sin_port = htons((short) port);
-        him4->sin_addr.s_addr = htonl(address);
-        him4->sin_family = AF_INET;
-        *len = sizeof(struct sockaddr_in);
+        sa->sa4.sin_port = htons(port);
+        sa->sa4.sin_addr.s_addr = htonl(address);
+        sa->sa4.sin_family = AF_INET;
+        if (len != NULL) {
+            *len = sizeof(struct sockaddr_in);
+        }
     }
     return 0;
 }
 
 void
-NET_SetTrafficClass(struct sockaddr *him, int trafficClass) {
-    if (him->sa_family == AF_INET6) {
-        struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-        him6->sin6_flowinfo = htonl((trafficClass & 0xff) << 20);
-    }
-}
-
-JNIEXPORT jint JNICALL
-NET_GetPortFromSockaddr(struct sockaddr *him) {
-    if (him->sa_family == AF_INET6) {
-        return ntohs(((struct sockaddr_in6*)him)->sin6_port);
-    } else {
-        return ntohs(((struct sockaddr_in*)him)->sin_port);
+NET_SetTrafficClass(SOCKETADDRESS *sa, int trafficClass) {
+    if (sa->sa.sa_family == AF_INET6) {
+        sa->sa6.sin6_flowinfo = htonl((trafficClass & 0xff) << 20);
     }
 }
 
@@ -1488,7 +1447,7 @@
  *
  */
 int
-NET_Bind(int fd, struct sockaddr *him, int len)
+NET_Bind(int fd, SOCKETADDRESS *sa, int len)
 {
 #if defined(__solaris__)
     int level = -1;
@@ -1503,9 +1462,8 @@
      * ## When IPv6 is enabled this will be an IPv4-mapped
      * ## with family set to AF_INET6
      */
-    if (him->sa_family == AF_INET) {
-        struct sockaddr_in *sa = (struct sockaddr_in *)him;
-        if ((ntohl(sa->sin_addr.s_addr) & 0x7f0000ff) == 0x7f0000ff) {
+    if (sa->sa.sa_family == AF_INET) {
+        if ((ntohl(sa->sa4.sin_addr.s_addr) & 0x7f0000ff) == 0x7f0000ff) {
             errno = EADDRNOTAVAIL;
             return -1;
         }
@@ -1524,8 +1482,9 @@
      */
     alen = sizeof(arg);
 
-    if (useExclBind || getsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
-                   (char *)&arg, &alen) == 0) {
+    if (useExclBind ||
+        getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&arg, &alen) == 0)
+    {
         if (useExclBind || arg == 0) {
             /*
              * SO_REUSEADDR is disabled or sun.net.useExclusiveBind
@@ -1533,8 +1492,8 @@
              * UDP_EXCLBIND
              */
             alen = sizeof(arg);
-            if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&arg,
-                           &alen) == 0) {
+            if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&arg, &alen) == 0)
+            {
                 if (arg == SOCK_STREAM) {
                     level = IPPROTO_TCP;
                     exclbind = TCP_EXCLBIND;
@@ -1545,14 +1504,13 @@
             }
 
             arg = 1;
-            setsockopt(fd, level, exclbind, (char *)&arg,
-                       sizeof(arg));
+            setsockopt(fd, level, exclbind, (char *)&arg, sizeof(arg));
         }
     }
 
 #endif
 
-    rv = bind(fd, him, len);
+    rv = bind(fd, &sa->sa, len);
 
 #if defined(__solaris__)
     if (rv < 0) {
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h	Tue Jan 24 00:30:25 2017 +0100
@@ -30,32 +30,6 @@
 #include <sys/poll.h>
 #include <sys/socket.h>
 
-int NET_Timeout(int s, long timeout);
-int NET_Timeout0(int s, long timeout, long currentTime);
-int NET_Read(int s, void* buf, size_t len);
-int NET_NonBlockingRead(int s, void* buf, size_t len);
-int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime);
-long NET_GetCurrentTime();
-int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
-                 struct sockaddr *from, socklen_t *fromlen);
-int NET_ReadV(int s, const struct iovec * vector, int count);
-int NET_Send(int s, void *msg, int len, unsigned int flags);
-int NET_SendTo(int s, const void *msg, int len,  unsigned  int
-               flags, const struct sockaddr *to, int tolen);
-int NET_Writev(int s, const struct iovec * vector, int count);
-int NET_Connect(int s, struct sockaddr *addr, int addrlen);
-int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen);
-int NET_SocketClose(int s);
-int NET_Dup2(int oldfd, int newfd);
-int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);
-int NET_SocketAvailable(int s, jint *pbytes);
-
-void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
-                                               const char* hostname,
-                                               int gai_error);
-void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
-                                  const char *defaultDetail);
-
 /************************************************************************
  * Macros and constants
  */
@@ -91,9 +65,36 @@
 } SOCKETADDRESS;
 
 /************************************************************************
- *  Utilities
+ * Functions
  */
 
+int NET_Timeout(int s, long timeout);
+int NET_Timeout0(int s, long timeout, long currentTime);
+int NET_Read(int s, void* buf, size_t len);
+int NET_NonBlockingRead(int s, void* buf, size_t len);
+int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime);
+long NET_GetCurrentTime();
+int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
+                 struct sockaddr *from, socklen_t *fromlen);
+int NET_ReadV(int s, const struct iovec * vector, int count);
+int NET_Send(int s, void *msg, int len, unsigned int flags);
+int NET_SendTo(int s, const void *msg, int len,  unsigned  int
+               flags, const struct sockaddr *to, int tolen);
+int NET_Writev(int s, const struct iovec * vector, int count);
+int NET_Connect(int s, struct sockaddr *addr, int addrlen);
+int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen);
+int NET_SocketClose(int s);
+int NET_Dup2(int oldfd, int newfd);
+int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);
+int NET_SocketAvailable(int s, jint *pbytes);
+
+void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
+                                               const char* hostname,
+                                               int gai_error);
+void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
+                                  const char *defaultDetail);
+void NET_SetTrafficClass(SOCKETADDRESS *sa, int trafficClass);
+
 #ifdef __linux__
 int kernelIsV24();
 int getDefaultIPv6Interface(struct in6_addr *target_addr);
--- a/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -181,11 +181,11 @@
      */
     senderAddr = (*env)->GetObjectField(env, this, dci_senderAddrID);
     if (senderAddr != NULL) {
-        if (!NET_SockaddrEqualsInetAddress(env, &sa.sa, senderAddr)) {
+        if (!NET_SockaddrEqualsInetAddress(env, &sa, senderAddr)) {
             senderAddr = NULL;
         } else {
             jint port = (*env)->GetIntField(env, this, dci_senderPortID);
-            if (port != NET_GetPortFromSockaddr(&sa.sa)) {
+            if (port != NET_GetPortFromSockaddr(&sa)) {
                 senderAddr = NULL;
             }
         }
@@ -193,7 +193,7 @@
     if (senderAddr == NULL) {
         jobject isa = NULL;
         int port = 0;
-        jobject ia = NET_SockaddrToInetAddress(env, &sa.sa, &port);
+        jobject ia = NET_SockaddrToInetAddress(env, &sa, &port);
         if (ia != NULL) {
             isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port);
         }
@@ -201,7 +201,7 @@
 
         (*env)->SetObjectField(env, this, dci_senderAddrID, ia);
         (*env)->SetIntField(env, this, dci_senderPortID,
-                            NET_GetPortFromSockaddr(&sa.sa));
+                            NET_GetPortFromSockaddr(&sa));
         (*env)->SetObjectField(env, this, dci_senderID, isa);
     }
     return n;
@@ -215,14 +215,14 @@
     jint fd = fdval(env, fdo);
     void *buf = (void *)jlong_to_ptr(address);
     SOCKETADDRESS sa;
-    int sa_len = sizeof(SOCKETADDRESS);
+    int sa_len = 0;
     jint n = 0;
 
     if (len > MAX_PACKET_LEN) {
         len = MAX_PACKET_LEN;
     }
 
-    if (NET_InetAddressToSockaddr(env, destAddress, destPort, &sa.sa,
+    if (NET_InetAddressToSockaddr(env, destAddress, destPort, &sa,
                                   &sa_len, preferIPv6) != 0) {
       return IOS_THROWN;
     }
--- a/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c	Tue Jan 24 00:30:25 2017 +0100
@@ -64,7 +64,7 @@
 
     if (getpeername(fd, &sa.sa, &len) == 0) {
         if (matchFamily(&sa.sa)) {
-            remote_ia = NET_SockaddrToInetAddress(env, &sa.sa, (int *)&remote_port);
+            remote_ia = NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port);
         }
     }
 
@@ -81,7 +81,7 @@
 
     if (getpeername(fd, &sa.sa, &len) == 0) {
         if (matchFamily(&sa.sa)) {
-            NET_SockaddrToInetAddress(env, &sa.sa, (int *)&remote_port);
+            NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port);
         }
     }
 
--- a/jdk/src/java.base/unix/native/libnio/ch/Net.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnio/ch/Net.c	Tue Jan 24 00:30:25 2017 +0100
@@ -274,15 +274,15 @@
                           jboolean useExclBind, jobject iao, int port)
 {
     SOCKETADDRESS sa;
-    int sa_len = sizeof(SOCKETADDRESS);
+    int sa_len = 0;
     int rv = 0;
 
-    if (NET_InetAddressToSockaddr(env, iao, port, &sa.sa, &sa_len,
+    if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len,
                                   preferIPv6) != 0) {
         return;
     }
 
-    rv = NET_Bind(fdval(env, fdo), &sa.sa, sa_len);
+    rv = NET_Bind(fdval(env, fdo), &sa, sa_len);
     if (rv != 0) {
         handleSocketError(env, errno);
     }
@@ -300,10 +300,10 @@
                              jobject fdo, jobject iao, jint port)
 {
     SOCKETADDRESS sa;
-    int sa_len = sizeof(SOCKETADDRESS);
+    int sa_len = 0;
     int rv;
 
-    if (NET_InetAddressToSockaddr(env, iao, port, &sa.sa, &sa_len,
+    if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len,
                                   preferIPv6) != 0) {
         return IOS_THROWN;
     }
@@ -349,7 +349,7 @@
         return -1;
 #endif /* _ALLBSD_SOURCE */
     }
-    return NET_GetPortFromSockaddr(&sa.sa);
+    return NET_GetPortFromSockaddr(&sa);
 }
 
 JNIEXPORT jobject JNICALL
@@ -382,7 +382,7 @@
         return NULL;
 #endif /* _ALLBSD_SOURCE */
     }
-    return NET_SockaddrToInetAddress(env, &sa.sa, &port);
+    return NET_SockaddrToInetAddress(env, &sa, &port);
 }
 
 JNIEXPORT jint JNICALL
--- a/jdk/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -112,7 +112,7 @@
     }
 
     (*env)->SetIntField(env, newfdo, fd_fdID, newfd);
-    remote_ia = NET_SockaddrToInetAddress(env, &sa.sa, (int *)&remote_port);
+    remote_ia = NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port);
     CHECK_NULL_RETURN(remote_ia, IOS_THROWN);
     isa = (*env)->NewObject(env, isa_class, isa_ctorID, remote_ia, remote_port);
     CHECK_NULL_RETURN(isa, IOS_THROWN);
--- a/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -233,11 +233,14 @@
         int childStart = 0;
         int parentEnd = pn;
 
+        boolean isDirectoryRelative =
+            pn == 2 && isLetter(parent.charAt(0)) && parent.charAt(1) == ':';
+
         if ((cn > 1) && (c.charAt(0) == slash)) {
             if (c.charAt(1) == slash) {
                 /* Drop prefix when child is a UNC pathname */
                 childStart = 2;
-            } else {
+            } else if (!isDirectoryRelative) {
                 /* Drop prefix when child is drive-relative */
                 childStart = 1;
 
@@ -254,7 +257,7 @@
 
         int strlen = parentEnd + cn - childStart;
         char[] theChars = null;
-        if (child.charAt(childStart) == slash) {
+        if (child.charAt(childStart) == slash || isDirectoryRelative) {
             theChars = new char[strlen];
             parent.getChars(0, parentEnd, theChars, 0);
             child.getChars(childStart, cn, theChars, parentEnd);
--- a/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -53,7 +53,7 @@
             break;
         }
         if (recvfrom(fd, buf, 1, MSG_PEEK,
-                         (struct sockaddr *)&rmtaddr, &addrlen) != SOCKET_ERROR) {
+                     &rmtaddr.sa, &addrlen) != SOCKET_ERROR) {
             break;
         }
         if (WSAGetLastError() != WSAECONNRESET) {
@@ -61,7 +61,7 @@
             break;
         }
 
-        recvfrom(fd, buf, 1, 0,  (struct sockaddr *)&rmtaddr, &addrlen);
+        recvfrom(fd, buf, 1, 0, &rmtaddr.sa, &addrlen);
         got_icmp = JNI_TRUE;
     }
 
@@ -134,14 +134,13 @@
 JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketBind
   (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port, jboolean exclBind) {
     SOCKETADDRESS sa;
-    int rv;
-    int sa_len = sizeof(sa);
+    int rv, sa_len = 0;
 
-    if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa,
+    if (NET_InetAddressToSockaddr(env, iaObj, port, &sa,
                                  &sa_len, JNI_TRUE) != 0) {
         return;
     }
-    rv = NET_WinBind(fd, (struct sockaddr *)&sa, sa_len, exclBind);
+    rv = NET_WinBind(fd, &sa, sa_len, exclBind);
 
     if (rv == SOCKET_ERROR) {
         if (WSAGetLastError() == WSAEACCES) {
@@ -159,17 +158,15 @@
 JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketConnect
   (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port) {
     SOCKETADDRESS sa;
-    int rv;
-    int sa_len = sizeof(sa);
+    int rv, sa_len = 0, t = TRUE;
     DWORD x1, x2; /* ignored result codes */
-    int t = TRUE;
 
-    if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa,
+    if (NET_InetAddressToSockaddr(env, iaObj, port, &sa,
                                    &sa_len, JNI_TRUE) != 0) {
         return;
     }
 
-    rv = connect(fd, (struct sockaddr *)&sa, sa_len);
+    rv = connect(fd, &sa.sa, sa_len);
     if (rv == SOCKET_ERROR) {
         NET_ThrowNew(env, WSAGetLastError(), "connect");
         return;
@@ -192,7 +189,7 @@
     int t = FALSE;
 
     memset(&sa, 0, sa_len);
-    connect(fd, (struct sockaddr *)&sa, sa_len);
+    connect(fd, &sa.sa, sa_len);
 
     /* see comment in socketCreate */
     WSAIoctl(fd, SIO_UDP_CONNRESET, &t, sizeof(t), &x1, sizeof(x1), &x2, 0, 0);
@@ -219,7 +216,7 @@
     SOCKETADDRESS sa;
     int len = sizeof(sa);
 
-    if (getsockname(fd, (struct sockaddr *)&sa, &len) == SOCKET_ERROR) {
+    if (getsockname(fd, &sa.sa, &len) == SOCKET_ERROR) {
         NET_ThrowNew(env, WSAGetLastError(), "getsockname");
         return -1;
     }
@@ -238,12 +235,12 @@
     jobject iaObj;
     int port;
 
-    if (getsockname(fd, (struct sockaddr *)&sa, &len) == SOCKET_ERROR) {
+    if (getsockname(fd, &sa.sa, &len) == SOCKET_ERROR) {
         NET_ThrowNew(env, WSAGetLastError(), "Error getting socket name");
         return NULL;
     }
 
-    iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
+    iaObj = NET_SockaddrToInetAddress(env, &sa, &port);
     return iaObj;
 }
 
@@ -316,7 +313,7 @@
 
         /* receive the packet */
         rv = recvfrom(fd, fullPacket, packetBufferLen, flags,
-                    (struct sockaddr *)&sa, &sa_len);
+                      &sa.sa, &sa_len);
 
         if (rv == SOCKET_ERROR && (WSAGetLastError() == WSAECONNRESET)) {
             /* An icmp port unreachable - we must receive this as Windows
@@ -383,15 +380,13 @@
          */
         packetAddress = (*env)->GetObjectField(env, dpObj, dp_addressID);
         if (packetAddress != NULL) {
-            if (!NET_SockaddrEqualsInetAddress(env, (struct sockaddr *)&sa,
-                                               packetAddress)) {
+            if (!NET_SockaddrEqualsInetAddress(env, &sa, packetAddress)) {
                 /* force a new InetAddress to be created */
                 packetAddress = NULL;
             }
         }
         if (packetAddress == NULL) {
-            packetAddress = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa,
-                                                      &port);
+            packetAddress = NET_SockaddrToInetAddress(env, &sa, &port);
             if (packetAddress != NULL) {
                 /* stuff the new Inetaddress into the packet */
                 (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
@@ -422,20 +417,18 @@
   (JNIEnv *env, jclass clazz, jint fd, jbyteArray data, jint offset, jint length,
      jobject iaObj, jint port, jboolean connected) {
     SOCKETADDRESS sa;
-    int sa_len = sizeof(sa);
-    SOCKETADDRESS *sap = &sa;
+    int rv, sa_len = 0;
+    struct sockaddr *sap = 0;
     char BUF[MAX_BUFFER_LEN];
     char *fullPacket;
-    int rv;
 
-    if (connected) {
-        sap = 0; /* arg to sendto () null in this case */
-        sa_len = 0;
-    } else {
-        if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa,
-                                       &sa_len, JNI_TRUE) != 0) {
+    // if already connected, sap arg to sendto() is null
+    if (!connected) {
+        if (NET_InetAddressToSockaddr(env, iaObj, port, &sa,
+                                      &sa_len, JNI_TRUE) != 0) {
             return;
         }
+        sap = &sa.sa;
     }
 
     if (length > MAX_BUFFER_LEN) {
@@ -456,7 +449,7 @@
 
     (*env)->GetByteArrayRegion(env, data, offset, length,
                                (jbyte *)fullPacket);
-    rv = sendto(fd, fullPacket, length, 0, (struct sockaddr *)sap, sa_len);
+    rv = sendto(fd, fullPacket, length, 0, sap, sa_len);
     if (rv == SOCKET_ERROR) {
         if (rv == -1) {
             NET_ThrowNew(env, WSAGetLastError(), "Datagram send failed");
--- a/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -89,15 +89,14 @@
    jboolean exclBind)
 {
     SOCKETADDRESS sa;
-    int rv;
-    int sa_len = sizeof(sa);
+    int rv, sa_len = 0;
 
-    if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa,
-                                 &sa_len, JNI_TRUE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, port, &sa,
+                                  &sa_len, JNI_TRUE) != 0) {
       return;
     }
 
-    rv = NET_WinBind(fd, (struct sockaddr *)&sa, sa_len, exclBind);
+    rv = NET_WinBind(fd, &sa, sa_len, exclBind);
 
     if (rv == SOCKET_ERROR)
         NET_ThrowNew(env, WSAGetLastError(), "NET_Bind");
@@ -111,15 +110,14 @@
 JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_connect0
   (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port) {
     SOCKETADDRESS sa;
-    int rv;
-    int sa_len = sizeof(sa);
+    int rv, sa_len = 0;
 
-    if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa,
-                                 &sa_len, JNI_TRUE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, port, &sa,
+                                  &sa_len, JNI_TRUE) != 0) {
       return -1;
     }
 
-    rv = connect(fd, (struct sockaddr *)&sa, sa_len);
+    rv = connect(fd, &sa.sa, sa_len);
     if (rv == SOCKET_ERROR) {
         int err = WSAGetLastError();
         if (err == WSAEWOULDBLOCK) {
@@ -217,7 +215,7 @@
     SOCKETADDRESS sa;
     int len = sizeof(sa);
 
-    if (getsockname(fd, (struct sockaddr *)&sa, &len) == SOCKET_ERROR) {
+    if (getsockname(fd, &sa.sa, &len) == SOCKET_ERROR) {
         if (WSAGetLastError() == WSAENOTSOCK) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                     "Socket closed");
@@ -243,11 +241,11 @@
     jclass iaContainerClass;
     jfieldID iaFieldID;
 
-    if (getsockname(fd, (struct sockaddr *)&sa, &len) == SOCKET_ERROR) {
+    if (getsockname(fd, &sa.sa, &len) == SOCKET_ERROR) {
         NET_ThrowNew(env, WSAGetLastError(), "Error getting socket name");
         return;
     }
-    iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
+    iaObj = NET_SockaddrToInetAddress(env, &sa, &port);
     CHECK_NULL(iaObj);
 
     iaContainerClass = (*env)->GetObjectClass(env, iaContainerObj);
@@ -283,7 +281,7 @@
     int len = sizeof(sa);
 
     memset((char *)&sa, 0, len);
-    newfd = accept(fd, (struct sockaddr *)&sa, &len);
+    newfd = accept(fd, &sa.sa, &len);
 
     if (newfd == INVALID_SOCKET) {
         if (WSAGetLastError() == -2) {
@@ -298,7 +296,7 @@
 
     SetHandleInformation((HANDLE)(UINT_PTR)newfd, HANDLE_FLAG_INHERIT, 0);
 
-    ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
+    ia = NET_SockaddrToInetAddress(env, &sa, &port);
     isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port);
     (*env)->SetObjectArrayElement(env, isaa, 0, isa);
 
--- a/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c	Tue Jan 24 00:30:25 2017 +0100
@@ -92,66 +92,69 @@
         int retry = 0;
 
         (*env)->GetByteArrayRegion(env, data, off, chunkLen, (jbyte *)bufP);
-
-        while(llen > 0) {
-            int n = send(fd, bufP + loff, llen, 0);
-            if (n > 0) {
-                llen -= n;
-                loff += n;
-                continue;
-            }
-
-            /*
-             * Due to a bug in Windows Sockets (observed on NT and Windows
-             * 2000) it may be necessary to retry the send. The issue is that
-             * on blocking sockets send/WSASend is supposed to block if there
-             * is insufficient buffer space available. If there are a large
-             * number of threads blocked on write due to congestion then it's
-             * possile to hit the NT/2000 bug whereby send returns WSAENOBUFS.
-             * The workaround we use is to retry the send. If we have a
-             * large buffer to send (>2k) then we retry with a maximum of
-             * 2k buffer. If we hit the issue with <=2k buffer then we backoff
-             * for 1 second and retry again. We repeat this up to a reasonable
-             * limit before bailing out and throwing an exception. In load
-             * conditions we've observed that the send will succeed after 2-3
-             * attempts but this depends on network buffers associated with
-             * other sockets draining.
-             */
-            if (WSAGetLastError() == WSAENOBUFS) {
-                if (llen > MAX_BUFFER_LEN) {
-                    buflen = MAX_BUFFER_LEN;
-                    chunkLen = MAX_BUFFER_LEN;
-                    llen = MAX_BUFFER_LEN;
+        if ((*env)->ExceptionCheck(env)) {
+            break;
+        } else {
+            while(llen > 0) {
+                int n = send(fd, bufP + loff, llen, 0);
+                if (n > 0) {
+                    llen -= n;
+                    loff += n;
                     continue;
                 }
-                if (retry >= 30) {
-                    JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
-                        "No buffer space available - exhausted attempts to queue buffer");
-                    if (bufP != BUF) {
-                        free(bufP);
-                    }
-                    return;
-                }
-                Sleep(1000);
-                retry++;
-                continue;
-            }
 
-            /*
-             * Send failed - can be caused by close or write error.
-             */
-            if (WSAGetLastError() == WSAENOTSOCK) {
-                JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
-            } else {
-                NET_ThrowCurrent(env, "socket write error");
+                /*
+                 * Due to a bug in Windows Sockets (observed on NT and Windows
+                 * 2000) it may be necessary to retry the send. The issue is that
+                 * on blocking sockets send/WSASend is supposed to block if there
+                 * is insufficient buffer space available. If there are a large
+                 * number of threads blocked on write due to congestion then it's
+                 * possile to hit the NT/2000 bug whereby send returns WSAENOBUFS.
+                 * The workaround we use is to retry the send. If we have a
+                 * large buffer to send (>2k) then we retry with a maximum of
+                 * 2k buffer. If we hit the issue with <=2k buffer then we backoff
+                 * for 1 second and retry again. We repeat this up to a reasonable
+                 * limit before bailing out and throwing an exception. In load
+                 * conditions we've observed that the send will succeed after 2-3
+                 * attempts but this depends on network buffers associated with
+                 * other sockets draining.
+                 */
+                if (WSAGetLastError() == WSAENOBUFS) {
+                    if (llen > MAX_BUFFER_LEN) {
+                        buflen = MAX_BUFFER_LEN;
+                        chunkLen = MAX_BUFFER_LEN;
+                        llen = MAX_BUFFER_LEN;
+                        continue;
+                    }
+                    if (retry >= 30) {
+                        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
+                            "No buffer space available - exhausted attempts to queue buffer");
+                        if (bufP != BUF) {
+                            free(bufP);
+                        }
+                        return;
+                    }
+                    Sleep(1000);
+                    retry++;
+                    continue;
+                }
+
+                /*
+                 * Send failed - can be caused by close or write error.
+                 */
+                if (WSAGetLastError() == WSAENOTSOCK) {
+                    JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+                } else {
+                    NET_ThrowCurrent(env, "socket write error");
+                }
+                if (bufP != BUF) {
+                    free(bufP);
+                }
+                return;
             }
-            if (bufP != BUF) {
-                free(bufP);
-            }
-            return;
+            len -= chunkLen;
+            off += chunkLen;
         }
-        len -= chunkLen;
-        off += chunkLen;
     }
 
     if (bufP != BUF) {
--- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -420,18 +420,13 @@
                                            jboolean exclBind) {
     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
     jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
-
-    int fd, fd1 = -1, family;
     int ipv6_supported = ipv6_available();
-
+    int fd, fd1 = -1, lcladdrlen = 0;
     SOCKETADDRESS lcladdr;
-    int lcladdrlen = sizeof(SOCKETADDRESS);
-    int address;
 
-    memset((char *)&lcladdr, 0, sizeof(lcladdr));
-
-    family = getInetAddress_family(env, addressObj);
-    if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
+    if (getInetAddress_family(env, addressObj) == java_net_InetAddress_IPv6 &&
+        !ipv6_supported)
+    {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         "Protocol family not supported");
         return;
@@ -446,14 +441,13 @@
             fd1 = (*env)->GetIntField(env, fd1Obj, IO_fd_fdID);
         }
     }
+
     if (IS_NULL(addressObj)) {
         JNU_ThrowNullPointerException(env, "argument address");
         return;
-    } else {
-        address = getInetAddress_addr(env, addressObj);
     }
 
-    if (NET_InetAddressToSockaddr(env, addressObj, port, &lcladdr.sa,
+    if (NET_InetAddressToSockaddr(env, addressObj, port, &lcladdr,
                                   &lcladdrlen, JNI_FALSE) != 0) {
         return;
     }
@@ -493,7 +487,7 @@
             return;
         }
     } else {
-        if (NET_WinBind(fd, &lcladdr.sa, lcladdrlen, exclBind) == -1) {
+        if (NET_WinBind(fd, &lcladdr, lcladdrlen, exclBind) == -1) {
             if (WSAGetLastError() == WSAEACCES) {
                 WSASetLastError(WSAEADDRINUSE);
             }
@@ -507,7 +501,7 @@
             NET_ThrowCurrent(env, "getsockname");
             return;
         }
-        port = ntohs((u_short) GET_PORT (&lcladdr));
+        port = ntohs((u_short)GET_PORT(&lcladdr));
     }
     (*env)->SetIntField(env, this, pdsi_localPortID, port);
 }
@@ -520,27 +514,25 @@
  */
 
 JNIEXPORT void JNICALL
-Java_java_net_TwoStacksPlainDatagramSocketImpl_connect0(JNIEnv *env, jobject this,
-                                               jobject address, jint port) {
-    /* The object's field */
+Java_java_net_TwoStacksPlainDatagramSocketImpl_connect0
+  (JNIEnv *env, jobject this, jobject address, jint port)
+{
     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
     jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
-    /* The fdObj'fd */
-    jint fd=-1, fd1=-1, fdc;
-    /* The packetAddress address, family and port */
-    jint addr, family;
+    jint fd = -1, fd1 = -1, fdc, family;
     SOCKETADDRESS rmtaddr;
-    int rmtaddrlen;
-    int ipv6_supported = ipv6_available();
+    int rmtaddrlen = 0;
 
     if (IS_NULL(fdObj) && IS_NULL(fd1Obj)) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         "Socket closed");
         return;
     }
+
     if (!IS_NULL(fdObj)) {
         fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
     }
+
     if (!IS_NULL(fd1Obj)) {
         fd1 = (*env)->GetIntField(env, fd1Obj, IO_fd_fdID);
     }
@@ -550,10 +542,8 @@
         return;
     }
 
-    addr = getInetAddress_addr(env, address);
-
     family = getInetAddress_family(env, address);
-    if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
+    if (family == java_net_InetAddress_IPv6 && !ipv6_available()) {
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         "Protocol family not supported");
         return;
@@ -572,12 +562,12 @@
         res = WSAIoctl(fdc,SIO_UDP_CONNRESET,&t,sizeof(t),&x1,sizeof(x1),&x2,0,0);
     }
 
-    if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr.sa,
+    if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr,
                                   &rmtaddrlen, JNI_FALSE) != 0) {
         return;
     }
 
-    if (connect(fdc, &rmtaddr.sa, sizeof(rmtaddr)) == -1) {
+    if (connect(fdc, &rmtaddr.sa, rmtaddrlen) == -1) {
         NET_ThrowCurrent(env, "connect");
         return;
     }
@@ -631,9 +621,9 @@
  * Signature: (Ljava/net/DatagramPacket;)V
  */
 JNIEXPORT void JNICALL
-Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
-                                           jobject packet) {
-
+Java_java_net_TwoStacksPlainDatagramSocketImpl_send
+  (JNIEnv *env, jobject this, jobject packet)
+{
     char BUF[MAX_BUFFER_LEN];
     char *fullPacket;
     jobject fdObj;
@@ -647,11 +637,10 @@
     jbyteArray packetBuffer;
     jboolean connected;
 
-    SOCKETADDRESS rmtaddr, *addrp = &rmtaddr;
+    SOCKETADDRESS rmtaddr;
+    struct sockaddr *addrp = 0;
     int addrlen = 0;
 
-    memset((char *)&rmtaddr, 0, sizeof(rmtaddr));
-
     if (IS_NULL(packet)) {
         JNU_ThrowNullPointerException(env, "null packet");
         return;
@@ -696,14 +685,13 @@
         packetBufferLen = MAX_PACKET_LEN;
     }
 
-    if (connected) {
-        addrp = 0; /* arg to sendto () null in this case */
-        addrlen = 0;
-    } else {
-        if (NET_InetAddressToSockaddr(env, iaObj, packetPort, &rmtaddr.sa,
+    // sockaddr arg to sendto() is null if already connected
+    if (!connected) {
+        if (NET_InetAddressToSockaddr(env, iaObj, packetPort, &rmtaddr,
                                       &addrlen, JNI_FALSE) != 0) {
             return;
         }
+        addrp = &rmtaddr.sa;
     }
 
     if (packetBufferLen > MAX_BUFFER_LEN) {
@@ -753,11 +741,12 @@
         fullPacket = &(BUF[0]);
     }
 
-    (*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset, packetBufferLen,
-                               (jbyte *)fullPacket);
-    if (sendto(fd, fullPacket, packetBufferLen, 0,
-               (struct sockaddr *)addrp, addrlen) == SOCKET_ERROR) {
-         NET_ThrowCurrent(env, "Datagram send failed");
+    (*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset,
+                               packetBufferLen, (jbyte *)fullPacket);
+    if (sendto(fd, fullPacket, packetBufferLen, 0, addrp,
+               addrlen) == SOCKET_ERROR)
+    {
+        NET_ThrowCurrent(env, "Datagram send failed");
     }
 
     if (packetBufferLen > MAX_BUFFER_LEN) {
@@ -1147,14 +1136,14 @@
          */
         packetAddress = (*env)->GetObjectField(env, packet, dp_addressID);
         if (packetAddress != NULL) {
-            if (!NET_SockaddrEqualsInetAddress(env, &remote_addr.sa,
+            if (!NET_SockaddrEqualsInetAddress(env, &remote_addr,
                                                packetAddress)) {
                 /* force a new InetAddress to be created */
                 packetAddress = NULL;
             }
         }
         if (packetAddress == NULL) {
-            packetAddress = NET_SockaddrToInetAddress(env, &remote_addr.sa,
+            packetAddress = NET_SockaddrToInetAddress(env, &remote_addr,
                                                       &port);
             /* stuff the new Inetaddress in the packet */
             (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
@@ -1431,20 +1420,21 @@
          * can't update any existing InetAddress because it is immutable
          */
         packetAddress = (*env)->GetObjectField(env, packet, dp_addressID);
-
         if (packetAddress != NULL) {
-            if (!NET_SockaddrEqualsInetAddress(env, &remote_addr.sa, packetAddress)) {
+            if (!NET_SockaddrEqualsInetAddress(env, &remote_addr,
+                                               packetAddress)) {
                 /* force a new InetAddress to be created */
                 packetAddress = NULL;
             }
         }
         if (packetAddress == NULL) {
-            packetAddress = NET_SockaddrToInetAddress(env, &remote_addr.sa, &port);
+            packetAddress = NET_SockaddrToInetAddress(env, &remote_addr,
+                                                      &port);
             /* stuff the new Inetaddress in the packet */
             (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
         } else {
             /* only get the new port number */
-            port = NET_GetPortFromSockaddr(&remote_addr.sa);
+            port = NET_GetPortFromSockaddr(&remote_addr);
         }
         /* populate the packet */
         (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
@@ -1528,7 +1518,7 @@
     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
     jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
     int ipv6_supported = ipv6_available();
-    int fd=-1, fd1=-1;
+    int fd = -1, fd1 = -1;
 
     if (IS_NULL(fdObj) && (!ipv6_supported || IS_NULL(fd1Obj))) {
         return;
@@ -1799,7 +1789,7 @@
 Java_java_net_TwoStacksPlainDatagramSocketImpl_socketNativeSetOption
   (JNIEnv *env,jobject this, jint opt,jobject value)
 {
-    int fd=-1, fd1=-1;
+    int fd = -1, fd1 = -1;
     int levelv4 = 0, levelv6 = 0, optnamev4 = 0, optnamev6 = 0, optlen = 0;
     union {
         int i;
@@ -2167,7 +2157,7 @@
 Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption
   (JNIEnv *env, jobject this, jint opt)
 {
-    int fd=-1, fd1=-1;
+    int fd = -1, fd1 = -1;
     int level, optname, optlen;
     union {
         int i;
@@ -2255,7 +2245,7 @@
   (JNIEnv *env, jobject this, jint family)
 {
     int fd = -1, fd1 = -1;
-    SOCKETADDRESS him;
+    SOCKETADDRESS sa;
     int len = 0;
     int port;
     jobject iaObj;
@@ -2288,12 +2278,12 @@
         return NULL;
     }
 
-    if (getsockname(fd, &him.sa, &len) == -1) {
+    if (getsockname(fd, &sa.sa, &len) == -1) {
         JNU_ThrowByNameWithMessageAndLastError
             (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
         return NULL;
     }
-    iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
+    iaObj = NET_SockaddrToInetAddress(env, &sa, &port);
 
     return iaObj;
 }
@@ -2430,7 +2420,7 @@
 
     int len, family;
     int ipv6_supported = ipv6_available();
-    int cmd ;
+    int cmd;
 
     memset((char *)&in, 0, sizeof(in));
     memset((char *)&name, 0, sizeof(name));
@@ -2452,7 +2442,7 @@
         return;
     }
 
-    if (NET_InetAddressToSockaddr(env, iaObj, 0, &name.sa, &len, JNI_FALSE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, 0, &name, &len, JNI_FALSE) != 0) {
       return;
     }
 
@@ -2473,7 +2463,7 @@
           return;
         }
         if (IS_NULL(niObj)) {
-            len = sizeof (in);
+            len = sizeof(in);
             if (NET_GetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                            (char *)&in, &len) < 0) {
                 NET_ThrowCurrent(env, "get IP_MULTICAST_IF failed");
--- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -175,8 +175,8 @@
  */
 JNIEXPORT void JNICALL
 Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
-                                            jobject iaObj, jint port,
-                                            jint timeout)
+                                                     jobject iaObj, jint port,
+                                                     jint timeout)
 {
     jint localport = (*env)->GetIntField(env, this, psi_localportID);
 
@@ -193,11 +193,11 @@
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
     jobject fd1Obj = (*env)->GetObjectField(env, this, psi_fd1ID);
 
-    SOCKETADDRESS him;
+    SOCKETADDRESS sa;
 
     /* The result of the connection */
     int connect_res;
-    memset((char *)&him, 0, sizeof(him));
+    memset((char *)&sa, 0, sizeof(sa));
 
     if (!IS_NULL(fdObj)) {
         fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
@@ -212,11 +212,12 @@
         return;
     }
 
-    if (NET_InetAddressToSockaddr(env, iaObj, port, &him.sa, &len, JNI_FALSE) != 0) {
-      return;
+    if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, &len,
+                                  JNI_FALSE) != 0) {
+        return;
     }
 
-    family = him.sa.sa_family;
+    family = sa.sa.sa_family;
     if (family == AF_INET6) {
         if (!ipv6_supported) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
@@ -248,7 +249,7 @@
     (*env)->SetObjectField(env, this, psi_fd1ID, NULL);
 
     if (timeout <= 0) {
-        connect_res = connect(fd, &him.sa, sizeof(SOCKETADDRESS));
+        connect_res = connect(fd, &sa.sa, sizeof(SOCKETADDRESS));
         if (connect_res == SOCKET_ERROR) {
             connect_res = WSAGetLastError();
         }
@@ -261,7 +262,7 @@
         ioctlsocket(fd, FIONBIO, &optval);
 
         /* initiate the connect */
-        connect_res = connect(fd, &him.sa, sizeof(SOCKETADDRESS));
+        connect_res = connect(fd, &sa.sa, sizeof(SOCKETADDRESS));
         if (connect_res == SOCKET_ERROR) {
             if (WSAGetLastError() != WSAEWOULDBLOCK) {
                 connect_res = WSAGetLastError();
@@ -362,7 +363,7 @@
          */
         u_short port;
         int len = sizeof(SOCKETADDRESS);
-        if (getsockname(fd, &him.sa, &len) == -1) {
+        if (getsockname(fd, &sa.sa, &len) == -1) {
             if (WSAGetLastError() == WSAENOTSOCK) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                                 "Socket closed");
@@ -371,7 +372,7 @@
             }
             return;
         }
-        port = ntohs((u_short)GET_PORT(&him));
+        port = ntohs((u_short)GET_PORT(&sa));
         (*env)->SetIntField(env, this, psi_localportID, (int) port);
     }
 }
@@ -396,7 +397,7 @@
     int family;
     int rv;
 
-    SOCKETADDRESS him;
+    SOCKETADDRESS sa;
 
     fdObj = (*env)->GetObjectField(env, this, psi_fdID);
     fd1Obj = (*env)->GetObjectField(env, this, psi_fd1ID);
@@ -424,13 +425,13 @@
         return;
     }
 
-    if (NET_InetAddressToSockaddr(env, iaObj, localport, &him.sa, &len,
+    if (NET_InetAddressToSockaddr(env, iaObj, localport, &sa, &len,
                                   JNI_FALSE) != 0) {
         return;
     }
     if (ipv6_supported) {
         struct ipv6bind v6bind;
-        v6bind.addr = &him;
+        v6bind.addr = &sa.sa;
         v6bind.ipv4_fd = fd;
         v6bind.ipv6_fd = fd1;
         rv = NET_BindV6(&v6bind, exclBind);
@@ -462,7 +463,7 @@
             (*env)->SetObjectField(env, this, psi_fd1ID, NULL);
         }
     } else {
-        rv = NET_WinBind(fd, &him.sa, len, exclBind);
+        rv = NET_WinBind(fd, &sa, len, exclBind);
     }
 
     if (rv == -1) {
@@ -481,11 +482,11 @@
         int len = sizeof(SOCKETADDRESS);
         u_short port;
 
-        if (getsockname(him.sa.sa_family == AF_INET ? fd: fd1, &him.sa, &len) == -1) {
+        if (getsockname(sa.sa.sa_family == AF_INET ? fd : fd1, &sa.sa, &len) == -1) {
             NET_ThrowCurrent(env, "getsockname in plain socketBind");
             return;
         }
-        port = ntohs((u_short) GET_PORT (&him));
+        port = ntohs((u_short) GET_PORT (&sa));
 
         (*env)->SetIntField(env, this, psi_localportID, (int)port);
     } else {
@@ -529,7 +530,7 @@
         JNU_ThrowNullPointerException(env, "socket address");
         return;
     }
-    if (NET_InetAddressToSockaddr(env, address, 0, &addr.sa, &addrlen,
+    if (NET_InetAddressToSockaddr(env, address, 0, &addr, &addrlen,
                                   JNI_FALSE) != 0) {
         return;
     }
@@ -585,7 +586,7 @@
     /* the fd int field on fdObj */
     jint fd=-1, fd1=-1;
 
-    SOCKETADDRESS him;
+    SOCKETADDRESS sa;
     jint len;
 
     if (IS_NULL(fdObj) && IS_NULL(fd1Obj)) {
@@ -676,7 +677,7 @@
             }
         }
     }
-    fd = accept(fd, &him.sa, &len);
+    fd = accept(fd, &sa.sa, &len);
     if (fd < 0) {
         /* REMIND: SOCKET CLOSED PROBLEM */
         if (fd == -2) {
@@ -691,7 +692,7 @@
     SetHandleInformation((HANDLE)(UINT_PTR)fd, HANDLE_FLAG_INHERIT, 0);
     (*env)->SetIntField(env, socketFdObj, IO_fd_fdID, fd);
 
-    if (him.sa.sa_family == AF_INET) {
+    if (sa.sa.sa_family == AF_INET) {
         if (inet4Cls == NULL) {
             jclass c = (*env)->FindClass(env, "java/net/Inet4Address");
             if (c != NULL) {
@@ -717,7 +718,7 @@
             return;
         }
 
-        setInetAddress_addr(env, socketAddressObj, ntohl(him.sa4.sin_addr.s_addr));
+        setInetAddress_addr(env, socketAddressObj, ntohl(sa.sa4.sin_addr.s_addr));
         setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv4);
         (*env)->SetObjectField(env, socket, psi_addressID, socketAddressObj);
     } else {
@@ -743,14 +744,14 @@
             NET_SocketClose(fd);
             return;
         }
-        setInet6Address_ipaddress(env, socketAddressObj, (char *)&him.sa6.sin6_addr);
+        setInet6Address_ipaddress(env, socketAddressObj, (char *)&sa.sa6.sin6_addr);
         setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv6);
-        setInet6Address_scopeid(env, socketAddressObj, him.sa6.sin6_scope_id);
+        setInet6Address_scopeid(env, socketAddressObj, sa.sa6.sin6_scope_id);
 
     }
     /* fields common to AF_INET and AF_INET6 */
 
-    port = ntohs ((u_short) GET_PORT (&him));
+    port = ntohs ((u_short)GET_PORT(&sa));
     (*env)->SetIntField(env, socket, psi_portID, (int)port);
     port = (*env)->GetIntField(env, this, psi_localportID);
     (*env)->SetIntField(env, socket, psi_localportID, port);
@@ -1025,14 +1026,14 @@
      * SO_BINDADDR isn't a socket option
      */
     if (opt == java_net_SocketOptions_SO_BINDADDR) {
-        SOCKETADDRESS him;
+        SOCKETADDRESS sa;
         int len = sizeof(SOCKETADDRESS);
         int port;
         jobject iaObj;
         jclass iaCntrClass;
         jfieldID iaFieldID;
 
-        memset((char *)&him, 0, len);
+        memset((char *)&sa, 0, len);
 
         if (fd == -1) {
             /* must be an IPV6 only socket. Case where both sockets are != -1
@@ -1041,12 +1042,12 @@
             fd = getFD1 (env, this);
         }
 
-        if (getsockname(fd, &him.sa, &len) < 0) {
+        if (getsockname(fd, &sa.sa, &len) < 0) {
             JNU_ThrowByNameWithMessageAndLastError
                 (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
             return -1;
         }
-        iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port);
+        iaObj = NET_SockaddrToInetAddress(env, &sa, &port);
         CHECK_NULL_RETURN(iaObj, -1);
 
         iaCntrClass = (*env)->GetObjectClass(env, iaContainerObj);
--- a/jdk/src/java.base/windows/native/libnet/net_util_md.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnet/net_util_md.c	Tue Jan 24 00:30:25 2017 +0100
@@ -488,10 +488,10 @@
  * Should be only called by the wrapper method NET_WinBind
  */
 JNIEXPORT int JNICALL
-NET_Bind(int s, struct sockaddr *him, int len)
+NET_Bind(int s, SOCKETADDRESS *sa, int len)
 {
     int rv = 0;
-    rv = bind(s, him, len);
+    rv = bind(s, &sa->sa, len);
 
     if (rv == SOCKET_ERROR) {
         /*
@@ -511,11 +511,11 @@
  * if required, and then calls NET_BIND
  */
 JNIEXPORT int JNICALL
-NET_WinBind(int s, struct sockaddr *him, int len, jboolean exclBind)
+NET_WinBind(int s, SOCKETADDRESS *sa, int len, jboolean exclBind)
 {
     if (exclBind == JNI_TRUE)
         setExclusiveBind(s);
-    return NET_Bind(s, him, len);
+    return NET_Bind(s, sa, len);
 }
 
 JNIEXPORT int JNICALL
@@ -677,8 +677,8 @@
     if (family == AF_INET && (b->addr->sa4.sin_addr.s_addr != INADDR_ANY)) {
         /* bind to v4 only */
         int ret;
-        ret = NET_WinBind((int)b->ipv4_fd, (struct sockaddr *)b->addr,
-                                sizeof(SOCKETADDRESS), exclBind);
+        ret = NET_WinBind((int)b->ipv4_fd, b->addr,
+                          sizeof(SOCKETADDRESS), exclBind);
         if (ret == SOCKET_ERROR) {
             CLOSE_SOCKETS_AND_RETURN;
         }
@@ -689,7 +689,7 @@
     if (family == AF_INET6 && (!IN6_IS_ADDR_ANY(&b->addr->sa6.sin6_addr))) {
         /* bind to v6 only */
         int ret;
-        ret = NET_WinBind((int)b->ipv6_fd, (struct sockaddr *)b->addr,
+        ret = NET_WinBind((int)b->ipv6_fd, b->addr,
                           sizeof(SOCKETADDRESS), exclBind);
         if (ret == SOCKET_ERROR) {
             CLOSE_SOCKETS_AND_RETURN;
@@ -719,7 +719,7 @@
         oaddr.sa4.sin_addr.s_addr = INADDR_ANY;
     }
 
-    rv = NET_WinBind(fd, (struct sockaddr *)b->addr, sizeof(SOCKETADDRESS), exclBind);
+    rv = NET_WinBind(fd, b->addr, sizeof(SOCKETADDRESS), exclBind);
     if (rv == SOCKET_ERROR) {
         CLOSE_SOCKETS_AND_RETURN;
     }
@@ -731,7 +731,7 @@
     }
     bound_port = GET_PORT (b->addr);
     SET_PORT (&oaddr, bound_port);
-    if ((rv = NET_WinBind(ofd, &oaddr.sa,
+    if ((rv = NET_WinBind(ofd, &oaddr,
                           sizeof(SOCKETADDRESS), exclBind)) == SOCKET_ERROR) {
         int retries;
         int sotype, arglen=sizeof(sotype);
@@ -768,7 +768,7 @@
 
             /* bind random port on first socket */
             SET_PORT (&oaddr, 0);
-            rv = NET_WinBind(ofd, &oaddr.sa, sizeof(SOCKETADDRESS), exclBind);
+            rv = NET_WinBind(ofd, &oaddr, sizeof(SOCKETADDRESS), exclBind);
             if (rv == SOCKET_ERROR) {
                 CLOSE_SOCKETS_AND_RETURN;
             }
@@ -784,8 +784,7 @@
             }
             bound_port = GET_PORT (&oaddr);
             SET_PORT (b->addr, bound_port);
-            rv = NET_WinBind(fd, (struct sockaddr *)b->addr,
-                             sizeof(SOCKETADDRESS), exclBind);
+            rv = NET_WinBind(fd, b->addr, sizeof(SOCKETADDRESS), exclBind);
 
             if (rv != SOCKET_ERROR) {
                 if (family == AF_INET) {
@@ -853,31 +852,33 @@
     return result == SOCKET_ERROR ? WSAGetLastError() : 0;
 }
 
-/* If address types is IPv6, then IPv6 must be available. Otherwise
- * no address can be generated. In the case of an IPv4 Inetaddress this
- * method will return an IPv4 mapped address where IPv6 is available and
- * v4MappedAddress is TRUE. Otherwise it will return a sockaddr_in
- * structure for an IPv4 InetAddress.
-*/
+/**
+ * See net_util.h for documentation
+ */
 JNIEXPORT int JNICALL
-NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him,
-                          int *len, jboolean v4MappedAddress) {
-    jint family, iafam;
-    iafam = getInetAddress_family(env, iaObj);
-    family = (iafam == java_net_InetAddress_IPv4)? AF_INET : AF_INET6;
-    if (ipv6_available() && !(family == AF_INET && v4MappedAddress == JNI_FALSE)) {
-        struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
+NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
+                          SOCKETADDRESS *sa, int *len,
+                          jboolean v4MappedAddress)
+{
+    jint family = getInetAddress_family(env, iaObj);
+    memset((char *)sa, 0, sizeof(SOCKETADDRESS));
+
+    if (ipv6_available() &&
+        !(family == java_net_InetAddress_IPv4 &&
+          v4MappedAddress == JNI_FALSE))
+    {
         jbyte caddr[16];
-        jint address, scopeid = 0;
-        jint cached_scope_id = 0;
+        jint address;
+        unsigned int scopeid = 0, cached_scope_id = 0;
 
-        if (family == AF_INET) { /* will convert to IPv4-mapped address */
-            memset((char *) caddr, 0, 16);
+        if (family == java_net_InetAddress_IPv4) {
+            // convert to IPv4-mapped address
+            memset((char *)caddr, 0, 16);
             address = getInetAddress_addr(env, iaObj);
             if (address == INADDR_ANY) {
                 /* we would always prefer IPv6 wildcard address
-                caddr[10] = 0xff;
-                caddr[11] = 0xff; */
+                 * caddr[10] = 0xff;
+                 * caddr[11] = 0xff; */
             } else {
                 caddr[10] = 0xff;
                 caddr[11] = 0xff;
@@ -889,46 +890,39 @@
         } else {
             getInet6Address_ipaddress(env, iaObj, (char *)caddr);
             scopeid = getInet6Address_scopeid(env, iaObj);
-            cached_scope_id = (jint)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID);
+            cached_scope_id = (unsigned int)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID);
         }
-
-        memset((char *)him6, 0, sizeof(struct sockaddr_in6));
-        him6->sin6_port = (u_short) htons((u_short)port);
-        memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) );
-        him6->sin6_family = AF_INET6;
-        if ((family == AF_INET6) && IN6_IS_ADDR_LINKLOCAL( &(him6->sin6_addr) )
-            && (!scopeid && !cached_scope_id)) {
-            cached_scope_id = getDefaultIPv6Interface(env, him6);
+        sa->sa6.sin6_port = (u_short)htons((u_short)port);
+        memcpy((void *)&sa->sa6.sin6_addr, caddr, sizeof(struct in6_addr));
+        sa->sa6.sin6_family = AF_INET6;
+        if ((family == java_net_InetAddress_IPv6) &&
+            IN6_IS_ADDR_LINKLOCAL(&sa->sa6.sin6_addr) &&
+            (!scopeid && !cached_scope_id))
+        {
+            cached_scope_id = getDefaultIPv6Interface(env, &sa->sa6);
             (*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id);
         }
-        him6->sin6_scope_id = scopeid != 0 ? scopeid : cached_scope_id;
-        *len = sizeof(struct sockaddr_in6) ;
+        sa->sa6.sin6_scope_id = scopeid == 0 ? cached_scope_id : scopeid;
+        if (len != NULL) {
+            *len = sizeof(struct sockaddr_in6);
+        }
     } else {
-        struct sockaddr_in *him4 = (struct sockaddr_in *)him;
         jint address;
-        if (family != AF_INET) {
-          JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable");
-          return -1;
+        if (family != java_net_InetAddress_IPv4) {
+            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable");
+            return -1;
         }
-        memset((char *)him4, 0, sizeof(struct sockaddr_in));
         address = getInetAddress_addr(env, iaObj);
-        him4->sin_port = htons((short) port);
-        him4->sin_addr.s_addr = (u_long) htonl(address);
-        him4->sin_family = AF_INET;
-        *len = sizeof(struct sockaddr_in);
+        sa->sa4.sin_port = htons((short)port);
+        sa->sa4.sin_addr.s_addr = (u_long)htonl(address);
+        sa->sa4.sin_family = AF_INET;
+        if (len != NULL) {
+            *len = sizeof(struct sockaddr_in);
+        }
     }
     return 0;
 }
 
-JNIEXPORT jint JNICALL
-NET_GetPortFromSockaddr(struct sockaddr *him) {
-    if (him->sa_family == AF_INET6) {
-        return ntohs(((struct sockaddr_in6 *)him)->sin6_port);
-    } else {
-        return ntohs(((struct sockaddr_in *)him)->sin_port);
-    }
-}
-
 int
 NET_IsIPv4Mapped(jbyte* caddr) {
     int i;
@@ -961,16 +955,6 @@
     return 1;
 }
 
-int getScopeID(struct sockaddr *him) {
-    struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-    return him6->sin6_scope_id;
-}
-
-int cmpScopeID(unsigned int scope, struct sockaddr *him) {
-    struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-    return him6->sin6_scope_id == scope;
-}
-
 /**
  * Wrapper for select/poll with timeout on a single file descriptor.
  *
--- a/jdk/src/java.base/windows/native/libnet/net_util_md.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnet/net_util_md.h	Tue Jan 24 00:30:25 2017 +0100
@@ -121,7 +121,7 @@
 
 JNIEXPORT int JNICALL NET_BindV6(struct ipv6bind *b, jboolean exclBind);
 
-JNIEXPORT int JNICALL NET_WinBind(int s, struct sockaddr *him, int len,
+JNIEXPORT int JNICALL NET_WinBind(int s, SOCKETADDRESS *sa, int len,
                                   jboolean exclBind);
 
 /* XP versions of the native routines */
--- a/jdk/src/java.base/windows/native/libnio/ch/DatagramChannelImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnio/ch/DatagramChannelImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -96,7 +96,7 @@
             break;
         }
         if (recvfrom(fd, buf, 1, MSG_PEEK,
-                     (struct sockaddr *)&sa, &addrlen) != SOCKET_ERROR) {
+                     &sa.sa, &addrlen) != SOCKET_ERROR) {
             break;
         }
         if (WSAGetLastError() != WSAECONNRESET) {
@@ -104,7 +104,7 @@
             break;
         }
 
-        recvfrom(fd, buf, 1, 0,  (struct sockaddr *)&sa, &addrlen);
+        recvfrom(fd, buf, 1, 0, &sa.sa, &addrlen);
         got_icmp = JNI_TRUE;
     }
 
@@ -122,7 +122,7 @@
 
     memset(&sa, 0, sa_len);
 
-    rv = connect((SOCKET)fd, (struct sockaddr *)&sa, sa_len);
+    rv = connect((SOCKET)fd, &sa.sa, sa_len);
     if (rv == SOCKET_ERROR) {
         handleSocketError(env, WSAGetLastError());
     } else {
@@ -153,7 +153,7 @@
                      (char *)buf,
                      len,
                      0,
-                     (struct sockaddr *)&sa,
+                     &sa.sa,
                      &sa_len);
 
         if (n == SOCKET_ERROR) {
@@ -182,12 +182,11 @@
      */
     senderAddr = (*env)->GetObjectField(env, this, dci_senderAddrID);
     if (senderAddr != NULL) {
-        if (!NET_SockaddrEqualsInetAddress(env, (struct sockaddr *)&sa,
-                                           senderAddr)) {
+        if (!NET_SockaddrEqualsInetAddress(env, &sa, senderAddr)) {
             senderAddr = NULL;
         } else {
             jint port = (*env)->GetIntField(env, this, dci_senderPortID);
-            if (port != NET_GetPortFromSockaddr((struct sockaddr *)&sa)) {
+            if (port != NET_GetPortFromSockaddr(&sa)) {
                 senderAddr = NULL;
             }
         }
@@ -195,7 +194,7 @@
     if (senderAddr == NULL) {
         jobject isa = NULL;
         int port;
-        jobject ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
+        jobject ia = NET_SockaddrToInetAddress(env, &sa, &port);
         if (ia != NULL) {
             isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port);
         }
@@ -204,7 +203,7 @@
         // update cachedSenderInetAddress/cachedSenderPort
         (*env)->SetObjectField(env, this, dci_senderAddrID, ia);
         (*env)->SetIntField(env, this, dci_senderPortID,
-                            NET_GetPortFromSockaddr((struct sockaddr *)&sa));
+                            NET_GetPortFromSockaddr(&sa));
         (*env)->SetObjectField(env, this, dci_senderID, isa);
     }
     return n;
@@ -219,21 +218,15 @@
     jint fd = fdval(env, fdo);
     void *buf = (void *)jlong_to_ptr(address);
     SOCKETADDRESS sa;
-    int sa_len;
+    int sa_len = 0;
     jint rv = 0;
 
-    if (NET_InetAddressToSockaddr(env, destAddress, destPort,
-                                  (struct sockaddr *)&sa,
-                                   &sa_len, preferIPv6) != 0) {
+    if (NET_InetAddressToSockaddr(env, destAddress, destPort, &sa,
+                                  &sa_len, preferIPv6) != 0) {
       return IOS_THROWN;
     }
 
-    rv = sendto((SOCKET)fd,
-               buf,
-               len,
-               0,
-               (struct sockaddr *)&sa,
-               sa_len);
+    rv = sendto((SOCKET)fd, buf, len, 0, &sa.sa, sa_len);
     if (rv == SOCKET_ERROR) {
         int theErr = (jint)WSAGetLastError();
         if (theErr == WSAEWOULDBLOCK) {
--- a/jdk/src/java.base/windows/native/libnio/ch/Net.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnio/ch/Net.c	Tue Jan 24 00:30:25 2017 +0100
@@ -168,13 +168,13 @@
 {
     SOCKETADDRESS sa;
     int rv;
-    int sa_len;
+    int sa_len = 0;
 
-    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) {
-      return;
+    if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len, preferIPv6) != 0) {
+        return;
     }
 
-    rv = NET_WinBind(fdval(env, fdo), (struct sockaddr *)&sa, sa_len, isExclBind);
+    rv = NET_WinBind(fdval(env, fdo), &sa, sa_len, isExclBind);
     if (rv == SOCKET_ERROR)
         NET_ThrowNew(env, WSAGetLastError(), "bind");
 }
@@ -194,14 +194,14 @@
 {
     SOCKETADDRESS sa;
     int rv;
-    int sa_len;
+    int sa_len = 0;
     SOCKET s = (SOCKET)fdval(env, fdo);
 
-    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) {
+    if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len, preferIPv6) != 0) {
         return IOS_THROWN;
     }
 
-    rv = connect(s, (struct sockaddr *)&sa, sa_len);
+    rv = connect(s, &sa.sa, sa_len);
     if (rv != 0) {
         int err = WSAGetLastError();
         if (err == WSAEINPROGRESS || err == WSAEWOULDBLOCK) {
@@ -226,7 +226,7 @@
     SOCKETADDRESS sa;
     int sa_len = sizeof(sa);
 
-    if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) {
+    if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) < 0) {
         int error = WSAGetLastError();
         if (error == WSAEINVAL) {
             return 0;
@@ -234,7 +234,7 @@
         NET_ThrowNew(env, error, "getsockname");
         return IOS_THROWN;
     }
-    return NET_GetPortFromSockaddr((struct sockaddr *)&sa);
+    return NET_GetPortFromSockaddr(&sa);
 }
 
 JNIEXPORT jobject JNICALL
@@ -244,11 +244,11 @@
     int sa_len = sizeof(sa);
     int port;
 
-    if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) {
+    if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) < 0) {
         NET_ThrowNew(env, WSAGetLastError(), "getsockname");
         return NULL;
     }
-    return NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
+    return NET_SockaddrToInetAddress(env, &sa, &port);
 }
 
 JNIEXPORT jint JNICALL
@@ -257,7 +257,7 @@
     SOCKETADDRESS sa;
     int sa_len = sizeof(sa);
 
-    if (getpeername(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) {
+    if (getpeername(fdval(env, fdo), &sa.sa, &sa_len) < 0) {
         int error = WSAGetLastError();
         if (error == WSAEINVAL) {
             return 0;
@@ -265,7 +265,7 @@
         NET_ThrowNew(env, error, "getsockname");
         return IOS_THROWN;
     }
-    return NET_GetPortFromSockaddr((struct sockaddr *)&sa);
+    return NET_GetPortFromSockaddr(&sa);
 }
 
 JNIEXPORT jobject JNICALL
@@ -275,11 +275,11 @@
     int sa_len = sizeof(sa);
     int port;
 
-    if (getpeername(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) {
+    if (getpeername(fdval(env, fdo), &sa.sa, &sa_len) < 0) {
         NET_ThrowNew(env, WSAGetLastError(), "getsockname");
         return NULL;
     }
-    return NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
+    return NET_SockaddrToInetAddress(env, &sa, &port);
 }
 
 JNIEXPORT jint JNICALL
--- a/jdk/src/java.base/windows/native/libnio/ch/ServerSocketChannelImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnio/ch/ServerSocketChannelImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -95,7 +95,7 @@
     int addrlen = sizeof(sa);
 
     memset((char *)&sa, 0, sizeof(sa));
-    newfd = (jint)accept(ssfd, (struct sockaddr *)&sa, &addrlen);
+    newfd = (jint)accept(ssfd, &sa.sa, &addrlen);
     if (newfd == INVALID_SOCKET) {
         int theErr = (jint)WSAGetLastError();
         if (theErr == WSAEWOULDBLOCK) {
@@ -107,7 +107,7 @@
 
     SetHandleInformation((HANDLE)(UINT_PTR)newfd, HANDLE_FLAG_INHERIT, 0);
     (*env)->SetIntField(env, newfdo, fd_fdID, newfd);
-    remote_ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, (int *)&remote_port);
+    remote_ia = NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port);
     CHECK_NULL_RETURN(remote_ia, IOS_THROWN);
 
     isa = (*env)->NewObject(env, isa_class, isa_ctorID, remote_ia, remote_port);
--- a/jdk/src/java.base/windows/native/libnio/ch/WindowsAsynchronousSocketChannelImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnio/ch/WindowsAsynchronousSocketChannelImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -88,26 +88,21 @@
 Java_sun_nio_ch_WindowsAsynchronousSocketChannelImpl_connect0(JNIEnv* env, jclass this,
     jlong socket, jboolean preferIPv6, jobject iao, jint port, jlong ov)
 {
-    SOCKET s = (SOCKET) jlong_to_ptr(socket);
-    OVERLAPPED* lpOverlapped = (OVERLAPPED*) jlong_to_ptr(ov);
+    SOCKET s = (SOCKET)jlong_to_ptr(socket);
+    OVERLAPPED *lpOverlapped = (OVERLAPPED *)jlong_to_ptr(ov);
 
     SOCKETADDRESS sa;
-    int sa_len;
+    int sa_len = 0;
     BOOL res;
 
-    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) {
+    if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len,
+                                  preferIPv6) != 0) {
         return IOS_THROWN;
     }
 
     ZeroMemory((PVOID)lpOverlapped, sizeof(OVERLAPPED));
 
-    res = (*ConnectEx_func)(s,
-                            (struct sockaddr *)&sa,
-                            sa_len,
-                            NULL,
-                            0,
-                            NULL,
-                            lpOverlapped);
+    res = (*ConnectEx_func)(s, &sa.sa, sa_len, NULL, 0, NULL, lpOverlapped);
     if (res == 0) {
         int error = GetLastError();
         if (error == ERROR_IO_PENDING) {
--- a/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 
 #define FD_SETSIZE 1024
 
+#include <limits.h>
 #include <stdlib.h>
 #include <winsock2.h>
 
@@ -74,9 +75,19 @@
     } else if (timeout < 0) {
         tv = NULL;
     } else {
+        jlong sec = timeout / 1000;
         tv = &timevalue;
-        tv->tv_sec =  (long)(timeout / 1000);
-        tv->tv_usec = (long)((timeout % 1000) * 1000);
+        //
+        // struct timeval members are signed 32-bit integers so the
+        // signed 64-bit jlong needs to be clamped
+        //
+        if (sec > INT_MAX) {
+            tv->tv_sec  = INT_MAX;
+            tv->tv_usec = 0;
+        } else {
+            tv->tv_sec  = (long)sec;
+            tv->tv_usec = (long)((timeout % 1000) * 1000);
+        }
     }
 
     /* Set FD_SET structures required for select */
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java	Tue Jan 24 00:30:25 2017 +0100
@@ -123,7 +123,7 @@
         }
 
         // grab the pointer to the CMenuBar, and retain it in native
-        nativeSetDefaultMenuBar(((CMenuBar)peer).getModel());
+        ((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar);
     }
 
     void setAboutMenuItemVisible(final boolean present) {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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
@@ -26,29 +26,28 @@
 package sun.lwawt.macosx;
 
 import java.awt.CheckboxMenuItem;
-import java.awt.EventQueue;
 import java.awt.event.ItemEvent;
 import java.awt.peer.CheckboxMenuItemPeer;
 
 import sun.awt.SunToolkit;
 
 public class CCheckboxMenuItem extends CMenuItem implements CheckboxMenuItemPeer {
-    boolean fAutoToggle = true;
-    boolean fIsIndeterminate = false;
+    volatile boolean fAutoToggle = true;
+    volatile boolean fIsIndeterminate = false;
 
     private native void nativeSetState(long modelPtr, boolean state);
     private native void nativeSetIsCheckbox(long modelPtr);
 
-    CCheckboxMenuItem(CheckboxMenuItem target) {
+    CCheckboxMenuItem(final CheckboxMenuItem target) {
         super(target);
-        nativeSetIsCheckbox(getModel());
+        execute(this::nativeSetIsCheckbox);
         setState(target.getState());
     }
 
     // MenuItemPeer implementation
     @Override
-    public void setState(boolean state) {
-        nativeSetState(getModel(), state);
+    public void setState(final boolean state) {
+        execute(ptr -> nativeSetState(ptr, state));
     }
 
     public void handleAction(final boolean state) {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Tue Jan 24 00:30:25 2017 +0100
@@ -23,7 +23,6 @@
  * questions.
  */
 
-
 package sun.lwawt.macosx;
 
 /**
@@ -34,6 +33,7 @@
     private static native void nativeCFRelease(final long ptr, final boolean disposeOnAppKitThread);
 
     private final boolean disposeOnAppKitThread;
+    // TODO this pointer should be private and accessed via CFNativeAction class
     protected volatile long ptr;
 
     /**
@@ -70,8 +70,72 @@
         nativeCFRelease(oldPtr, disposeOnAppKitThread); // perform outside of the synchronized block
     }
 
+    /**
+     * The interface which allows to execute some native operations with
+     * assumption that the native pointer will be valid till the end.
+     */
+    public interface CFNativeAction {
+
+        /**
+         * The native operation should be called from this method.
+         *
+         * @param  ptr the pointer to the native data
+         */
+        void run(long ptr);
+    }
+
+    /**
+     * The interface which allows to execute some native operations and get a
+     * result with assumption that the native pointer will be valid till the
+     * end.
+     */
+    interface CFNativeActionGet {
+
+        /**
+         * The native operation should be called from this method.
+         *
+         * @param  ptr the pointer to the native data
+         * @return result of the native operation
+         */
+        long run(long ptr);
+    }
+
+    /**
+     * This is utility method which should be used instead of the direct access
+     * to the {@link #ptr}, because this method guaranteed that the pointer will
+     * not be zero and will be valid till the end of the operation.It is highly
+     * recomended to not use any external lock in action. If the current
+     * {@link #ptr} is {@code 0} then action will be ignored.
+     *
+     * @param  action The native operation
+     */
+    public final synchronized void execute(final CFNativeAction action) {
+        if (ptr != 0) {
+            action.run(ptr);
+        }
+    }
+
+    /**
+     * This is utility method which should be used instead of the direct access
+     * to the {@link #ptr}, because this method guaranteed that the pointer will
+     * not be zero and will be valid till the end of the operation. It is highly
+     * recomended to not use any external lock in action. If the current
+     * {@link #ptr} is {@code 0} then action will be ignored and {@code} is
+     * returned.
+     *
+     * @param  action the native operation
+     * @return result of the native operation, usually the native pointer to
+     *         some other data
+     */
+    final synchronized long executeGet(final CFNativeActionGet action) {
+        if (ptr != 0) {
+            return action.run(ptr);
+        }
+        return 0;
+    }
+
     @Override
-    protected void finalize() throws Throwable {
+    protected final void finalize() throws Throwable {
         dispose();
     }
 }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenu.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenu.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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
@@ -25,7 +25,9 @@
 
 package sun.lwawt.macosx;
 
-import java.awt.*;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
 import java.awt.peer.MenuItemPeer;
 import java.awt.peer.MenuPeer;
 
@@ -37,7 +39,7 @@
 
     // This way we avoiding invocation of the setters twice
     @Override
-    protected void initialize(MenuItem target) {
+    protected final void initialize(MenuItem target) {
         setLabel(target.getLabel());
         setEnabled(target.isEnabled());
     }
@@ -57,52 +59,50 @@
     }
 
     @Override
-    protected long createModel() {
+    long createModel() {
         CMenuComponent parent = (CMenuComponent)
             LWCToolkit.targetToPeer(getTarget().getParent());
 
-        if (parent instanceof CMenu ||
-            parent instanceof CPopupMenu)
-        {
-            return nativeCreateSubMenu(parent.getModel());
-        } else if (parent instanceof CMenuBar) {
+        if (parent instanceof CMenu) {
+            return parent.executeGet(this::nativeCreateSubMenu);
+        }
+        if (parent instanceof CMenuBar) {
             MenuBar parentContainer = (MenuBar)getTarget().getParent();
             boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget();
             int insertionLocation = ((CMenuBar)parent).getNextInsertionIndex();
-            return nativeCreateMenu(parent.getModel(),
-                                    isHelpMenu, insertionLocation);
-        } else {
-            throw new InternalError("Parent must be CMenu or CMenuBar");
+            return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu,
+                                                             insertionLocation));
         }
+        throw new InternalError("Parent must be CMenu or CMenuBar");
     }
 
     @Override
-    public void addItem(MenuItem item) {
+    public final void addItem(MenuItem item) {
         // Nothing to do here -- we added it when we created the
         // menu item's peer.
     }
 
     @Override
-    public void delItem(int index) {
-        nativeDeleteItem(getModel(), index);
+    public final void delItem(final int index) {
+        execute(ptr -> nativeDeleteItem(ptr, index));
     }
 
     @Override
-    public void setLabel(String label) {
-        nativeSetMenuTitle(getModel(), label);
+    public final void setLabel(final String label) {
+        execute(ptr->nativeSetMenuTitle(ptr, label));
         super.setLabel(label);
     }
 
     // Note that addSeparator is never called directly from java.awt.Menu,
     // though it is required in the MenuPeer interface.
     @Override
-    public void addSeparator() {
-        nativeAddSeparator(getModel());
+    public final void addSeparator() {
+        execute(this::nativeAddSeparator);
     }
 
     // Used by ScreenMenuBar to get to the native menu for event handling.
-    public long getNativeMenu() {
-        return nativeGetNSMenu(getModel());
+    public final long getNativeMenu() {
+        return executeGet(this::nativeGetNSMenu);
     }
 
     private native long nativeCreateMenu(long parentMenuPtr,
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuBar.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuBar.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, 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
@@ -31,7 +31,7 @@
 
 import sun.awt.AWTAccessor;
 
-public class CMenuBar extends CMenuComponent implements MenuBarPeer {
+public final class CMenuBar extends CMenuComponent implements MenuBarPeer {
 
     private int nextInsertionIndex = -1;
 
@@ -40,14 +40,15 @@
     }
 
     @Override
-    protected long createModel() {
+    long createModel() {
         return nativeCreateMenuBar();
     }
 
     @Override
-    public void addHelpMenu(Menu m) {
-        CMenu cMenu = AWTAccessor.getMenuComponentAccessor().getPeer(m);
-        nativeSetHelpMenu(getModel(), cMenu.getModel());
+    public void addHelpMenu(final Menu m) {
+        final CMenu cMenu = AWTAccessor.getMenuComponentAccessor().getPeer(m);
+        execute(parentPtr -> cMenu.execute(
+                menuPtr -> nativeSetHelpMenu(parentPtr, menuPtr)));
     }
 
     public int getNextInsertionIndex() {
@@ -65,8 +66,8 @@
     }
 
     @Override
-    public void delMenu(int index) {
-        nativeDelMenu(getModel(), index);
+    public void delMenu(final int index) {
+        execute(ptr -> nativeDelMenu(ptr, index));
     }
 
     private native long nativeCreateMenuBar();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuComponent.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuComponent.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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
@@ -29,36 +29,32 @@
 import java.awt.MenuComponent;
 import java.awt.peer.MenuComponentPeer;
 
-public abstract class CMenuComponent implements MenuComponentPeer {
+abstract class CMenuComponent extends CFRetainedResource
+        implements MenuComponentPeer {
+
+    private final MenuComponent target;
 
-    private MenuComponent target;
-    private long modelPtr;
-
-    CMenuComponent(MenuComponent target) {
+    CMenuComponent(final MenuComponent target) {
+        super(0, true);
         this.target = target;
-        this.modelPtr = createModel();
+        setPtr(createModel());
     }
 
-    MenuComponent getTarget() {
+    final MenuComponent getTarget() {
         return target;
     }
 
-    public long getModel() {
-        return modelPtr;
+    abstract long createModel();
+
+    @Override
+    public final void dispose() {
+        super.dispose();
+        LWCToolkit.targetDisposedPeer(target, this);
     }
 
-    protected abstract long createModel();
-
-    public void dispose() {
-        LWCToolkit.targetDisposedPeer(target, this);
-        nativeDispose(modelPtr);
-        target = null;
-    }
-
-    private native void nativeDispose(long modelPtr);
-
     // 1.5 peer method
-    public void setFont(Font f) {
+    @Override
+    public final void setFont(final Font f) {
         // no-op, as we don't currently support menu fonts
         // c.f. radar 4032912
     }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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
@@ -25,16 +25,17 @@
 
 package sun.lwawt.macosx;
 
+import java.awt.MenuItem;
+import java.awt.MenuShortcut;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.peer.MenuItemPeer;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 import sun.awt.SunToolkit;
 import sun.lwawt.LWToolkit;
 
-import java.awt.MenuContainer;
-import java.awt.MenuItem;
-import java.awt.MenuShortcut;
-import java.awt.event.*;
-import java.awt.peer.MenuItemPeer;
-import java.util.concurrent.atomic.AtomicBoolean;
-
 public class CMenuItem extends CMenuComponent implements MenuItemPeer {
 
     private final AtomicBoolean enabled = new AtomicBoolean(true);
@@ -58,9 +59,9 @@
     }
 
     @Override
-    protected long createModel() {
+    long createModel() {
         CMenuComponent parent = (CMenuComponent)LWToolkit.targetToPeer(getTarget().getParent());
-        return nativeCreate(parent.getModel(), isSeparator());
+        return parent.executeGet(ptr->nativeCreate(ptr, isSeparator()));
     }
 
     public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
@@ -90,7 +91,12 @@
             keyChar = 0;
         }
 
-        nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask);
+        final String finalLabel = label;
+        final char finalKeyChar = keyChar;
+        final int finalKeyCode = keyCode;
+        final int finalKeyMask = keyMask;
+        execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
+                                      finalKeyCode, finalKeyMask));
     }
 
     @Override
@@ -105,16 +111,16 @@
      * There isn't a need to expose this except in a instanceof because
      * it isn't defined in the peer api.
      */
-    public void setImage(java.awt.Image img) {
+    public final void setImage(final java.awt.Image img) {
         CImage cimg = CImage.getCreator().createFromImage(img);
-        nativeSetImage(getModel(), cimg == null ? 0L : cimg.ptr);
+        execute(ptr -> nativeSetImage(ptr, cimg == null ? 0L : cimg.ptr));
     }
 
     /**
      * New API for tooltips
      */
-    public void setToolTipText(String text) {
-        nativeSetTooltip(getModel(), text);
+    public final void setToolTipText(final String text) {
+        execute(ptr -> nativeSetTooltip(ptr, text));
     }
 
 //    @Override
@@ -138,7 +144,8 @@
             b &= ((CMenuItem) parent).isEnabled();
         }
         if (enabled.compareAndSet(!b, b)) {
-            nativeSetEnabled(getModel(), b);
+            final boolean finalB = b;
+            execute(ptr->nativeSetEnabled(ptr, finalB));
         }
     }
 
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Tue Jan 24 00:30:25 2017 +0100
@@ -231,6 +231,7 @@
     private boolean isFullScreenAnimationOn;
 
     private volatile boolean isInFullScreen;
+    private volatile boolean isIconifyAnimationActive;
 
     private Window target;
     private LWWindowPeer peer;
@@ -448,7 +449,7 @@
         final long nsWindowPtr = getNSWindowPtr();
         CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb);
         if (mbPeer != null) {
-            nativeSetNSWindowMenuBar(nsWindowPtr, mbPeer.getModel());
+            mbPeer.execute(ptr -> nativeSetNSWindowMenuBar(nsWindowPtr, ptr));
         } else {
             nativeSetNSWindowMenuBar(nsWindowPtr, 0);
         }
@@ -997,6 +998,9 @@
         if (peer != null) {
             peer.notifyIconify(iconify);
         }
+        if (iconify) {
+            isIconifyAnimationActive = false;
+        }
     }
 
     private void deliverZoom(final boolean isZoomed) {
@@ -1071,6 +1075,17 @@
         return true;
     }
 
+    private boolean isIconified() {
+        boolean isIconified = false;
+        if (target instanceof Frame) {
+            int state = ((Frame)target).getExtendedState();
+            if ((state & Frame.ICONIFIED) != 0) {
+                isIconified = true;
+            }
+        }
+        return isIconifyAnimationActive || isIconified;
+    }
+
     private boolean isOneOfOwnersOrSelf(CPlatformWindow window) {
         while (window != null) {
             if (this == window) {
@@ -1094,11 +1109,14 @@
         // the windows are ordered above their nearest owner; ancestors of the window,
         // which is going to become 'main window', are placed above their siblings.
         CPlatformWindow rootOwner = getRootOwner();
-        if (rootOwner.isVisible()) {
+        if (rootOwner.isVisible() && !rootOwner.isIconified()) {
             CWrapper.NSWindow.orderFront(rootOwner.getNSWindowPtr());
         }
-        final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
-        orderAboveSiblingsImpl(windowAccessor.getOwnedWindows(rootOwner.target));
+        // Do not order child windows of iconified owner.
+        if (!rootOwner.isIconified()) {
+            final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
+            orderAboveSiblingsImpl(windowAccessor.getOwnedWindows(rootOwner.target));
+        }
     }
 
     private void orderAboveSiblingsImpl(Window[] windows) {
@@ -1109,10 +1127,12 @@
 
         // Go through the list of windows and perform ordering.
         for (Window w : windows) {
+            boolean iconified = false;
             final Object p = componentAccessor.getPeer(w);
             if (p instanceof LWWindowPeer) {
                 CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
-                if (pw != null && pw.isVisible()) {
+                iconified = isIconified();
+                if (pw != null && pw.isVisible() && !iconified) {
                     // If the window is one of ancestors of 'main window' or is going to become main by itself,
                     // the window should be ordered above its siblings; otherwise the window is just ordered
                     // above its nearest parent.
@@ -1125,10 +1145,13 @@
                     pw.applyWindowLevel(w);
                 }
             }
-            // Retrieve the child windows for each window from the list and store them for future use.
+            // Retrieve the child windows for each window from the list except iconified ones
+            // and store them for future use.
             // Note: we collect data about child windows even for invisible owners, since they may have
             // visible children.
-            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
+            if (!iconified) {
+                childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
+            }
         }
         // If some windows, which have just been ordered, have any child windows, let's start new iteration
         // and order these child windows.
@@ -1149,6 +1172,10 @@
     //                          NATIVE CALLBACKS
     // ----------------------------------------------------------------------
 
+    private void windowWillMiniaturize() {
+        isIconifyAnimationActive = true;
+    }
+
     private void windowDidBecomeMain() {
         if (checkBlockingAndOrder()) return;
         // If it's not blocked, make sure it's above its siblings
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPopupMenu.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPopupMenu.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, 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
@@ -25,18 +25,20 @@
 
 package sun.lwawt.macosx;
 
-import java.awt.*;
+import java.awt.Component;
+import java.awt.Event;
+import java.awt.Point;
+import java.awt.PopupMenu;
 import java.awt.peer.PopupMenuPeer;
 
-import sun.lwawt.LWWindowPeer;
+final class CPopupMenu extends CMenu implements PopupMenuPeer {
 
-public class CPopupMenu extends CMenu implements PopupMenuPeer {
     CPopupMenu(PopupMenu target) {
         super(target);
     }
 
     @Override
-    protected long createModel() {
+    long createModel() {
         return nativeCreatePopupMenu();
     }
 
@@ -50,7 +52,7 @@
             Point loc = origin.getLocationOnScreen();
             e.x += loc.x;
             e.y += loc.y;
-            nativeShowPopupMenu(getModel(), e.x, e.y);
+            execute(ptr -> nativeShowPopupMenu(ptr, e.x, e.y));
         }
     }
 }
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, 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
@@ -118,7 +118,10 @@
             }
         }
 
-        return checkAndCreatePopupPeer().getModel();
+        // This method is executed on Appkit, so if ptr is not zero means that,
+        // it is still not deallocated(even if we call NSApp postRunnableEvent)
+        // and sent CFRelease to the native queue
+        return checkAndCreatePopupPeer().ptr;
     }
 
     /**
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Tue Jan 24 00:30:25 2017 +0100
@@ -327,10 +327,43 @@
     return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
 }
 
+// Retrieves the list of possible window layers (levels)
++ (NSArray*) getWindowLayers {
+    static NSArray *windowLayers;
+    static dispatch_once_t token;
+
+    // Initialize the list of possible window layers
+    dispatch_once(&token, ^{
+        // The layers are ordered from front to back, (i.e. the toppest one is the first)
+        windowLayers = [NSArray arrayWithObjects:
+                            [NSNumber numberWithInt:CGWindowLevelForKey(kCGPopUpMenuWindowLevelKey)],
+                            [NSNumber numberWithInt:CGWindowLevelForKey(kCGFloatingWindowLevelKey)],
+                            [NSNumber numberWithInt:CGWindowLevelForKey(kCGNormalWindowLevelKey)],
+                            nil
+                        ];
+        [windowLayers retain];
+    });
+    return windowLayers;
+}
+
 // returns id for the topmost window under mouse
 + (NSInteger) getTopmostWindowUnderMouseID {
     NSInteger result = -1;
 
+    NSArray *windowLayers = [AWTWindow getWindowLayers];
+    // Looking for the window under mouse starting from the toppest layer
+    for (NSNumber *layer in windowLayers) {
+        result = [AWTWindow getTopmostWindowUnderMouseIDImpl:[layer integerValue]];
+        if (result != -1) {
+            break;
+        }
+    }
+    return result;
+}
+
++ (NSInteger) getTopmostWindowUnderMouseIDImpl:(NSInteger)windowLayer {
+    NSInteger result = -1;
+
     NSRect screenRect = [[NSScreen mainScreen] frame];
     NSPoint nsMouseLocation = [NSEvent mouseLocation];
     CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
@@ -339,7 +372,7 @@
 
     for (NSDictionary *window in windows) {
         NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue];
-        if (layer == 0) {
+        if (layer == windowLayer) {
             CGRect rect;
             CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
             if (CGRectContainsPoint(rect, cgMouseLocation)) {
@@ -639,6 +672,14 @@
 AWT_ASSERT_APPKIT_THREAD;
 
     self.isMinimizing = YES;
+
+    JNIEnv *env = [ThreadUtilities getJNIEnv];
+    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
+    if (platformWindow != NULL) {
+        static JNF_MEMBER_CACHE(jm_windowWillMiniaturize, jc_CPlatformWindow, "windowWillMiniaturize", "()V");
+        JNFCallVoidMethod(env, platformWindow, jm_windowWillMiniaturize);
+        (*env)->DeleteLocalRef(env, platformWindow);
+    }
     // Excplicitly make myself a key window to avoid possible
     // negative visual effects during iconify operation
     [self.nsWindow makeKeyAndOrderFront:self.nsWindow];
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m	Tue Jan 24 00:30:25 2017 +0100
@@ -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
@@ -38,7 +38,7 @@
 - (id)initWithPeer:(jobject)peer {
 AWT_ASSERT_APPKIT_THREAD;
     // Create the new NSMenu
-    self = [super initWithPeer:peer asSeparator:[NSNumber numberWithBool:NO]];
+    self = [super initWithPeer:peer asSeparator:NO];
     if (self) {
         fMenu = [NSMenu javaMenuWithTitle:@""];
         [fMenu retain];
@@ -133,14 +133,13 @@
 
 CMenu * createCMenu (jobject cPeerObjGlobal) {
 
-    CMenu *aCMenu = nil;
+    __block CMenu *aCMenu = nil;
+
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 
-    // We use an array here only to be able to get a return value
-    NSMutableArray *args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], nil];
-
-    [ThreadUtilities performOnMainThread:@selector(_create_OnAppKitThread:) on:[CMenu alloc] withObject:args waitUntilDone:YES];
-
-    aCMenu = (CMenu *)[args objectAtIndex: 0];
+        aCMenu = [[CMenu alloc] initWithPeer:cPeerObjGlobal];
+        // the aCMenu is released in CMenuComponent.dispose()
+    }];
 
     if (aCMenu == nil) {
         return 0L;
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m	Tue Jan 24 00:30:25 2017 +0100
@@ -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
@@ -383,27 +383,20 @@
 Java_sun_lwawt_macosx_CMenuBar_nativeCreateMenuBar
     (JNIEnv *env, jobject peer)
 {
-    CMenuBar *aCMenuBar = nil;
+    __block CMenuBar *aCMenuBar = nil;
     JNF_COCOA_ENTER(env);
 
     jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
 
-    // We use an array here only to be able to get a return value
-    NSMutableArray *args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], nil];
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 
-    [ThreadUtilities performOnMainThread:@selector(_create_OnAppKitThread:) on:[CMenuBar alloc] withObject:args waitUntilDone:YES];
-
-    aCMenuBar = (CMenuBar *)[args objectAtIndex: 0];
-
+        aCMenuBar = [[CMenuBar alloc] initWithPeer:cPeerObjGlobal];
+        // the aCMenuBar is released in CMenuComponent.dispose()
+    }];
     if (aCMenuBar == nil) {
         return 0L;
     }
 
-    // [args release];
-
-    // A strange memory managment after that.
-
-
     JNF_COCOA_EXIT(env);
     return ptr_to_jlong(aCMenuBar);
 }
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m	Tue Jan 24 00:30:25 2017 +0100
@@ -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
@@ -41,45 +41,11 @@
     return self;
 }
 
--(void) cleanup {
-    // Used by subclasses
-}
-
--(void) disposer {
+- (void)dealloc {
     JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
     JNFDeleteGlobalRef(env, fPeer);
     fPeer = NULL;
 
-    [self cleanup];
-    [self release];
+    [super dealloc];
 }
-
-// The method is used by all subclasses, since the process of the creation
-// is the same. The only exception is the CMenuItem class.
-- (void) _create_OnAppKitThread: (NSMutableArray *)argValue {
-    jobject cPeerObjGlobal = (jobject)[[argValue objectAtIndex: 0] pointerValue];
-    CMenuItem *aCMenuItem = [self initWithPeer:cPeerObjGlobal];
-    [argValue removeAllObjects];
-    [argValue addObject: aCMenuItem];
-}
-
 @end
-
-/*
- * Class:     sun_lwawt_macosx_CMenuComponent
- * Method:    nativeDispose
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL
-Java_sun_lwawt_macosx_CMenuComponent_nativeDispose
-(JNIEnv *env, jobject peer, jlong menuItemObj)
-{
-JNF_COCOA_ENTER(env);
-
-    [ThreadUtilities performOnMainThread:@selector(disposer)
-                                      on:((id)jlong_to_ptr(menuItemObj))
-                              withObject:nil
-                           waitUntilDone:NO];
-
-JNF_COCOA_EXIT(env);
-}
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.h	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, 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
@@ -32,7 +32,7 @@
 }
 
 // Setup
-- (id) initWithPeer:(jobject)peer asSeparator: (NSNumber *) asSeparator;
+- (id) initWithPeer:(jobject)peer asSeparator: (BOOL) asSeparator;
 - (void) setIsCheckbox;
 
 // Events
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, 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
@@ -39,11 +39,11 @@
 
 @implementation CMenuItem
 
-- (id) initWithPeer:(jobject)peer asSeparator: (NSNumber *) asSeparator{
+- (id) initWithPeer:(jobject)peer asSeparator: (BOOL) asSeparator{
     AWT_ASSERT_APPKIT_THREAD;
     self = [super initWithPeer:peer];
     if (self) {
-        if ([asSeparator boolValue]) {
+        if (asSeparator) {
             fMenuItem = (NSMenuItem*)[NSMenuItem separatorItem];
             [fMenuItem retain];
         } else {
@@ -204,12 +204,9 @@
     }];
 }
 
-- (void)cleanup {
+- (void)dealloc {
     [fMenuItem setAction:NULL];
     [fMenuItem setTarget:nil];
-}
-
-- (void)dealloc {
     [fMenuItem release];
     fMenuItem = nil;
     
@@ -228,14 +225,6 @@
     fIsCheckbox = YES;
 }
 
-- (void) _createMenuItem_OnAppKitThread: (NSMutableArray *)argValue {
-    jobject cPeerObjGlobal = (jobject)[[argValue objectAtIndex: 0] pointerValue];
-    NSNumber * asSeparator = (NSNumber *)[argValue objectAtIndex: 1];
-    CMenuItem *aCMenuItem = [self initWithPeer: cPeerObjGlobal asSeparator: asSeparator];
-    [argValue removeAllObjects];
-    [argValue addObject: aCMenuItem];
-}
-
 - (NSString *)description {
     return [NSString stringWithFormat:@"CMenuItem[ %@ ]", fMenuItem];
 }
@@ -397,24 +386,18 @@
 (JNIEnv *env, jobject peer, jlong parentCMenuObj, jboolean isSeparator)
 {
     
-    CMenuItem *aCMenuItem = nil;
+    __block CMenuItem *aCMenuItem = nil;
+    BOOL asSeparator = (isSeparator == JNI_TRUE) ? YES: NO;
     CMenu *parentCMenu = (CMenu *)jlong_to_ptr(parentCMenuObj);
     JNF_COCOA_ENTER(env);
     
     jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
-    
-    NSMutableArray *args = nil;
-    
-    // Create a new item....
-    if (isSeparator == JNI_TRUE) {
-        args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:YES],  nil];
-    } else {
-        args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:NO],  nil];
-    }
-    
-    [ThreadUtilities performOnMainThread:@selector(_createMenuItem_OnAppKitThread:) on:[CMenuItem alloc] withObject:args waitUntilDone:YES];
-    
-    aCMenuItem = (CMenuItem *)[args objectAtIndex: 0];
+
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
+        aCMenuItem = [[CMenuItem alloc] initWithPeer: cPeerObjGlobal
+                                         asSeparator: asSeparator];
+        // the CMenuItem is released in CMenuComponent.dispose()
+    }];
     
     if (aCMenuItem == nil) {
         return 0L;
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java	Tue Jan 24 00:30:25 2017 +0100
@@ -735,7 +735,11 @@
                     parse_iCCP_chunk(chunkLength);
                     break;
                 case iTXt_TYPE:
-                    parse_iTXt_chunk(chunkLength);
+                    if (ignoreMetadata) {
+                        stream.skipBytes(chunkLength);
+                    } else {
+                        parse_iTXt_chunk(chunkLength);
+                    }
                     break;
                 case pHYs_TYPE:
                     parse_pHYs_chunk();
@@ -759,7 +763,11 @@
                     parse_tRNS_chunk(chunkLength);
                     break;
                 case zTXt_TYPE:
-                    parse_zTXt_chunk(chunkLength);
+                    if (ignoreMetadata) {
+                        stream.skipBytes(chunkLength);
+                    } else {
+                        parse_zTXt_chunk(chunkLength);
+                    }
                     break;
                 default:
                     // Read an unknown chunk
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -730,18 +730,47 @@
             // to use it if the data layout is component type.
             if (iccProfileField != null
                     && itsRaw.getColorModel() instanceof ComponentColorModel) {
-                // Create a ColorSpace from the profile.
-                byte[] iccProfileValue = iccProfileField.getAsBytes();
-                ICC_Profile iccProfile
-                        = ICC_Profile.getInstance(iccProfileValue);
-                ICC_ColorSpace iccColorSpace
-                        = new ICC_ColorSpace(iccProfile);
-
                 // Get the raw sample and color information.
                 ColorModel cmRaw = itsRaw.getColorModel();
                 ColorSpace csRaw = cmRaw.getColorSpace();
                 SampleModel smRaw = itsRaw.getSampleModel();
 
+                ColorSpace iccColorSpace = null;
+                try {
+                    // Create a ColorSpace from the profile.
+                    byte[] iccProfileValue = iccProfileField.getAsBytes();
+                    ICC_Profile iccProfile
+                        = ICC_Profile.getInstance(iccProfileValue);
+                    iccColorSpace = new ICC_ColorSpace(iccProfile);
+
+                    // Workaround for JDK-8145241: test a conversion and fall
+                    // back to a standard ColorSpace if it fails. This
+                    // workaround could be removed if JDK-8145241 is fixed.
+                    float[] rgb =
+                        iccColorSpace.toRGB(new float[] {1.0F, 1.0F, 1.0F});
+                } catch (Exception iccProfileException) {
+                    processWarningOccurred("Superseding bad ICC profile: "
+                        + iccProfileException.getMessage());
+
+                    if (iccColorSpace != null) {
+                        switch (iccColorSpace.getType()) {
+                            case ColorSpace.TYPE_GRAY:
+                                iccColorSpace =
+                                    ColorSpace.getInstance(ColorSpace.CS_GRAY);
+                                break;
+                            case ColorSpace.TYPE_RGB:
+                                iccColorSpace =
+                                    ColorSpace.getInstance(ColorSpace.CS_sRGB);
+                                break;
+                            default:
+                                iccColorSpace = csRaw;
+                                break;
+                        }
+                    } else {
+                        iccColorSpace = csRaw;
+                    }
+                }
+
                 // Get the number of samples per pixel and the number
                 // of color components.
                 int numBands = smRaw.getNumBands();
--- a/jdk/src/java.desktop/share/classes/java/beans/AppletInitializer.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/java/beans/AppletInitializer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -30,21 +30,20 @@
 import java.beans.beancontext.BeanContext;
 
 /**
- * <p>
  * This interface is designed to work in collusion with java.beans.Beans.instantiate.
  * The interface is intended to provide mechanism to allow the proper
  * initialization of JavaBeans that are also Applets, during their
  * instantiation by java.beans.Beans.instantiate().
- * </p>
  *
  * @see java.beans.Beans#instantiate
  *
  * @since 1.2
  *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
-
-
-@SuppressWarnings("deprecation")
+@Deprecated(since = "9")
 public interface AppletInitializer {
 
     /**
@@ -74,7 +73,6 @@
      * @param bCtxt          The BeanContext intended for this Applet, or
      *                       null.
      */
-
     void initialize(Applet newAppletBean, BeanContext bCtxt);
 
     /**
@@ -86,6 +84,5 @@
      *
      * @param newApplet  The newly instantiated JavaBean
      */
-
     void activate(Applet newApplet);
 }
--- a/jdk/src/java.desktop/share/classes/java/beans/Beans.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/java/beans/Beans.java	Tue Jan 24 00:30:25 2017 +0100
@@ -97,8 +97,10 @@
      * @exception IOException if an I/O error occurs.
      * @since 1.2
      */
-
-    public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException {
+    @SuppressWarnings("deprecation")
+    public static Object instantiate(ClassLoader cls, String beanName,
+                                     BeanContext beanContext)
+            throws IOException, ClassNotFoundException {
         return Beans.instantiate(cls, beanName, beanContext, null);
     }
 
@@ -153,10 +155,18 @@
      *              object could not be found.
      * @exception IOException if an I/O error occurs.
      * @since 1.2
+     *
+     * @deprecated It is recommended to use
+     * {@link #instantiate(ClassLoader, String, BeanContext)},
+     * because the Applet API is deprecated. See the
+     * <a href="../../java/applet/package-summary.html"> java.applet package
+     * documentation</a> for further information.
      */
-    @SuppressWarnings("deprecation")
-    public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer)
-                        throws IOException, ClassNotFoundException {
+    @Deprecated(since = "9")
+    public static Object instantiate(ClassLoader cls, String beanName,
+                                     BeanContext beanContext,
+                                     AppletInitializer initializer)
+            throws IOException, ClassNotFoundException {
 
         InputStream ins;
         ObjectInputStream oins = null;
@@ -501,7 +511,7 @@
  * Package private support class.  This provides a default AppletContext
  * for beans which are applets.
  */
-@SuppressWarnings("deprecation")
+@Deprecated(since = "9")
 class BeansAppletContext implements AppletContext {
     Applet target;
     Hashtable<URL,Object> imageCache = new Hashtable<>();
@@ -586,7 +596,7 @@
  * Package private support class.  This provides an AppletStub
  * for beans which are applets.
  */
-@SuppressWarnings("deprecation")
+@Deprecated(since = "9")
 class BeansAppletStub implements AppletStub {
     transient boolean active;
     transient Applet target;
--- a/jdk/src/java.desktop/share/classes/javax/swing/PopupFactory.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/PopupFactory.java	Tue Jan 24 00:30:25 2017 +0100
@@ -260,6 +260,7 @@
      * Obtains the appropriate <code>Popup</code> based on
      * <code>popupType</code>.
      */
+    @SuppressWarnings("deprecation")
     private Popup getPopup(Component owner, Component contents,
                            int ownerX, int ownerY, int popupType) {
         if (GraphicsEnvironment.isHeadless()) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Tue Jan 24 00:30:25 2017 +0100
@@ -525,8 +525,12 @@
      * @param h Height of the region to repaint
      * @see JApplet#repaint
      * @since 1.6
+     *
+     * @deprecated The Applet API is deprecated. See the
+     * <a href="../../java/applet/package-summary.html"> java.applet package
+     * documentation</a> for further information.
      */
-    @SuppressWarnings("deprecation")
+    @Deprecated(since = "9")
     public void addDirtyRegion(Applet applet, int x, int y, int w, int h) {
         addDirtyRegion0(applet, x, y, w, h);
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/TablePrintable.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/TablePrintable.java	Tue Jan 24 00:30:25 2017 +0100
@@ -380,6 +380,12 @@
         // print the current section of the table
         g2d.translate(-clip.x, -clip.y);
         g2d.clip(clip);
+
+        // set a property so that BasicTableUI#paint can know JTable printMode
+        // is FIT_WIDTH since TablePrintable.printMode is not accessible from BasicTableUI
+        if (printMode == JTable.PrintMode.FIT_WIDTH) {
+            table.putClientProperty("Table.printMode", JTable.PrintMode.FIT_WIDTH);
+        }
         table.print(g2d);
 
         // restore the original transform and clip
@@ -407,8 +413,18 @@
         for(int visrow = rMin; visrow < rMax; visrow++) {
             rowHeight += table.getRowHeight(visrow);
         }
-        g2d.drawRect(0, 0, visibleBounds.width, hclip.height + rowHeight);
+        // If PrintMode is FIT_WIDTH, then draw rect for entire column width while
+        // printing irrespective of how many columns are visible in console
+        if (printMode == JTable.PrintMode.FIT_WIDTH) {
+            g2d.drawRect(0, 0, clip.width, hclip.height + rowHeight);
+        } else {
+            g2d.drawRect(0, 0, visibleBounds.width, hclip.height + rowHeight);
+        }
 
+        // clear the property
+        if (printMode == JTable.PrintMode.FIT_WIDTH) {
+            table.putClientProperty("Table.printMode", null);
+        }
         // dispose the graphics copy
         g2d.dispose();
 
@@ -534,5 +550,4 @@
         } while (clip.width + colWidth <= pw);
 
     }
-
 }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1812,12 +1812,12 @@
         }
 
         boolean ltr = table.getComponentOrientation().isLeftToRight();
-
+        Point upperLeft, lowerRight;
         // compute the visible part of table which needs to be painted
         Rectangle visibleBounds = clip.intersection(bounds);
-        Point upperLeft = visibleBounds.getLocation();
-        Point lowerRight = new Point(visibleBounds.x + visibleBounds.width - 1,
-                                     visibleBounds.y + visibleBounds.height - 1);
+        upperLeft = visibleBounds.getLocation();
+        lowerRight = new Point(visibleBounds.x + visibleBounds.width - 1,
+                               visibleBounds.y + visibleBounds.height - 1);
 
         int rMin = table.rowAtPoint(upperLeft);
         int rMax = table.rowAtPoint(lowerRight);
@@ -1834,6 +1834,18 @@
             rMax = table.getRowCount()-1;
         }
 
+        // For FIT_WIDTH, all columns should be printed irrespective of
+        // how many columns are visible. So, we used clip which is already set to
+        // total col width instead of visible region
+        // Since JTable.PrintMode is not accessible
+        // from here, we aet "Table.printMode" in TablePrintable#print and
+        // access from here.
+        Object printMode = table.getClientProperty("Table.printMode");
+        if ((printMode == JTable.PrintMode.FIT_WIDTH)) {
+            upperLeft = clip.getLocation();
+            lowerRight = new Point(clip.x + clip.width - 1,
+                                   clip.y + clip.height - 1);
+        }
         int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight);
         int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft);
         // This should never happen.
@@ -2018,7 +2030,7 @@
             int y = damagedArea.y;
             for (int row = rMin; row <= rMax; row++) {
                 y += table.getRowHeight(row);
-                g.drawLine(damagedArea.x, y - 1, tableWidth - 1, y - 1);
+                SwingUtilities2.drawHLine(g, damagedArea.x, tableWidth - 1, y - 1);
             }
         }
         if (table.getShowVerticalLines()) {
@@ -2030,14 +2042,14 @@
                 for (int column = cMin; column <= cMax; column++) {
                     int w = cm.getColumn(column).getWidth();
                     x += w;
-                    g.drawLine(x - 1, 0, x - 1, tableHeight - 1);
+                    SwingUtilities2.drawVLine(g, x - 1, 0, tableHeight - 1);
                 }
             } else {
                 x = damagedArea.x;
                 for (int column = cMax; column >= cMin; column--) {
                     int w = cm.getColumn(column).getWidth();
                     x += w;
-                    g.drawLine(x - 1, 0, x - 1, tableHeight - 1);
+                    SwingUtilities2.drawVLine(g, x - 1, 0, tableHeight - 1);
                 }
             }
         }
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/PasswordView.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PasswordView.java	Tue Jan 24 00:30:25 2017 +0100
@@ -27,10 +27,7 @@
 import sun.swing.SwingUtilities2;
 import java.awt.*;
 import java.awt.font.FontRenderContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import javax.swing.JPasswordField;
-import static javax.swing.text.PlainView.isFPMethodOverriden;
 
 /**
  * Implements a View suitable for use in JPasswordField
@@ -332,22 +329,6 @@
 
     static char[] ONE = new char[1];
 
-    private final boolean drawEchoCharacterOverridden;
-
-    {
-        final Class<?> CLS = getClass();
-        final Class<?> INT = Integer.TYPE;
-        final Class<?> FP = Float.TYPE;
-        final Class<?> CHAR = Character.TYPE;
-
-        drawEchoCharacterOverridden = AccessController
-                .doPrivileged(new PrivilegedAction<Boolean>() {
-            @Override
-            public Boolean run() {
-                Class<?>[] intTypes = {Graphics.class, INT, INT, CHAR};
-                Class<?>[] fpTypes = {Graphics2D.class, FP, FP, CHAR};
-                return isFPMethodOverriden("drawEchoCharacter", CLS, intTypes, fpTypes);
-            }
-        });
-    }
+    private final boolean drawEchoCharacterOverridden =
+            getFPMethodOverridden(getClass(), "drawEchoCharacter", FPMethodArgs.GNNC);
 }
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java	Tue Jan 24 00:30:25 2017 +0100
@@ -32,6 +32,8 @@
 import java.util.Objects;
 import javax.swing.event.*;
 import java.lang.reflect.Module;
+import java.lang.ref.SoftReference;
+import java.util.HashMap;
 
 /**
  * Implements View interface for a simple multi-line text view
@@ -818,10 +820,45 @@
         return w;
     }
 
-    static boolean isFPMethodOverriden(String method,
-                                Class<?> cls,
-                                Class<?>[] intTypes,
-                                Class<?>[] fpTypes)
+    static boolean getFPMethodOverridden(Class<?> cls, String method,
+                                         FPMethodArgs methodArgs) {
+        HashMap<FPMethodItem, Boolean> map = null;
+        boolean initialized = methodsOverriddenMapRef != null
+                              && (map = methodsOverriddenMapRef.get()) != null;
+
+        if (!initialized) {
+            map = new HashMap<>();
+            methodsOverriddenMapRef = new SoftReference<>(map);
+        }
+
+        FPMethodItem key = new FPMethodItem(cls, method);
+        Boolean isFPMethodOverridden = map.get(key);
+        if (isFPMethodOverridden == null) {
+            isFPMethodOverridden = checkFPMethodOverridden(cls, method, methodArgs);
+            map.put(key, isFPMethodOverridden);
+        }
+        return isFPMethodOverridden;
+    }
+
+    private static boolean checkFPMethodOverridden(final Class<?> className,
+                                                   final String methodName,
+                                                   final FPMethodArgs methodArgs) {
+
+        return AccessController
+                .doPrivileged(new PrivilegedAction<Boolean>() {
+                    @Override
+                    public Boolean run() {
+                        return isFPMethodOverridden(methodName, className,
+                                                    methodArgs.getMethodArguments(false),
+                                                    methodArgs.getMethodArguments(true));
+                    }
+                });
+    }
+
+    private static boolean isFPMethodOverridden(String method,
+                                                Class<?> cls,
+                                                Class<?>[] intTypes,
+                                                Class<?>[] fpTypes)
     {
         Module thisModule = PlainView.class.getModule();
         while (!thisModule.equals(cls.getModule())) {
@@ -840,6 +877,57 @@
         return true;
     }
 
+    enum FPMethodArgs {
+
+        IGNN,
+        IIGNN,
+        GNNII,
+        GNNC;
+
+        public Class<?>[] getMethodArguments(boolean isFPType) {
+            Class<?> N = (isFPType) ? Float.TYPE : Integer.TYPE;
+            Class<?> G = (isFPType) ? Graphics2D.class : Graphics.class;
+            switch (this) {
+                case IGNN:
+                    return new Class<?>[]{Integer.TYPE, G, N, N};
+                case IIGNN:
+                    return new Class<?>[]{Integer.TYPE, Integer.TYPE, G, N, N};
+                case GNNII:
+                    return new Class<?>[]{G, N, N, Integer.TYPE, Integer.TYPE};
+                case GNNC:
+                    return new Class<?>[]{G, N, N, Character.TYPE};
+                default:
+                    throw new RuntimeException("Unknown method arguments!");
+            }
+        }
+    }
+
+     private static class FPMethodItem {
+
+        final Class<?> className;
+        final String methodName;
+
+        public FPMethodItem(Class<?> className, String methodName) {
+            this.className = className;
+            this.methodName = methodName;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj instanceof FPMethodItem) {
+                FPMethodItem that = (FPMethodItem) obj;
+                return this.className.equals(that.className)
+                        && this.methodName.equals(that.methodName);
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            return 31 * methodName.hashCode() + className.hashCode();
+        }
+    }
+
     // --- member variables -----------------------------------------------
 
     /**
@@ -878,46 +966,13 @@
      */
     int firstLineOffset;
 
-    final boolean drawLineOverridden;
-    final boolean drawSelectedTextOverridden;
-    final boolean drawUnselectedTextOverridden;
-    final boolean useFloatingPointAPI;
-
-    {
-        final Class<?> CLS = getClass();
-        final Class<?> INT = Integer.TYPE;
-        final Class<?> FP = Float.TYPE;
-
-        drawLineOverridden = AccessController
-                .doPrivileged(new PrivilegedAction<Boolean>() {
-            @Override
-            public Boolean run() {
-                Class<?>[] intTypes = {INT, Graphics.class, INT, INT};
-                Class<?>[] fpTypes = {INT, Graphics2D.class, FP, FP};
-                return isFPMethodOverriden("drawLine", CLS, intTypes, fpTypes);
-            }
-        });
-
-        drawUnselectedTextOverridden = AccessController
-                .doPrivileged(new PrivilegedAction<Boolean>() {
-            @Override
-            public Boolean run() {
-                Class<?>[] intTypes = {Graphics.class, INT, INT, INT, INT};
-                Class<?>[] fpTypes = {Graphics2D.class, FP, FP, INT, INT};
-                return isFPMethodOverriden("drawUnselectedText", CLS, intTypes, fpTypes);
-            }
-        });
-
-        drawSelectedTextOverridden = AccessController
-                .doPrivileged(new PrivilegedAction<Boolean>() {
-            @Override
-            public Boolean run() {
-                Class<?>[] intTypes = {Graphics.class, INT, INT, INT, INT};
-                Class<?>[] fpTypes = {Graphics2D.class, FP, FP, INT, INT};
-                return isFPMethodOverriden("drawSelectedText", CLS, intTypes, fpTypes);
-            }
-        });
-
-        useFloatingPointAPI = drawUnselectedTextOverridden || drawSelectedTextOverridden;
-    }
+    private static SoftReference<HashMap<FPMethodItem, Boolean>> methodsOverriddenMapRef;
+    final boolean drawLineOverridden =
+            getFPMethodOverridden(getClass(), "drawLine", FPMethodArgs.IGNN);
+    final boolean drawSelectedTextOverridden =
+            getFPMethodOverridden(getClass(), "drawSelectedText", FPMethodArgs.GNNII);
+    final boolean drawUnselectedTextOverridden =
+            getFPMethodOverridden(getClass(), "drawUnselectedText", FPMethodArgs.GNNII);
+    final boolean useFloatingPointAPI =
+            drawUnselectedTextOverridden || drawSelectedTextOverridden;
 }
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Tue Jan 24 00:30:25 2017 +0100
@@ -28,10 +28,9 @@
 import java.awt.font.FontRenderContext;
 import java.awt.geom.Rectangle2D;
 import java.lang.ref.SoftReference;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import javax.swing.event.*;
-import static javax.swing.text.PlainView.isFPMethodOverriden;
+import static javax.swing.text.PlainView.FPMethodArgs.*;
+import static javax.swing.text.PlainView.getFPMethodOverridden;
 
 /**
  * View of plain text (text with only one font and color)
@@ -989,46 +988,12 @@
         SoftReference<int[]> lineCache = null;
     }
 
-    private final boolean drawLineOverridden;
-    private final boolean drawSelectedTextOverridden;
-    private final boolean drawUnselectedTextOverridden;
-    private final boolean useFloatingPointAPI;
-
-    {
-        final Class<?> CLS = getClass();
-        final Class<?> INT = Integer.TYPE;
-        final Class<?> FP = Float.TYPE;
-
-        drawLineOverridden = AccessController
-                .doPrivileged(new PrivilegedAction<Boolean>() {
-            @Override
-            public Boolean run() {
-                Class<?>[] intTypes = {INT, INT, Graphics.class, INT, INT};
-                Class<?>[] fpTypes = {INT, INT, Graphics2D.class, FP, FP};
-                return isFPMethodOverriden("drawLine", CLS, intTypes, fpTypes);
-            }
-        });
-
-        drawUnselectedTextOverridden = AccessController
-                .doPrivileged(new PrivilegedAction<Boolean>() {
-            @Override
-            public Boolean run() {
-                Class<?>[] intTypes = {Graphics.class, INT, INT, INT, INT};
-                Class<?>[] fpTypes = {Graphics2D.class, FP, FP, INT, INT};
-                return isFPMethodOverriden("drawUnselectedText", CLS, intTypes, fpTypes);
-            }
-        });
-
-        drawSelectedTextOverridden = AccessController
-                .doPrivileged(new PrivilegedAction<Boolean>() {
-            @Override
-            public Boolean run() {
-                Class<?>[] intTypes = {Graphics.class, INT, INT, INT, INT};
-                Class<?>[] fpTypes = {Graphics2D.class, FP, FP, INT, INT};
-                return isFPMethodOverriden("drawSelectedText", CLS, intTypes, fpTypes);
-            }
-        });
-
-        useFloatingPointAPI = drawUnselectedTextOverridden || drawSelectedTextOverridden;
-    }
+    private final boolean drawLineOverridden =
+            getFPMethodOverridden(getClass(), "drawLine", IIGNN);
+    private final boolean drawSelectedTextOverridden =
+            getFPMethodOverridden(getClass(), "drawSelectedText", GNNII);
+    private final boolean drawUnselectedTextOverridden =
+            getFPMethodOverridden(getClass(), "drawUnselectedText", GNNII);
+    private final boolean useFloatingPointAPI =
+            drawUnselectedTextOverridden || drawSelectedTextOverridden;
 }
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletEvent.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletEvent.java	Tue Jan 24 00:30:25 2017 +0100
@@ -32,8 +32,13 @@
  * AppletEvent class.
  *
  * @author  Sunita Mani
+ *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
 @SuppressWarnings("serial") // JDK-implementation class
+@Deprecated(since = "9")
 public class AppletEvent extends EventObject {
 
     private Object arg;
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletEventMulticaster.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletEventMulticaster.java	Tue Jan 24 00:30:25 2017 +0100
@@ -36,7 +36,12 @@
  * responsible for dispatching events to them.
  *
  * @author  Sunita Mani
+ *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
+@Deprecated(since = "9")
 public class AppletEventMulticaster implements AppletListener {
 
     private final AppletListener a, b;
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletIOException.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletIOException.java	Tue Jan 24 00:30:25 2017 +0100
@@ -31,10 +31,14 @@
  * An applet IO exception.
  *
  * @author      Koji Uno
+ *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
 @SuppressWarnings("serial") // JDK implementation class
-public
-class AppletIOException extends IOException {
+@Deprecated(since = "9")
+public class AppletIOException extends IOException {
     private String key = null;
     private Object msgobj = null;
 
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletIllegalArgumentException.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletIllegalArgumentException.java	Tue Jan 24 00:30:25 2017 +0100
@@ -29,10 +29,14 @@
  * An applet security exception.
  *
  * @author      Arthur van Hoff
+ *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
 @SuppressWarnings("serial") // JDK implementation class
-public
-class AppletIllegalArgumentException extends IllegalArgumentException {
+@Deprecated(since = "9")
+public class AppletIllegalArgumentException extends IllegalArgumentException {
     private String key = null;
 
     public AppletIllegalArgumentException(String key) {
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletImageRef.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletImageRef.java	Tue Jan 24 00:30:25 2017 +0100
@@ -31,6 +31,7 @@
 import sun.awt.image.URLImageSource;
 import java.net.URL;
 
+@Deprecated(since = "9")
 class AppletImageRef {
     private SoftReference<Image> soft = null;
 
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletListener.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletListener.java	Tue Jan 24 00:30:25 2017 +0100
@@ -32,8 +32,12 @@
  * by objects interested in AppletEvents.
  *
  * @author  Sunita Mani
+ *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
-
+@Deprecated(since = "9")
 public interface AppletListener extends EventListener {
     public void appletStateChanged(AppletEvent e);
 }
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletObjectInputStream.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletObjectInputStream.java	Tue Jan 24 00:30:25 2017 +0100
@@ -34,8 +34,12 @@
 /**
  * This subclass of ObjectInputStream delegates loading of classes to
  * an existing ClassLoader.
+ *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
-
+@Deprecated(since = "9")
 class AppletObjectInputStream extends ObjectInputStream
 {
     private AppletClassLoader loader;
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java	Tue Jan 24 00:30:25 2017 +0100
@@ -52,9 +52,14 @@
  * thread group to call the applet's init(), start(), stop(), and
  * destroy() methods.
  *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
+ *
  * @author      Arthur van Hoff
  */
-@SuppressWarnings({"serial", "deprecation"}) // JDK implementation class
+@SuppressWarnings({"serial"}) // JDK implementation class
+@Deprecated(since = "9")
 public
 abstract class AppletPanel extends Panel implements AppletStub, Runnable {
 
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletProps.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletProps.java	Tue Jan 24 00:30:25 2017 +0100
@@ -36,6 +36,7 @@
 import sun.security.action.*;
 
 @SuppressWarnings("serial") // JDK implementation class
+@Deprecated(since = "9")
 class AppletProps extends Frame {
 
     TextField proxyHost;
@@ -197,6 +198,7 @@
 /* 4066432 */
 /* Dialog class to display property-related errors to user */
 @SuppressWarnings("serial") // JDK implementation class
+@Deprecated(since = "9")
 class AppletPropsErrorDialog extends Dialog {
     @SuppressWarnings("deprecation")
     public AppletPropsErrorDialog(Frame parent, String title, String message,
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -43,6 +43,7 @@
  * A frame to show the applet tag in.
  */
 @SuppressWarnings("serial") // JDK-implementation class
+@Deprecated(since = "9")
 final class TextFrame extends Frame {
 
     /**
@@ -91,6 +92,7 @@
 /**
  * Lets us construct one using unix-style one shot behaviors.
  */
+@Deprecated(since = "9")
 final class StdAppletViewerFactory implements AppletViewerFactory {
 
     @Override
@@ -116,8 +118,13 @@
  * <a href="../../../docs/tooldocs/appletviewertags.html">AppletViewer Tags</a>.
  * (The document named appletviewertags.html in the JDK's docs/tooldocs directory,
  *  once the JDK docs have been installed.)
+ *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
-@SuppressWarnings({"serial", "deprecation"}) // JDK-implementation class
+@SuppressWarnings({"serial"}) // JDK-implementation class
+@Deprecated(since = "9")
 public class AppletViewer extends Frame implements AppletContext, Printable {
 
     /**
@@ -146,7 +153,7 @@
      */
     AppletViewerFactory factory;
 
-
+    @Deprecated(since = "9")
     private final class UserActionListener implements ActionListener {
         @Override
         public void actionPerformed(ActionEvent evt) {
@@ -219,6 +226,7 @@
             }
         };
 
+        @Deprecated(since = "9")
         class AppletEventListener implements AppletListener
         {
             final Frame frame;
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerFactory.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerFactory.java	Tue Jan 24 00:30:25 2017 +0100
@@ -33,8 +33,8 @@
 import java.net.URL;
 import java.awt.MenuBar;
 
-public
-interface AppletViewerFactory {
+@Deprecated(since = "9")
+public interface AppletViewerFactory {
         public AppletViewer createAppletViewer(int x, int y, URL doc,
                                                Hashtable<String, String> atts);
         public MenuBar getBaseMenuBar();
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerPanel.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerPanel.java	Tue Jan 24 00:30:25 2017 +0100
@@ -40,7 +40,12 @@
  * destroy() methods.
  *
  * @author      Arthur van Hoff
+ *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
+@Deprecated(since = "9")
 class AppletViewerPanel extends AppletPanel {
 
     /* Are we debugging? */
--- a/jdk/src/java.desktop/share/classes/sun/applet/Main.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/applet/Main.java	Tue Jan 24 00:30:25 2017 +0100
@@ -39,7 +39,12 @@
 
 /**
  * The main entry point into AppletViewer.
+ *
+ * @deprecated The Applet API is deprecated. See the
+ * <a href="../../java/applet/package-summary.html"> java.applet package
+ * documentation</a> for further information.
  */
+@Deprecated(since = "9")
 public class Main {
     /**
      * The file which contains all of the AppletViewer specific properties.
--- a/jdk/src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java	Tue Jan 24 00:30:25 2017 +0100
@@ -496,10 +496,14 @@
      * Checks if the component is in an EmbeddedFrame. If so,
      * returns the applet found in the hierarchy or null if
      * not found.
-     * @return the parent applet or {@ null}
+     * @return the parent applet or {@code null}
      * @since 1.6
+     *
+     * @deprecated The Applet API is deprecated. See the
+     * <a href="../../java/applet/package-summary.html"> java.applet package
+     * documentation</a> for further information.
      */
-    @SuppressWarnings("deprecation")
+    @Deprecated(since = "9")
     public static Applet getAppletIfAncestorOf(Component comp) {
         Container parent = comp.getParent();
         Applet applet = null;
--- a/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c	Tue Jan 24 00:30:25 2017 +0100
@@ -2419,7 +2419,7 @@
     case sun_awt_image_IntegerComponentRaster_TYPE_INT_8BIT_SAMPLES:
         if (!((rasterP->chanOffsets[0] == 0 || SAFE_TO_ALLOC_2(rasterP->chanOffsets[0], 4)) &&
               SAFE_TO_ALLOC_2(width, 4) &&
-              SAFE_TO_ALLOC_3(height, rasterP->scanlineStride, 4)))
+              SAFE_TO_ALLOC_3(rasterP->scanlineStride, height, 4)))
         {
             return -1;
         }
@@ -2428,7 +2428,7 @@
 
         if (offset < 0 || offset >= dataSize ||
             width > rasterP->scanlineStride ||
-            height * rasterP->scanlineStride * 4 > dataSize - offset)
+            ((width + (height - 1) * rasterP->scanlineStride) * 4) > dataSize - offset)
         {
             // raster data buffer is too short
             return -1;
@@ -2446,7 +2446,7 @@
         return 0;
     case sun_awt_image_IntegerComponentRaster_TYPE_BYTE_SAMPLES:
         if (!(SAFE_TO_ALLOC_2(width, rasterP->numBands) &&
-              SAFE_TO_ALLOC_2(height, rasterP->scanlineStride)))
+              SAFE_TO_ALLOC_2(rasterP->scanlineStride, height)))
         {
             return -1;
         }
@@ -2455,7 +2455,8 @@
 
         if (offset < 0 || offset >= dataSize ||
             width * rasterP->numBands > rasterP->scanlineStride ||
-            height * rasterP->scanlineStride > dataSize - offset)
+            ((width * rasterP->numBands) +
+             (height - 1) * rasterP->scanlineStride) > dataSize - offset)
         {
             // raster data buffer is too short
             return -1;
@@ -2474,7 +2475,7 @@
     case sun_awt_image_IntegerComponentRaster_TYPE_USHORT_SAMPLES:
         if (!((rasterP->chanOffsets[0] == 0 || SAFE_TO_ALLOC_2(rasterP->chanOffsets[0], 2)) &&
               SAFE_TO_ALLOC_3(width, rasterP->numBands, 2) &&
-              SAFE_TO_ALLOC_3(height, rasterP->scanlineStride, 2)))
+              SAFE_TO_ALLOC_3(rasterP->scanlineStride, height, 2)))
         {
               return -1;
         }
@@ -2483,7 +2484,8 @@
 
         if (offset < 0 || offset >= dataSize ||
             width * rasterP->numBands > rasterP->scanlineStride ||
-            height * rasterP->scanlineStride * 2 > dataSize - offset)
+            (((width * rasterP->numBands) +
+             (height - 1) * rasterP->scanlineStride)) * 2 > dataSize - offset)
         {
             // raster data buffer is too short
              return -1;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-blob.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-blob.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -247,7 +247,7 @@
  * @destroy: callback to call when @data is not needed anymore.
  * @replace: whether to replace an existing data with the same key.
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -266,9 +266,9 @@
  * @blob: a blob.
  * @key: key for data to get.
  *
- *
+ * 
  *
- * Return value: (transfer none):
+ * Return value: (transfer none): 
  *
  * Since: 0.9.2
  **/
@@ -284,7 +284,7 @@
  * hb_blob_make_immutable:
  * @blob: a blob.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -301,7 +301,7 @@
  * hb_blob_is_immutable:
  * @blob: a blob.
  *
- *
+ * 
  *
  * Return value: TODO
  *
@@ -318,7 +318,7 @@
  * hb_blob_get_length:
  * @blob: a blob.
  *
- *
+ * 
  *
  * Return value: the length of blob data in bytes.
  *
@@ -335,9 +335,9 @@
  * @blob: a blob.
  * @length: (out):
  *
- *
+ * 
  *
- * Returns: (transfer none) (array length=length):
+ * Returns: (transfer none) (array length=length): 
  *
  * Since: 0.9.2
  **/
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-json.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-json.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -34,397 +34,397 @@
 
 #line 36 "hb-buffer-deserialize-json.hh"
 static const unsigned char _deserialize_json_trans_keys[] = {
-        0u, 0u, 9u, 123u, 9u, 34u, 97u, 103u, 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u,
-        48u, 57u, 9u, 125u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u,
-        9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, 9u, 125u,
-        120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u,
-        9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u,
+        0u, 0u, 9u, 123u, 9u, 34u, 97u, 103u, 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 
+        48u, 57u, 9u, 125u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 
+        9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, 9u, 125u, 
+        120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, 
+        9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 
         65u, 122u, 34u, 122u, 9u, 125u, 9u, 125u, 9u, 93u, 9u, 123u, 0u, 0u, 0
 };
 
 static const char _deserialize_json_key_spans[] = {
-        0, 115, 26, 7, 2, 1, 50, 49,
-        10, 117, 117, 117, 1, 50, 49, 10,
-        117, 117, 1, 1, 50, 49, 117, 117,
-        2, 1, 50, 49, 10, 117, 117, 1,
-        50, 49, 10, 117, 117, 1, 50, 49,
+        0, 115, 26, 7, 2, 1, 50, 49, 
+        10, 117, 117, 117, 1, 50, 49, 10, 
+        117, 117, 1, 1, 50, 49, 117, 117, 
+        2, 1, 50, 49, 10, 117, 117, 1, 
+        50, 49, 10, 117, 117, 1, 50, 49, 
         58, 89, 117, 117, 85, 115, 0
 };
 
 static const short _deserialize_json_index_offsets[] = {
-        0, 0, 116, 143, 151, 154, 156, 207,
-        257, 268, 386, 504, 622, 624, 675, 725,
-        736, 854, 972, 974, 976, 1027, 1077, 1195,
-        1313, 1316, 1318, 1369, 1419, 1430, 1548, 1666,
-        1668, 1719, 1769, 1780, 1898, 2016, 2018, 2069,
+        0, 0, 116, 143, 151, 154, 156, 207, 
+        257, 268, 386, 504, 622, 624, 675, 725, 
+        736, 854, 972, 974, 976, 1027, 1077, 1195, 
+        1313, 1316, 1318, 1369, 1419, 1430, 1548, 1666, 
+        1668, 1719, 1769, 1780, 1898, 2016, 2018, 2069, 
         2119, 2178, 2268, 2386, 2504, 2590, 2706
 };
 
 static const char _deserialize_json_indicies[] = {
-        0, 0, 0, 0, 0, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        0, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 2, 1, 3, 3, 3,
-        3, 3, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 3, 1, 4, 1,
-        5, 1, 6, 7, 1, 1, 8, 1,
-        9, 10, 1, 11, 1, 11, 11, 11,
-        11, 11, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 11, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 12, 1,
-        12, 12, 12, 12, 12, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 12,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 13, 1, 1, 14,
-        15, 15, 15, 15, 15, 15, 15, 15,
-        15, 1, 16, 17, 17, 17, 17, 17,
-        17, 17, 17, 17, 1, 18, 18, 18,
-        18, 18, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 18, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        19, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 20, 1, 21, 21, 21, 21, 21,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 21, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 3, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 22,
-        1, 18, 18, 18, 18, 18, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        18, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 19, 1, 1, 1,
-        17, 17, 17, 17, 17, 17, 17, 17,
-        17, 17, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 20, 1, 23,
-        1, 23, 23, 23, 23, 23, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        23, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 24, 1, 24, 24, 24, 24,
-        24, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 24, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        25, 1, 1, 26, 27, 27, 27, 27,
-        27, 27, 27, 27, 27, 1, 28, 29,
-        29, 29, 29, 29, 29, 29, 29, 29,
-        1, 30, 30, 30, 30, 30, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        30, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 31, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 32, 1, 30,
-        30, 30, 30, 30, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 30, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 31, 1, 1, 1, 29, 29,
-        29, 29, 29, 29, 29, 29, 29, 29,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 32, 1, 33, 1, 34,
-        1, 34, 34, 34, 34, 34, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        34, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 35, 1, 35, 35, 35, 35,
-        35, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 35, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 36, 37, 37, 37, 37,
-        37, 37, 37, 37, 37, 1, 38, 38,
-        38, 38, 38, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 38, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 39, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 40, 1, 38, 38, 38, 38,
-        38, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 38, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 39,
-        1, 1, 1, 41, 41, 41, 41, 41,
-        41, 41, 41, 41, 41, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        40, 1, 42, 43, 1, 44, 1, 44,
-        44, 44, 44, 44, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 44, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        45, 1, 45, 45, 45, 45, 45, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 45, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 46, 1,
-        1, 47, 48, 48, 48, 48, 48, 48,
-        48, 48, 48, 1, 49, 50, 50, 50,
-        50, 50, 50, 50, 50, 50, 1, 51,
-        51, 51, 51, 51, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 51, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 52, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 53, 1, 51, 51, 51,
-        51, 51, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 51, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        52, 1, 1, 1, 50, 50, 50, 50,
-        50, 50, 50, 50, 50, 50, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 53, 1, 54, 1, 54, 54, 54,
-        54, 54, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 54, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 55, 1,
-        55, 55, 55, 55, 55, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 55,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 56, 1, 1, 57,
-        58, 58, 58, 58, 58, 58, 58, 58,
-        58, 1, 59, 60, 60, 60, 60, 60,
-        60, 60, 60, 60, 1, 61, 61, 61,
-        61, 61, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 61, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        62, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 63, 1, 61, 61, 61, 61, 61,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 61, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 62, 1,
-        1, 1, 60, 60, 60, 60, 60, 60,
-        60, 60, 60, 60, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 63,
-        1, 64, 1, 64, 64, 64, 64, 64,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 64, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 65, 1, 65, 65,
-        65, 65, 65, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 65, 1, 66,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 67, 68, 68,
-        68, 68, 68, 68, 68, 68, 68, 1,
-        69, 69, 69, 69, 69, 69, 69, 69,
-        69, 69, 69, 69, 69, 69, 69, 69,
-        69, 69, 69, 69, 69, 69, 69, 69,
-        69, 69, 1, 1, 1, 1, 1, 1,
-        69, 69, 69, 69, 69, 69, 69, 69,
-        69, 69, 69, 69, 69, 69, 69, 69,
-        69, 69, 69, 69, 69, 69, 69, 69,
-        69, 69, 1, 70, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 71, 71,
-        1, 71, 71, 71, 71, 71, 71, 71,
-        71, 71, 71, 1, 1, 1, 1, 1,
-        1, 1, 71, 71, 71, 71, 71, 71,
-        71, 71, 71, 71, 71, 71, 71, 71,
-        71, 71, 71, 71, 71, 71, 71, 71,
-        71, 71, 71, 71, 1, 1, 1, 1,
-        71, 1, 71, 71, 71, 71, 71, 71,
-        71, 71, 71, 71, 71, 71, 71, 71,
-        71, 71, 71, 71, 71, 71, 71, 71,
-        71, 71, 71, 71, 1, 72, 72, 72,
-        72, 72, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 72, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        73, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 74, 1, 72, 72, 72, 72, 72,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 72, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 73, 1,
-        1, 1, 75, 75, 75, 75, 75, 75,
-        75, 75, 75, 75, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 74,
-        1, 76, 76, 76, 76, 76, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        76, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 77, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 78, 1, 0,
-        0, 0, 0, 0, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 0, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
+        0, 0, 0, 0, 0, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        0, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 2, 1, 3, 3, 3, 
+        3, 3, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 3, 1, 4, 1, 
+        5, 1, 6, 7, 1, 1, 8, 1, 
+        9, 10, 1, 11, 1, 11, 11, 11, 
+        11, 11, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 11, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 12, 1, 
+        12, 12, 12, 12, 12, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 12, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 13, 1, 1, 14, 
+        15, 15, 15, 15, 15, 15, 15, 15, 
+        15, 1, 16, 17, 17, 17, 17, 17, 
+        17, 17, 17, 17, 1, 18, 18, 18, 
+        18, 18, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 18, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        19, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 20, 1, 21, 21, 21, 21, 21, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 21, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 3, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 22, 
+        1, 18, 18, 18, 18, 18, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        18, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 19, 1, 1, 1, 
+        17, 17, 17, 17, 17, 17, 17, 17, 
+        17, 17, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 20, 1, 23, 
+        1, 23, 23, 23, 23, 23, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        23, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 24, 1, 24, 24, 24, 24, 
+        24, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 24, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        25, 1, 1, 26, 27, 27, 27, 27, 
+        27, 27, 27, 27, 27, 1, 28, 29, 
+        29, 29, 29, 29, 29, 29, 29, 29, 
+        1, 30, 30, 30, 30, 30, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        30, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 31, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 32, 1, 30, 
+        30, 30, 30, 30, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 30, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 31, 1, 1, 1, 29, 29, 
+        29, 29, 29, 29, 29, 29, 29, 29, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 32, 1, 33, 1, 34, 
+        1, 34, 34, 34, 34, 34, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        34, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 35, 1, 35, 35, 35, 35, 
+        35, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 35, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 36, 37, 37, 37, 37, 
+        37, 37, 37, 37, 37, 1, 38, 38, 
+        38, 38, 38, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 38, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 39, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 40, 1, 38, 38, 38, 38, 
+        38, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 38, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 39, 
+        1, 1, 1, 41, 41, 41, 41, 41, 
+        41, 41, 41, 41, 41, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        40, 1, 42, 43, 1, 44, 1, 44, 
+        44, 44, 44, 44, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 44, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        45, 1, 45, 45, 45, 45, 45, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 45, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 46, 1, 
+        1, 47, 48, 48, 48, 48, 48, 48, 
+        48, 48, 48, 1, 49, 50, 50, 50, 
+        50, 50, 50, 50, 50, 50, 1, 51, 
+        51, 51, 51, 51, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 51, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 52, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 53, 1, 51, 51, 51, 
+        51, 51, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 51, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        52, 1, 1, 1, 50, 50, 50, 50, 
+        50, 50, 50, 50, 50, 50, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 53, 1, 54, 1, 54, 54, 54, 
+        54, 54, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 54, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 55, 1, 
+        55, 55, 55, 55, 55, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 55, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 56, 1, 1, 57, 
+        58, 58, 58, 58, 58, 58, 58, 58, 
+        58, 1, 59, 60, 60, 60, 60, 60, 
+        60, 60, 60, 60, 1, 61, 61, 61, 
+        61, 61, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 61, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        62, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 63, 1, 61, 61, 61, 61, 61, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 61, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 62, 1, 
+        1, 1, 60, 60, 60, 60, 60, 60, 
+        60, 60, 60, 60, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 63, 
+        1, 64, 1, 64, 64, 64, 64, 64, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 64, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 65, 1, 65, 65, 
+        65, 65, 65, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 65, 1, 66, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 67, 68, 68, 
+        68, 68, 68, 68, 68, 68, 68, 1, 
+        69, 69, 69, 69, 69, 69, 69, 69, 
+        69, 69, 69, 69, 69, 69, 69, 69, 
+        69, 69, 69, 69, 69, 69, 69, 69, 
+        69, 69, 1, 1, 1, 1, 1, 1, 
+        69, 69, 69, 69, 69, 69, 69, 69, 
+        69, 69, 69, 69, 69, 69, 69, 69, 
+        69, 69, 69, 69, 69, 69, 69, 69, 
+        69, 69, 1, 70, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 71, 71, 
+        1, 71, 71, 71, 71, 71, 71, 71, 
+        71, 71, 71, 1, 1, 1, 1, 1, 
+        1, 1, 71, 71, 71, 71, 71, 71, 
+        71, 71, 71, 71, 71, 71, 71, 71, 
+        71, 71, 71, 71, 71, 71, 71, 71, 
+        71, 71, 71, 71, 1, 1, 1, 1, 
+        71, 1, 71, 71, 71, 71, 71, 71, 
+        71, 71, 71, 71, 71, 71, 71, 71, 
+        71, 71, 71, 71, 71, 71, 71, 71, 
+        71, 71, 71, 71, 1, 72, 72, 72, 
+        72, 72, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 72, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        73, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 74, 1, 72, 72, 72, 72, 72, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 72, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 73, 1, 
+        1, 1, 75, 75, 75, 75, 75, 75, 
+        75, 75, 75, 75, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 74, 
+        1, 76, 76, 76, 76, 76, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        76, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 77, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 78, 1, 0, 
+        0, 0, 0, 0, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 0, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
         1, 2, 1, 1, 0
 };
 
 static const char _deserialize_json_trans_targs[] = {
-        1, 0, 2, 2, 3, 4, 18, 24,
-        37, 5, 12, 6, 7, 8, 9, 11,
-        9, 11, 10, 2, 44, 10, 44, 13,
-        14, 15, 16, 17, 16, 17, 10, 2,
-        44, 19, 20, 21, 22, 23, 10, 2,
-        44, 23, 25, 31, 26, 27, 28, 29,
-        30, 29, 30, 10, 2, 44, 32, 33,
-        34, 35, 36, 35, 36, 10, 2, 44,
-        38, 39, 40, 42, 43, 41, 10, 41,
+        1, 0, 2, 2, 3, 4, 18, 24, 
+        37, 5, 12, 6, 7, 8, 9, 11, 
+        9, 11, 10, 2, 44, 10, 44, 13, 
+        14, 15, 16, 17, 16, 17, 10, 2, 
+        44, 19, 20, 21, 22, 23, 10, 2, 
+        44, 23, 25, 31, 26, 27, 28, 29, 
+        30, 29, 30, 10, 2, 44, 32, 33, 
+        34, 35, 36, 35, 36, 10, 2, 44, 
+        38, 39, 40, 42, 43, 41, 10, 41, 
         10, 2, 44, 43, 44, 45, 46
 };
 
 static const char _deserialize_json_trans_actions[] = {
-        0, 0, 1, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 2, 2, 2,
-        0, 0, 3, 3, 4, 0, 5, 0,
-        0, 2, 2, 2, 0, 0, 6, 6,
-        7, 0, 0, 0, 2, 2, 8, 8,
-        9, 0, 0, 0, 0, 0, 2, 2,
-        2, 0, 0, 10, 10, 11, 0, 0,
-        2, 2, 2, 0, 0, 12, 12, 13,
-        0, 0, 0, 2, 2, 2, 14, 0,
+        0, 0, 1, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 2, 2, 2, 
+        0, 0, 3, 3, 4, 0, 5, 0, 
+        0, 2, 2, 2, 0, 0, 6, 6, 
+        7, 0, 0, 0, 2, 2, 8, 8, 
+        9, 0, 0, 0, 0, 0, 2, 2, 
+        2, 0, 0, 10, 10, 11, 0, 0, 
+        2, 2, 2, 0, 0, 12, 12, 13, 
+        0, 0, 0, 2, 2, 2, 14, 0, 
         15, 15, 16, 0, 0, 0, 0
 };
 
@@ -461,7 +461,7 @@
   int cs;
   hb_glyph_info_t info = {0};
   hb_glyph_position_t pos = {0};
-
+  
 #line 466 "hb-buffer-deserialize-json.hh"
         {
         cs = deserialize_json_start;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-text.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-text.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -34,274 +34,274 @@
 
 #line 36 "hb-buffer-deserialize-text.hh"
 static const unsigned char _deserialize_text_trans_keys[] = {
-        0u, 0u, 9u, 122u, 45u, 57u, 48u, 57u, 45u, 57u, 48u, 57u, 48u, 57u, 45u, 57u,
-        48u, 57u, 44u, 44u, 45u, 57u, 48u, 57u, 44u, 57u, 9u, 124u, 9u, 124u, 0u, 0u,
-        9u, 122u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u,
+        0u, 0u, 9u, 122u, 45u, 57u, 48u, 57u, 45u, 57u, 48u, 57u, 48u, 57u, 45u, 57u, 
+        48u, 57u, 44u, 44u, 45u, 57u, 48u, 57u, 44u, 57u, 9u, 124u, 9u, 124u, 0u, 0u, 
+        9u, 122u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 
         9u, 124u, 9u, 124u, 9u, 124u, 0
 };
 
 static const char _deserialize_text_key_spans[] = {
-        0, 114, 13, 10, 13, 10, 10, 13,
-        10, 1, 13, 10, 14, 116, 116, 0,
-        114, 116, 116, 116, 116, 116, 116, 116,
+        0, 114, 13, 10, 13, 10, 10, 13, 
+        10, 1, 13, 10, 14, 116, 116, 0, 
+        114, 116, 116, 116, 116, 116, 116, 116, 
         116, 116, 116
 };
 
 static const short _deserialize_text_index_offsets[] = {
-        0, 0, 115, 129, 140, 154, 165, 176,
-        190, 201, 203, 217, 228, 243, 360, 477,
-        478, 593, 710, 827, 944, 1061, 1178, 1295,
+        0, 0, 115, 129, 140, 154, 165, 176, 
+        190, 201, 203, 217, 228, 243, 360, 477, 
+        478, 593, 710, 827, 944, 1061, 1178, 1295, 
         1412, 1529, 1646
 };
 
 static const char _deserialize_text_indicies[] = {
-        0, 0, 0, 0, 0, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        0, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        2, 3, 3, 3, 3, 3, 3, 3,
-        3, 3, 1, 1, 1, 1, 1, 1,
-        1, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 1, 1, 1, 1, 1,
-        1, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 1, 5, 1, 1, 6,
-        7, 7, 7, 7, 7, 7, 7, 7,
-        7, 1, 8, 9, 9, 9, 9, 9,
-        9, 9, 9, 9, 1, 10, 1, 1,
-        11, 12, 12, 12, 12, 12, 12, 12,
-        12, 12, 1, 13, 14, 14, 14, 14,
-        14, 14, 14, 14, 14, 1, 15, 16,
-        16, 16, 16, 16, 16, 16, 16, 16,
-        1, 17, 1, 1, 18, 19, 19, 19,
-        19, 19, 19, 19, 19, 19, 1, 20,
-        21, 21, 21, 21, 21, 21, 21, 21,
-        21, 1, 22, 1, 23, 1, 1, 24,
-        25, 25, 25, 25, 25, 25, 25, 25,
-        25, 1, 26, 27, 27, 27, 27, 27,
-        27, 27, 27, 27, 1, 22, 1, 1,
-        1, 21, 21, 21, 21, 21, 21, 21,
-        21, 21, 21, 1, 28, 28, 28, 28,
-        28, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 28, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 29, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        30, 1, 1, 31, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        32, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 33,
-        1, 34, 34, 34, 34, 34, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        34, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 35, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 36, 1, 1, 0,
-        0, 0, 0, 0, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 0, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 2, 3,
-        3, 3, 3, 3, 3, 3, 3, 3,
-        1, 1, 1, 1, 1, 1, 1, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 1, 1, 1, 1, 1, 1, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 4, 4, 4, 4, 4, 4, 4,
-        4, 1, 28, 28, 28, 28, 28, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 28, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 29, 1, 1, 1,
-        1, 37, 37, 37, 37, 37, 37, 37,
-        37, 37, 37, 1, 1, 1, 30, 1,
-        1, 31, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 32, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 33, 1, 38,
-        38, 38, 38, 38, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 38, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 39, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 40, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 41, 1, 42, 42, 42, 42,
-        42, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 42, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        43, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 44,
-        1, 42, 42, 42, 42, 42, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        42, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        14, 14, 14, 14, 14, 14, 14, 14,
-        14, 14, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 43, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 44, 1, 38, 38,
-        38, 38, 38, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 38, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 39, 1, 1, 1, 9, 9, 9,
-        9, 9, 9, 9, 9, 9, 9, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 40, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 41, 1, 45, 45, 45, 45, 45,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 45, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 46, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 47, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 48,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 49, 1,
-        50, 50, 50, 50, 50, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 50,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 51, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 52, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 53, 1, 50, 50, 50,
-        50, 50, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 50, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 51,
-        1, 1, 1, 1, 27, 27, 27, 27,
-        27, 27, 27, 27, 27, 27, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 52, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        53, 1, 45, 45, 45, 45, 45, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 45, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 46, 1, 1, 1,
-        1, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 1, 1, 1, 1, 1,
-        1, 47, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 48, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 49, 1, 28,
-        28, 28, 28, 28, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 28, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 29, 1, 55, 55, 1, 55, 55,
-        55, 55, 55, 55, 55, 55, 55, 55,
-        1, 1, 1, 30, 1, 1, 31, 55,
-        55, 55, 55, 55, 55, 55, 55, 55,
-        55, 55, 55, 55, 55, 55, 55, 55,
-        55, 55, 55, 55, 55, 55, 55, 55,
-        55, 1, 1, 32, 1, 55, 1, 55,
-        55, 55, 55, 55, 55, 55, 55, 55,
-        55, 55, 55, 55, 55, 55, 55, 55,
-        55, 55, 55, 55, 55, 55, 55, 55,
+        0, 0, 0, 0, 0, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        0, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        2, 3, 3, 3, 3, 3, 3, 3, 
+        3, 3, 1, 1, 1, 1, 1, 1, 
+        1, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 1, 1, 1, 1, 1, 
+        1, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 1, 5, 1, 1, 6, 
+        7, 7, 7, 7, 7, 7, 7, 7, 
+        7, 1, 8, 9, 9, 9, 9, 9, 
+        9, 9, 9, 9, 1, 10, 1, 1, 
+        11, 12, 12, 12, 12, 12, 12, 12, 
+        12, 12, 1, 13, 14, 14, 14, 14, 
+        14, 14, 14, 14, 14, 1, 15, 16, 
+        16, 16, 16, 16, 16, 16, 16, 16, 
+        1, 17, 1, 1, 18, 19, 19, 19, 
+        19, 19, 19, 19, 19, 19, 1, 20, 
+        21, 21, 21, 21, 21, 21, 21, 21, 
+        21, 1, 22, 1, 23, 1, 1, 24, 
+        25, 25, 25, 25, 25, 25, 25, 25, 
+        25, 1, 26, 27, 27, 27, 27, 27, 
+        27, 27, 27, 27, 1, 22, 1, 1, 
+        1, 21, 21, 21, 21, 21, 21, 21, 
+        21, 21, 21, 1, 28, 28, 28, 28, 
+        28, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 28, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 29, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        30, 1, 1, 31, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        32, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 33, 
+        1, 34, 34, 34, 34, 34, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        34, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 35, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 36, 1, 1, 0, 
+        0, 0, 0, 0, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 0, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 2, 3, 
+        3, 3, 3, 3, 3, 3, 3, 3, 
+        1, 1, 1, 1, 1, 1, 1, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 1, 1, 1, 1, 1, 1, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 4, 4, 4, 4, 4, 4, 4, 
+        4, 1, 28, 28, 28, 28, 28, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 28, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 29, 1, 1, 1, 
+        1, 37, 37, 37, 37, 37, 37, 37, 
+        37, 37, 37, 1, 1, 1, 30, 1, 
+        1, 31, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 32, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 33, 1, 38, 
+        38, 38, 38, 38, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 38, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 39, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 40, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 41, 1, 42, 42, 42, 42, 
+        42, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 42, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        43, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 44, 
+        1, 42, 42, 42, 42, 42, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        42, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        14, 14, 14, 14, 14, 14, 14, 14, 
+        14, 14, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 43, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 44, 1, 38, 38, 
+        38, 38, 38, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 38, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 39, 1, 1, 1, 9, 9, 9, 
+        9, 9, 9, 9, 9, 9, 9, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 40, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 41, 1, 45, 45, 45, 45, 45, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 45, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 46, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 47, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 48, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 49, 1, 
+        50, 50, 50, 50, 50, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 50, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 51, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 52, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 53, 1, 50, 50, 50, 
+        50, 50, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 50, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 51, 
+        1, 1, 1, 1, 27, 27, 27, 27, 
+        27, 27, 27, 27, 27, 27, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 52, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        53, 1, 45, 45, 45, 45, 45, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 45, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 46, 1, 1, 1, 
+        1, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 1, 1, 1, 1, 1, 
+        1, 47, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 48, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 49, 1, 28, 
+        28, 28, 28, 28, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 28, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 29, 1, 55, 55, 1, 55, 55, 
+        55, 55, 55, 55, 55, 55, 55, 55, 
+        1, 1, 1, 30, 1, 1, 31, 55, 
+        55, 55, 55, 55, 55, 55, 55, 55, 
+        55, 55, 55, 55, 55, 55, 55, 55, 
+        55, 55, 55, 55, 55, 55, 55, 55, 
+        55, 1, 1, 32, 1, 55, 1, 55, 
+        55, 55, 55, 55, 55, 55, 55, 55, 
+        55, 55, 55, 55, 55, 55, 55, 55, 
+        55, 55, 55, 55, 55, 55, 55, 55, 
         55, 1, 33, 1, 0
 };
 
 static const char _deserialize_text_trans_targs[] = {
-        1, 0, 13, 17, 26, 3, 18, 21,
-        18, 21, 5, 19, 20, 19, 20, 22,
-        25, 8, 9, 12, 9, 12, 10, 11,
-        23, 24, 23, 24, 14, 2, 6, 7,
-        15, 16, 14, 15, 16, 17, 14, 4,
-        15, 16, 14, 15, 16, 14, 2, 7,
+        1, 0, 13, 17, 26, 3, 18, 21, 
+        18, 21, 5, 19, 20, 19, 20, 22, 
+        25, 8, 9, 12, 9, 12, 10, 11, 
+        23, 24, 23, 24, 14, 2, 6, 7, 
+        15, 16, 14, 15, 16, 17, 14, 4, 
+        15, 16, 14, 15, 16, 14, 2, 7, 
         15, 16, 14, 2, 15, 16, 25, 26
 };
 
 static const char _deserialize_text_trans_actions[] = {
-        0, 0, 1, 1, 1, 2, 2, 2,
-        0, 0, 2, 2, 2, 0, 0, 2,
-        2, 2, 2, 2, 0, 0, 3, 2,
-        2, 2, 0, 0, 4, 5, 5, 5,
-        4, 4, 0, 0, 0, 0, 6, 7,
-        6, 6, 8, 8, 8, 9, 10, 10,
+        0, 0, 1, 1, 1, 2, 2, 2, 
+        0, 0, 2, 2, 2, 0, 0, 2, 
+        2, 2, 2, 2, 0, 0, 3, 2, 
+        2, 2, 0, 0, 4, 5, 5, 5, 
+        4, 4, 0, 0, 0, 0, 6, 7, 
+        6, 6, 8, 8, 8, 9, 10, 10, 
         9, 9, 11, 12, 11, 11, 0, 0
 };
 
 static const char _deserialize_text_eof_actions[] = {
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 4, 0, 0,
-        0, 4, 6, 8, 8, 6, 9, 11,
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 4, 0, 0, 
+        0, 4, 6, 8, 8, 6, 9, 11, 
         11, 9, 4
 };
 
@@ -338,7 +338,7 @@
   int cs;
   hb_glyph_info_t info = {0};
   hb_glyph_position_t pos = {0};
-
+  
 #line 343 "hb-buffer-deserialize-text.hh"
         {
         cs = deserialize_text_start;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -134,7 +134,7 @@
 #ifndef HB_NDEBUG
     unsigned int end = start + count;
     assert (end <= 8);
-    unsigned int bits = (1<<end) - (1<<start);
+    unsigned int bits = (1u<<end) - (1u<<start);
     assert (0 == (allocated_var_bits & bits));
     allocated_var_bits |= bits;
 #endif
@@ -144,7 +144,7 @@
 #ifndef HB_NDEBUG
     unsigned int end = start + count;
     assert (end <= 8);
-    unsigned int bits = (1<<end) - (1<<start);
+    unsigned int bits = (1u<<end) - (1u<<start);
     assert (bits == (allocated_var_bits & bits));
     allocated_var_bits &= ~bits;
 #endif
@@ -154,7 +154,7 @@
 #ifndef HB_NDEBUG
     unsigned int end = start + count;
     assert (end <= 8);
-    unsigned int bits = (1<<end) - (1<<start);
+    unsigned int bits = (1u<<end) - (1u<<start);
     assert (bits == (allocated_var_bits & bits));
 #endif
   }
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-serialize.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-serialize.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -58,7 +58,7 @@
  * @str is a valid buffer serialization format, use
  * hb_buffer_serialize_list_formats() to get the list of supported formats.
  *
- * Return value:
+ * Return value: 
  * The parsed #hb_buffer_serialize_format_t.
  *
  * Since: 0.9.7
@@ -289,7 +289,7 @@
  * ## json
  * TODO.
  *
- * Return value:
+ * Return value: 
  * The number of serialized items.
  *
  * Since: 0.9.7
@@ -393,14 +393,14 @@
  * hb_buffer_deserialize_glyphs:
  * @buffer: an #hb_buffer_t buffer.
  * @buf: (array length=buf_len):
- * @buf_len:
+ * @buf_len: 
  * @end_ptr: (out):
- * @font:
- * @format:
+ * @font: 
+ * @format: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.7
  **/
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -703,7 +703,7 @@
 /**
  * hb_buffer_get_empty:
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -780,14 +780,14 @@
 /**
  * hb_buffer_set_user_data: (skip)
  * @buffer: an #hb_buffer_t.
- * @key:
- * @data:
- * @destroy:
- * @replace:
+ * @key: 
+ * @data: 
+ * @destroy: 
+ * @replace: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -804,11 +804,11 @@
 /**
  * hb_buffer_get_user_data: (skip)
  * @buffer: an #hb_buffer_t.
- * @key:
- *
+ * @key: 
  *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -858,9 +858,9 @@
 /**
  * hb_buffer_set_unicode_funcs:
  * @buffer: an #hb_buffer_t.
- * @unicode_funcs:
+ * @unicode_funcs: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -884,9 +884,9 @@
  * hb_buffer_get_unicode_funcs:
  * @buffer: an #hb_buffer_t.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -1090,7 +1090,7 @@
  *
  * See hb_buffer_set_flags().
  *
- * Return value:
+ * Return value: 
  * The @buffer flags.
  *
  * Since: 0.9.7
@@ -1104,9 +1104,9 @@
 /**
  * hb_buffer_set_cluster_level:
  * @buffer: an #hb_buffer_t.
- * @cluster_level:
+ * @cluster_level: 
  *
- *
+ * 
  *
  * Since: 0.9.42
  **/
@@ -1124,9 +1124,9 @@
  * hb_buffer_get_cluster_level:
  * @buffer: an #hb_buffer_t.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.42
  **/
@@ -1165,7 +1165,7 @@
  *
  * See hb_buffer_set_replacement_codepoint().
  *
- * Return value:
+ * Return value: 
  * The @buffer replacement #hb_codepoint_t.
  *
  * Since: 0.9.31
@@ -1276,7 +1276,7 @@
  * Similar to hb_buffer_pre_allocate(), but clears any new items added at the
  * end.
  *
- * Return value:
+ * Return value: 
  * %true if @buffer memory allocation succeeded, %false otherwise.
  *
  * Since: 0.9.2
@@ -1786,7 +1786,7 @@
  * @user_data:
  * @destroy:
  *
- *
+ * 
  *
  * Since: 1.1.3
  **/
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-cache-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-cache-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -45,11 +45,11 @@
 
   inline bool get (unsigned int key, unsigned int *value)
   {
-    unsigned int k = key & ((1<<cache_bits)-1);
+    unsigned int k = key & ((1u<<cache_bits)-1);
     unsigned int v = values[k];
     if ((v >> value_bits) != (key >> cache_bits))
       return false;
-    *value = v & ((1<<value_bits)-1);
+    *value = v & ((1u<<value_bits)-1);
     return true;
   }
 
@@ -57,14 +57,14 @@
   {
     if (unlikely ((key >> key_bits) || (value >> value_bits)))
       return false; /* Overflows */
-    unsigned int k = key & ((1<<cache_bits)-1);
+    unsigned int k = key & ((1u<<cache_bits)-1);
     unsigned int v = ((key>>cache_bits)<<value_bits) | value;
     values[k] = v;
     return true;
   }
 
   private:
-  unsigned int values[1<<cache_bits];
+  unsigned int values[1u<<cache_bits];
 };
 
 typedef hb_cache_t<21, 16, 8> hb_cmap_cache_t;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-common.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-common.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -57,12 +57,12 @@
 
 /**
  * hb_tag_from_string:
- * @str: (array length=len) (element-type uint8_t):
- * @len:
+ * @str: (array length=len) (element-type uint8_t): 
+ * @len: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -87,10 +87,10 @@
 
 /**
  * hb_tag_to_string:
- * @tag:
- * @buf: (out caller-allocates) (array fixed-size=4) (element-type uint8_t):
+ * @tag: 
+ * @buf: (out caller-allocates) (array fixed-size=4) (element-type uint8_t): 
  *
- *
+ * 
  *
  * Since: 0.9.5
  **/
@@ -115,12 +115,12 @@
 
 /**
  * hb_direction_from_string:
- * @str: (array length=len) (element-type uint8_t):
- * @len:
+ * @str: (array length=len) (element-type uint8_t): 
+ * @len: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -143,11 +143,11 @@
 
 /**
  * hb_direction_to_string:
- * @direction:
- *
+ * @direction: 
  *
+ * 
  *
- * Return value: (transfer none):
+ * Return value: (transfer none): 
  *
  * Since: 0.9.2
  **/
@@ -337,7 +337,7 @@
 /**
  * hb_language_get_default:
  *
- *
+ * 
  *
  * Return value: (transfer none):
  *
@@ -366,7 +366,7 @@
  *
  * Converts an ISO 15924 script tag to a corresponding #hb_script_t.
  *
- * Return value:
+ * Return value: 
  * An #hb_script_t corresponding to the ISO 15924 tag.
  *
  * Since: 0.9.2
@@ -415,7 +415,7 @@
  * corresponding #hb_script_t. Shorthand for hb_tag_from_string() then
  * hb_script_from_iso15924_tag().
  *
- * Return value:
+ * Return value: 
  * An #hb_script_t corresponding to the ISO 15924 tag.
  *
  * Since: 0.9.2
@@ -445,11 +445,11 @@
 
 /**
  * hb_script_get_horizontal_direction:
- * @script:
- *
+ * @script: 
  *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -588,13 +588,13 @@
 
 /**
  * hb_version_atleast:
- * @major:
- * @minor:
- * @micro:
+ * @major: 
+ * @minor: 
+ * @micro: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.30
  **/
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-coretext.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-coretext.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -145,6 +145,22 @@
     DEBUG_MSG (CORETEXT, cg_font, "Font CTFontCreateWithGraphicsFont() failed");
     return NULL;
   }
+
+  /* crbug.com/576941 and crbug.com/625902 and the investigation in the latter
+   * bug indicate that the cascade list reconfiguration occasionally causes
+   * crashes in CoreText on OS X 10.9, thus let's skip this step on older
+   * operating system versions. Except for the emoji font, where _not_
+   * reconfiguring the cascade list causes CoreText crashes. For details, see
+   * crbug.com/549610 */
+  // 0x00070000 stands for "kCTVersionNumber10_10", see CoreText.h
+  if (&CTGetCoreTextVersion != NULL && CTGetCoreTextVersion() < 0x00070000) {
+    CFStringRef fontName = CTFontCopyPostScriptName (ct_font);
+    bool isEmojiFont = CFStringCompare (fontName, CFSTR("AppleColorEmoji"), 0) == kCFCompareEqualTo;
+    CFRelease (fontName);
+    if (!isEmojiFont)
+      return ct_font;
+  }
+
   CFURLRef original_url = (CFURLRef)CTFontCopyAttribute(ct_font, kCTFontURLAttribute);
 
   /* Create font copy with cascade list that has LastResort first; this speeds up CoreText
@@ -272,7 +288,9 @@
 hb_coretext_shaper_shape_plan_data_t *
 _hb_coretext_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan HB_UNUSED,
                                              const hb_feature_t *user_features HB_UNUSED,
-                                             unsigned int        num_user_features HB_UNUSED)
+                                             unsigned int        num_user_features HB_UNUSED,
+                                             const int          *coords HB_UNUSED,
+                                             unsigned int        num_coords HB_UNUSED)
 {
   return (hb_coretext_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
 }
@@ -717,7 +735,7 @@
       pchars[chars_len++] = 0xFFFDu;
     else {
       pchars[chars_len++] = 0xD800u + ((c - 0x10000u) >> 10);
-      pchars[chars_len++] = 0xDC00u + ((c - 0x10000u) & ((1 << 10) - 1));
+      pchars[chars_len++] = 0xDC00u + ((c - 0x10000u) & ((1u << 10) - 1));
     }
   }
 
@@ -1264,7 +1282,9 @@
 hb_coretext_aat_shaper_shape_plan_data_t *
 _hb_coretext_aat_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan HB_UNUSED,
                                              const hb_feature_t *user_features HB_UNUSED,
-                                             unsigned int        num_user_features HB_UNUSED)
+                                             unsigned int        num_user_features HB_UNUSED,
+                                             const int          *coords HB_UNUSED,
+                                             unsigned int        num_coords HB_UNUSED)
 {
   return (hb_coretext_aat_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
 }
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-face.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-face.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -35,8 +35,6 @@
 #include "hb-ot-head-table.hh"
 #include "hb-ot-maxp-table.hh"
 
-#include "hb-cache-private.hh"
-
 #include <string.h>
 
 
@@ -70,10 +68,10 @@
 /**
  * hb_face_create_for_tables:
  * @reference_table_func: (closure user_data) (destroy destroy) (scope notified):
- * @user_data:
- * @destroy:
+ * @user_data: 
+ * @destroy: 
  *
- *
+ * 
  *
  * Return value: (transfer full)
  *
@@ -150,10 +148,10 @@
 
 /**
  * hb_face_create: (Xconstructor)
- * @blob:
- * @index:
+ * @blob: 
+ * @index: 
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -185,7 +183,7 @@
 /**
  * hb_face_get_empty:
  *
- *
+ * 
  *
  * Return value: (transfer full)
  *
@@ -202,9 +200,9 @@
  * hb_face_reference: (skip)
  * @face: a face.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -218,7 +216,7 @@
  * hb_face_destroy: (skip)
  * @face: a face.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -248,14 +246,14 @@
 /**
  * hb_face_set_user_data: (skip)
  * @face: a face.
- * @key:
- * @data:
- * @destroy:
- * @replace:
+ * @key: 
+ * @data: 
+ * @destroy: 
+ * @replace: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -272,9 +270,9 @@
 /**
  * hb_face_get_user_data: (skip)
  * @face: a face.
- * @key:
+ * @key: 
  *
- *
+ * 
  *
  * Return value: (transfer none):
  *
@@ -291,7 +289,7 @@
  * hb_face_make_immutable:
  * @face: a face.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -308,9 +306,9 @@
  * hb_face_is_immutable:
  * @face: a face.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -324,9 +322,9 @@
 /**
  * hb_face_reference_table:
  * @face: a face.
- * @tag:
+ * @tag: 
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -343,7 +341,7 @@
  * hb_face_reference_blob:
  * @face: a face.
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -358,9 +356,9 @@
 /**
  * hb_face_set_index:
  * @face: a face.
- * @index:
+ * @index: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -378,9 +376,9 @@
  * hb_face_get_index:
  * @face: a face.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -393,9 +391,9 @@
 /**
  * hb_face_set_upem:
  * @face: a face.
- * @upem:
+ * @upem: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -413,9 +411,9 @@
  * hb_face_get_upem:
  * @face: a face.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -437,9 +435,9 @@
 /**
  * hb_face_set_glyph_count:
  * @face: a face.
- * @glyph_count:
+ * @glyph_count: 
  *
- *
+ * 
  *
  * Since: 0.9.7
  **/
@@ -457,9 +455,9 @@
  * hb_face_get_glyph_count:
  * @face: a face.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.7
  **/
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-fallback-shape.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-fallback-shape.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -73,7 +73,9 @@
 hb_fallback_shaper_shape_plan_data_t *
 _hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan HB_UNUSED,
                                             const hb_feature_t *user_features HB_UNUSED,
-                                            unsigned int        num_user_features HB_UNUSED)
+                                            unsigned int        num_user_features HB_UNUSED,
+                                            const int          *coords HB_UNUSED,
+                                            unsigned int        num_coords HB_UNUSED)
 {
   return (hb_fallback_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
 }
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -108,6 +108,10 @@
   unsigned int x_ppem;
   unsigned int y_ppem;
 
+  /* Font variation coordinates. */
+  unsigned int num_coords;
+  int *coords;
+
   hb_font_funcs_t   *klass;
   void              *user_data;
   hb_destroy_func_t  destroy;
@@ -116,8 +120,14 @@
 
 
   /* Convert from font-space to user-space */
-  inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, this->x_scale); }
-  inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, this->y_scale); }
+  inline int dir_scale (hb_direction_t direction)
+  { return HB_DIRECTION_IS_VERTICAL(direction) ? y_scale : x_scale; }
+  inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, x_scale); }
+  inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, y_scale); }
+  inline hb_position_t em_scalef_x (float v) { return em_scalef (v, this->x_scale); }
+  inline hb_position_t em_scalef_y (float v) { return em_scalef (v, this->y_scale); }
+  inline hb_position_t em_scale_dir (int16_t v, hb_direction_t direction)
+  { return em_scale (v, dir_scale (direction)); }
 
   /* Convert from parent-font user-space to our user-space */
   inline hb_position_t parent_scale_x_distance (hb_position_t v) {
@@ -292,24 +302,32 @@
 
   /* A bit higher-level, and with fallback */
 
+  inline void get_h_extents_with_fallback (hb_font_extents_t *extents)
+  {
+    if (!get_font_h_extents (extents))
+    {
+      extents->ascender = y_scale * .8;
+      extents->descender = extents->ascender - y_scale;
+      extents->line_gap = 0;
+    }
+  }
+  inline void get_v_extents_with_fallback (hb_font_extents_t *extents)
+  {
+    if (!get_font_v_extents (extents))
+    {
+      extents->ascender = x_scale / 2;
+      extents->descender = extents->ascender - x_scale;
+      extents->line_gap = 0;
+    }
+  }
+
   inline void get_extents_for_direction (hb_direction_t direction,
                                          hb_font_extents_t *extents)
   {
-    if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
-      if (!get_font_h_extents (extents))
-      {
-        extents->ascender = y_scale * .8;
-        extents->descender = y_scale - extents->ascender;
-        extents->line_gap = 0;
-      }
-    } else {
-      if (!get_font_v_extents (extents))
-      {
-        extents->ascender = x_scale / 2;
-        extents->descender = x_scale - extents->ascender;
-        extents->line_gap = 0;
-      }
-    }
+    if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+      get_h_extents_with_fallback (extents);
+    else
+      get_v_extents_with_fallback (extents);
   }
 
   inline void get_glyph_advance_for_direction (hb_codepoint_t glyph,
@@ -325,14 +343,38 @@
     }
   }
 
-  /* Internal only */
   inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph,
                                              hb_position_t *x, hb_position_t *y)
   {
     *x = get_glyph_h_advance (glyph) / 2;
 
-    /* TODO use font_extents.ascender */
-    *y = y_scale;
+    /* TODO cache this somehow?! */
+    hb_font_extents_t extents;
+    get_h_extents_with_fallback (&extents);
+    *y = extents.ascender;
+  }
+
+  inline void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph,
+                                                hb_position_t *x, hb_position_t *y)
+  {
+    if (!get_glyph_h_origin (glyph, x, y) &&
+         get_glyph_v_origin (glyph, x, y))
+    {
+      hb_position_t dx, dy;
+      guess_v_origin_minus_h_origin (glyph, &dx, &dy);
+      *x -= dx; *y -= dy;
+    }
+  }
+  inline void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph,
+                                                hb_position_t *x, hb_position_t *y)
+  {
+    if (!get_glyph_v_origin (glyph, x, y) &&
+         get_glyph_h_origin (glyph, x, y))
+    {
+      hb_position_t dx, dy;
+      guess_v_origin_minus_h_origin (glyph, &dx, &dy);
+      *x += dx; *y += dy;
+    }
   }
 
   inline void get_glyph_origin_for_direction (hb_codepoint_t glyph,
@@ -340,25 +382,9 @@
                                               hb_position_t *x, hb_position_t *y)
   {
     if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
-    {
-      if (!get_glyph_h_origin (glyph, x, y) &&
-           get_glyph_v_origin (glyph, x, y))
-      {
-        hb_position_t dx, dy;
-        guess_v_origin_minus_h_origin (glyph, &dx, &dy);
-        *x -= dx; *y -= dy;
-      }
-    }
+      get_glyph_h_origin_with_fallback (glyph, x, y);
     else
-    {
-      if (!get_glyph_v_origin (glyph, x, y) &&
-           get_glyph_h_origin (glyph, x, y))
-      {
-        hb_position_t dx, dy;
-        guess_v_origin_minus_h_origin (glyph, &dx, &dy);
-        *x += dx; *y += dy;
-      }
-    }
+      get_glyph_v_origin_with_fallback (glyph, x, y);
   }
 
   inline void add_glyph_h_origin (hb_codepoint_t glyph,
@@ -366,7 +392,7 @@
   {
     hb_position_t origin_x, origin_y;
 
-    get_glyph_h_origin (glyph, &origin_x, &origin_y);
+    get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y);
 
     *x += origin_x;
     *y += origin_y;
@@ -376,7 +402,7 @@
   {
     hb_position_t origin_x, origin_y;
 
-    get_glyph_v_origin (glyph, &origin_x, &origin_y);
+    get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y);
 
     *x += origin_x;
     *y += origin_y;
@@ -398,7 +424,7 @@
   {
     hb_position_t origin_x, origin_y;
 
-    get_glyph_h_origin (glyph, &origin_x, &origin_y);
+    get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y);
 
     *x -= origin_x;
     *y -= origin_y;
@@ -408,7 +434,7 @@
   {
     hb_position_t origin_x, origin_y;
 
-    get_glyph_v_origin (glyph, &origin_x, &origin_y);
+    get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y);
 
     *x -= origin_x;
     *y -= origin_y;
@@ -504,7 +530,6 @@
     return false;
   }
 
-  private:
   inline hb_position_t em_scale (int16_t v, int scale)
   {
     int upem = face->get_upem ();
@@ -512,6 +537,10 @@
     scaled += scaled >= 0 ? upem/2 : -upem/2; /* Round. */
     return (hb_position_t) (scaled / upem);
   }
+  inline hb_position_t em_scalef (float v, int scale)
+  {
+    return (hb_position_t) (v * scale / face->get_upem ());
+  }
 };
 
 #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -35,8 +35,6 @@
 #include "hb-ot-head-table.hh"
 #include "hb-ot-maxp-table.hh"
 
-#include "hb-cache-private.hh"
-
 #include <string.h>
 
 
@@ -401,9 +399,9 @@
 /**
  * hb_font_funcs_create: (Xconstructor)
  *
- *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  *
  * Since: 0.9.2
  **/
@@ -423,9 +421,9 @@
 /**
  * hb_font_funcs_get_empty:
  *
- *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  *
  * Since: 0.9.2
  **/
@@ -439,9 +437,9 @@
  * hb_font_funcs_reference: (skip)
  * @ffuncs: font functions.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -455,7 +453,7 @@
  * hb_font_funcs_destroy: (skip)
  * @ffuncs: font functions.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -475,14 +473,14 @@
 /**
  * hb_font_funcs_set_user_data: (skip)
  * @ffuncs: font functions.
- * @key:
- * @data:
- * @destroy:
- * @replace:
+ * @key: 
+ * @data: 
+ * @destroy: 
+ * @replace: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -499,11 +497,11 @@
 /**
  * hb_font_funcs_get_user_data: (skip)
  * @ffuncs: font functions.
- * @key:
- *
+ * @key: 
  *
+ * 
  *
- * Return value: (transfer none):
+ * Return value: (transfer none): 
  *
  * Since: 0.9.2
  **/
@@ -519,7 +517,7 @@
  * hb_font_funcs_make_immutable:
  * @ffuncs: font functions.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -536,9 +534,9 @@
  * hb_font_funcs_is_immutable:
  * @ffuncs: font functions.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -629,13 +627,13 @@
 /**
  * hb_font_get_glyph:
  * @font: a font.
- * @unicode:
- * @variation_selector:
- * @glyph: (out):
+ * @unicode: 
+ * @variation_selector: 
+ * @glyph: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -652,12 +650,12 @@
 /**
  * hb_font_get_nominal_glyph:
  * @font: a font.
- * @unicode:
- * @glyph: (out):
+ * @unicode: 
+ * @glyph: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 1.2.3
  **/
@@ -672,13 +670,13 @@
 /**
  * hb_font_get_variation_glyph:
  * @font: a font.
- * @unicode:
- * @variation_selector:
- * @glyph: (out):
+ * @unicode: 
+ * @variation_selector: 
+ * @glyph: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 1.2.3
  **/
@@ -693,11 +691,11 @@
 /**
  * hb_font_get_glyph_h_advance:
  * @font: a font.
- * @glyph:
- *
+ * @glyph: 
  *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -711,11 +709,11 @@
 /**
  * hb_font_get_glyph_v_advance:
  * @font: a font.
- * @glyph:
- *
+ * @glyph: 
  *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -729,13 +727,13 @@
 /**
  * hb_font_get_glyph_h_origin:
  * @font: a font.
- * @glyph:
- * @x: (out):
- * @y: (out):
+ * @glyph: 
+ * @x: (out): 
+ * @y: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -750,13 +748,13 @@
 /**
  * hb_font_get_glyph_v_origin:
  * @font: a font.
- * @glyph:
- * @x: (out):
- * @y: (out):
+ * @glyph: 
+ * @x: (out): 
+ * @y: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -771,12 +769,12 @@
 /**
  * hb_font_get_glyph_h_kerning:
  * @font: a font.
- * @left_glyph:
- * @right_glyph:
+ * @left_glyph: 
+ * @right_glyph: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -790,12 +788,12 @@
 /**
  * hb_font_get_glyph_v_kerning:
  * @font: a font.
- * @top_glyph:
- * @bottom_glyph:
+ * @top_glyph: 
+ * @bottom_glyph: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -809,12 +807,12 @@
 /**
  * hb_font_get_glyph_extents:
  * @font: a font.
- * @glyph:
- * @extents: (out):
+ * @glyph: 
+ * @extents: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -829,14 +827,14 @@
 /**
  * hb_font_get_glyph_contour_point:
  * @font: a font.
- * @glyph:
- * @point_index:
- * @x: (out):
- * @y: (out):
+ * @glyph: 
+ * @point_index: 
+ * @x: (out): 
+ * @y: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -851,13 +849,13 @@
 /**
  * hb_font_get_glyph_name:
  * @font: a font.
- * @glyph:
- * @name: (array length=size):
- * @size:
+ * @glyph: 
+ * @name: (array length=size): 
+ * @size: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -872,13 +870,13 @@
 /**
  * hb_font_get_glyph_from_name:
  * @font: a font.
- * @name: (array length=len):
- * @len:
- * @glyph: (out):
+ * @name: (array length=len): 
+ * @len: 
+ * @glyph: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -913,12 +911,12 @@
 /**
  * hb_font_get_glyph_advance_for_direction:
  * @font: a font.
- * @glyph:
- * @direction:
- * @x: (out):
- * @y: (out):
+ * @glyph: 
+ * @direction: 
+ * @x: (out): 
+ * @y: (out): 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -934,12 +932,12 @@
 /**
  * hb_font_get_glyph_origin_for_direction:
  * @font: a font.
- * @glyph:
- * @direction:
- * @x: (out):
- * @y: (out):
+ * @glyph: 
+ * @direction: 
+ * @x: (out): 
+ * @y: (out): 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -955,12 +953,12 @@
 /**
  * hb_font_add_glyph_origin_for_direction:
  * @font: a font.
- * @glyph:
- * @direction:
- * @x: (out):
- * @y: (out):
+ * @glyph: 
+ * @direction: 
+ * @x: (out): 
+ * @y: (out): 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -976,12 +974,12 @@
 /**
  * hb_font_subtract_glyph_origin_for_direction:
  * @font: a font.
- * @glyph:
- * @direction:
- * @x: (out):
- * @y: (out):
+ * @glyph: 
+ * @direction: 
+ * @x: (out): 
+ * @y: (out): 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -997,13 +995,13 @@
 /**
  * hb_font_get_glyph_kerning_for_direction:
  * @font: a font.
- * @first_glyph:
- * @second_glyph:
- * @direction:
- * @x: (out):
- * @y: (out):
+ * @first_glyph: 
+ * @second_glyph: 
+ * @direction: 
+ * @x: (out): 
+ * @y: (out): 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1019,13 +1017,13 @@
 /**
  * hb_font_get_glyph_extents_for_origin:
  * @font: a font.
- * @glyph:
- * @direction:
- * @extents: (out):
+ * @glyph: 
+ * @direction: 
+ * @extents: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -1041,15 +1039,15 @@
 /**
  * hb_font_get_glyph_contour_point_for_origin:
  * @font: a font.
- * @glyph:
- * @point_index:
- * @direction:
- * @x: (out):
- * @y: (out):
+ * @glyph: 
+ * @point_index: 
+ * @direction: 
+ * @x: (out): 
+ * @y: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -1066,11 +1064,11 @@
 /**
  * hb_font_glyph_to_string:
  * @font: a font.
- * @glyph:
- * @s: (array length=size):
- * @size:
+ * @glyph: 
+ * @s: (array length=size): 
+ * @size: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1086,13 +1084,13 @@
 /**
  * hb_font_glyph_from_string:
  * @font: a font.
- * @s: (array length=len) (element-type uint8_t):
- * @len:
- * @glyph: (out):
+ * @s: (array length=len) (element-type uint8_t): 
+ * @len: 
+ * @glyph: (out): 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -1113,9 +1111,9 @@
  * hb_font_create: (Xconstructor)
  * @face: a face.
  *
- *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  *
  * Since: 0.9.2
  **/
@@ -1143,9 +1141,9 @@
  * hb_font_create_sub_font:
  * @parent: parent font.
  *
- *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  *
  * Since: 0.9.2
  **/
@@ -1167,13 +1165,15 @@
   font->x_ppem = parent->x_ppem;
   font->y_ppem = parent->y_ppem;
 
+  /* TODO: copy variation coordinates. */
+
   return font;
 }
 
 /**
  * hb_font_get_empty:
  *
- *
+ * 
  *
  * Return value: (transfer full)
  *
@@ -1196,6 +1196,9 @@
     0, /* x_ppem */
     0, /* y_ppem */
 
+    0, /* num_coords */
+    NULL, /* coords */
+
     const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */
     NULL, /* user_data */
     NULL, /* destroy */
@@ -1214,9 +1217,9 @@
  * hb_font_reference: (skip)
  * @font: a font.
  *
- *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  *
  * Since: 0.9.2
  **/
@@ -1230,7 +1233,7 @@
  * hb_font_destroy: (skip)
  * @font: a font.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1250,20 +1253,22 @@
   hb_face_destroy (font->face);
   hb_font_funcs_destroy (font->klass);
 
+  free (font->coords);
+
   free (font);
 }
 
 /**
  * hb_font_set_user_data: (skip)
  * @font: a font.
- * @key:
- * @data:
- * @destroy:
- * @replace:
+ * @key: 
+ * @data: 
+ * @destroy: 
+ * @replace: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -1280,11 +1285,11 @@
 /**
  * hb_font_get_user_data: (skip)
  * @font: a font.
- * @key:
- *
+ * @key: 
  *
+ * 
  *
- * Return value: (transfer none):
+ * Return value: (transfer none): 
  *
  * Since: 0.9.2
  **/
@@ -1299,7 +1304,7 @@
  * hb_font_make_immutable:
  * @font: a font.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1319,9 +1324,9 @@
  * hb_font_is_immutable:
  * @font: a font.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -1361,9 +1366,9 @@
  * hb_font_get_parent:
  * @font: a font.
  *
- *
+ * 
  *
- * Return value: (transfer none):
+ * Return value: (transfer none): 
  *
  * Since: 0.9.2
  **/
@@ -1377,9 +1382,9 @@
  * hb_font_get_face:
  * @font: a font.
  *
- *
+ * 
  *
- * Return value: (transfer none):
+ * Return value: (transfer none): 
  *
  * Since: 0.9.2
  **/
@@ -1394,10 +1399,10 @@
  * hb_font_set_funcs:
  * @font: a font.
  * @klass: (closure font_data) (destroy destroy) (scope notified):
- * @font_data:
- * @destroy:
+ * @font_data: 
+ * @destroy: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1430,9 +1435,9 @@
  * hb_font_set_funcs_data:
  * @font: a font.
  * @font_data: (destroy destroy) (scope notified):
- * @destroy:
+ * @destroy: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1459,10 +1464,10 @@
 /**
  * hb_font_set_scale:
  * @font: a font.
- * @x_scale:
- * @y_scale:
+ * @x_scale: 
+ * @y_scale: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1481,10 +1486,10 @@
 /**
  * hb_font_get_scale:
  * @font: a font.
- * @x_scale: (out):
- * @y_scale: (out):
+ * @x_scale: (out): 
+ * @y_scale: (out): 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1500,10 +1505,10 @@
 /**
  * hb_font_set_ppem:
  * @font: a font.
- * @x_ppem:
- * @y_ppem:
+ * @x_ppem: 
+ * @y_ppem: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1522,10 +1527,10 @@
 /**
  * hb_font_get_ppem:
  * @font: a font.
- * @x_ppem: (out):
- * @y_ppem: (out):
+ * @x_ppem: (out): 
+ * @y_ppem: (out): 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -1539,6 +1544,32 @@
 }
 
 
+void
+hb_font_set_var_coords_normalized (hb_font_t *font,
+                                   int *coords, /* XXX 2.14 normalized */
+                                   unsigned int coords_length)
+{
+  if (font->immutable)
+    return;
+
+  /* Skip tail zero entries. */
+  while (coords_length && !coords[coords_length - 1])
+    coords_length--;
+
+  int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : NULL;
+  if (unlikely (coords_length && !copy))
+    return;
+
+  free (font->coords);
+
+  if (coords_length)
+    memcpy (copy, coords, coords_length * sizeof (coords[0]));
+
+  font->coords = copy;
+  font->num_coords = coords_length;
+}
+
+
 #ifndef HB_DISABLE_DEPRECATED
 
 /*
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.h	Tue Jan 24 00:30:25 2017 +0100
@@ -604,6 +604,11 @@
                   unsigned int *y_ppem);
 
 
+HB_EXTERN void
+hb_font_set_var_coords_normalized (hb_font_t *font,
+                                   int *coords, /* XXX 2.14 normalized */
+                                   unsigned int coords_length);
+
 HB_END_DECLS
 
 #endif /* HB_FONT_H */
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -33,7 +33,10 @@
 
 #include "hb-font-private.hh"
 
+#include "hb-cache-private.hh" // Maybe use in the future?
+
 #include FT_ADVANCES_H
+#include FT_MULTIPLE_MASTERS_H
 #include FT_TRUETYPE_TABLES_H
 
 
@@ -111,7 +114,7 @@
  * @font:
  * @load_flags:
  *
- *
+ * 
  *
  * Since: 1.0.5
  **/
@@ -133,7 +136,7 @@
  * hb_ft_font_get_load_flags:
  * @font:
  *
- *
+ * 
  *
  * Return value:
  * Since: 1.0.5
@@ -504,12 +507,12 @@
 
 /**
  * hb_ft_face_create:
- * @ft_face: (destroy destroy) (scope notified):
+ * @ft_face: (destroy destroy) (scope notified): 
  * @destroy:
  *
- *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  * Since: 0.9.2
  **/
 hb_face_t *
@@ -541,9 +544,9 @@
  * hb_ft_face_create_referenced:
  * @ft_face:
  *
- *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  * Since: 0.9.38
  **/
 hb_face_t *
@@ -561,11 +564,11 @@
 
 /**
  * hb_ft_face_create_cached:
- * @ft_face:
- *
+ * @ft_face: 
  *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  * Since: 0.9.2
  **/
 hb_face_t *
@@ -586,12 +589,12 @@
 
 /**
  * hb_ft_font_create:
- * @ft_face: (destroy destroy) (scope notified):
+ * @ft_face: (destroy destroy) (scope notified): 
  * @destroy:
  *
- *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  * Since: 0.9.2
  **/
 hb_font_t *
@@ -606,14 +609,31 @@
   hb_face_destroy (face);
   _hb_ft_font_set_funcs (font, ft_face, false);
   hb_font_set_scale (font,
-                     (int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16),
-                     (int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16));
+                     (int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16),
+                     (int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16));
 #if 0 /* hb-ft works in no-hinting model */
   hb_font_set_ppem (font,
                     ft_face->size->metrics.x_ppem,
                     ft_face->size->metrics.y_ppem);
 #endif
 
+#ifdef HAVE_FT_GET_VAR_BLEND_COORDINATES
+  FT_MM_Var *mm_var = NULL;
+  if (!FT_Get_MM_Var (ft_face, &mm_var))
+  {
+    FT_Fixed coords[mm_var->num_axis];
+    int hbCoords[mm_var->num_axis];
+    if (!FT_Get_Var_Blend_Coordinates (ft_face, mm_var->num_axis, coords))
+    {
+      for (int i = 0; i < mm_var->num_axis; ++i)
+        hbCoords[i] = coords[i] >> 2;
+
+      hb_font_set_var_coords_normalized (font, hbCoords, mm_var->num_axis);
+    }
+  }
+  free (mm_var);
+#endif
+
   return font;
 }
 
@@ -621,9 +641,9 @@
  * hb_ft_font_create_referenced:
  * @ft_face:
  *
- *
+ * 
  *
- * Return value: (transfer full):
+ * Return value: (transfer full): 
  * Since: 0.9.38
  **/
 hb_font_t *
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-open-type-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-open-type-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -105,7 +105,7 @@
   inline unsigned int get_size (void) const { return (size); }
 
 #define DEFINE_SIZE_UNION(size, _member) \
-  DEFINE_INSTANCE_ASSERTION (this->u._member.static_size == (size)); \
+  DEFINE_INSTANCE_ASSERTION (0*sizeof(this->u._member.static_size) + sizeof(this->u._member) == (size)); \
   static const unsigned int min_size = (size)
 
 #define DEFINE_SIZE_MIN(size) \
@@ -650,7 +650,9 @@
   DEFINE_SIZE_STATIC (Size);
 };
 
+typedef IntType<int8_t  , 1> CHAR;      /* 8-bit signed integer. */
 typedef IntType<uint8_t , 1> BYTE;      /* 8-bit unsigned integer. */
+typedef IntType<int8_t  , 1> INT8;      /* 8-bit signed integer. */
 typedef IntType<uint16_t, 2> USHORT;    /* 16-bit unsigned integer. */
 typedef IntType<int16_t,  2> SHORT;     /* 16-bit signed integer. */
 typedef IntType<uint32_t, 4> ULONG;     /* 32-bit unsigned integer. */
@@ -805,6 +807,7 @@
     if (unlikely (!c->check_struct (this))) return_trace (false);
     unsigned int offset = *this;
     if (unlikely (!offset)) return_trace (true);
+    if (unlikely (!c->check_range (base, offset))) return_trace (false);
     const Type &obj = StructAtOffset<Type> (base, offset);
     return_trace (likely (obj.sanitize (c)) || neuter (c));
   }
@@ -815,6 +818,7 @@
     if (unlikely (!c->check_struct (this))) return_trace (false);
     unsigned int offset = *this;
     if (unlikely (!offset)) return_trace (true);
+    if (unlikely (!c->check_range (base, offset))) return_trace (false);
     const Type &obj = StructAtOffset<Type> (base, offset);
     return_trace (likely (obj.sanitize (c, user_data)) || neuter (c));
   }
@@ -948,8 +952,8 @@
 };
 
 /* Array of Offset's */
-template <typename Type>
-struct OffsetArrayOf : ArrayOf<OffsetTo<Type> > {};
+template <typename Type, typename OffsetType=USHORT>
+struct OffsetArrayOf : ArrayOf<OffsetTo<Type, OffsetType> > {};
 
 /* Array of offsets relative to the beginning of the array itself. */
 template <typename Type>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-cbdt-table.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,384 @@
+/*
+ * Copyright © 2016  Google, Inc.
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Seigo Nonaka
+ */
+
+#ifndef HB_OT_CBDT_TABLE_HH
+#define HB_OT_CBDT_TABLE_HH
+
+#include "hb-open-type-private.hh"
+
+namespace OT {
+
+struct SmallGlyphMetrics
+{
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this));
+  }
+
+  inline void get_extents (hb_glyph_extents_t *extents) const
+  {
+    extents->x_bearing = bearingX;
+    extents->y_bearing = bearingY;
+    extents->width = width;
+    extents->height = -height;
+  }
+
+  BYTE height;
+  BYTE width;
+  CHAR bearingX;
+  CHAR bearingY;
+  BYTE advance;
+
+  DEFINE_SIZE_STATIC(5);
+};
+
+struct BigGlyphMetrics : SmallGlyphMetrics
+{
+  CHAR vertBearingX;
+  CHAR vertBearingY;
+  BYTE vertAdvance;
+
+  DEFINE_SIZE_STATIC(8);
+};
+
+struct SBitLineMetrics
+{
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this));
+  }
+
+  CHAR ascender;
+  CHAR decender;
+  BYTE widthMax;
+  CHAR caretSlopeNumerator;
+  CHAR caretSlopeDenominator;
+  CHAR caretOffset;
+  CHAR minOriginSB;
+  CHAR minAdvanceSB;
+  CHAR maxBeforeBL;
+  CHAR minAfterBL;
+  CHAR padding1;
+  CHAR padding2;
+
+  DEFINE_SIZE_STATIC(12);
+};
+
+
+/*
+ * Index Subtables.
+ */
+
+struct IndexSubtableHeader
+{
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this));
+  }
+
+  USHORT indexFormat;
+  USHORT imageFormat;
+  ULONG imageDataOffset;
+
+  DEFINE_SIZE_STATIC(8);
+};
+
+template <typename OffsetType>
+struct IndexSubtableFormat1Or3
+{
+  inline bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this) &&
+		  c->check_array (offsetArrayZ, offsetArrayZ[0].static_size, glyph_count + 1));
+  }
+
+  bool get_image_data (unsigned int idx,
+		       unsigned int *offset,
+		       unsigned int *length) const
+  {
+    if (unlikely (offsetArrayZ[idx + 1] <= offsetArrayZ[idx]))
+      return false;
+
+    *offset = header.imageDataOffset + offsetArrayZ[idx];
+    *length = offsetArrayZ[idx + 1] - offsetArrayZ[idx];
+    return true;
+  }
+
+  IndexSubtableHeader header;
+  Offset<OffsetType> offsetArrayZ[VAR];
+
+  DEFINE_SIZE_ARRAY(8, offsetArrayZ);
+};
+
+struct IndexSubtableFormat1 : IndexSubtableFormat1Or3<ULONG> {};
+struct IndexSubtableFormat3 : IndexSubtableFormat1Or3<USHORT> {};
+
+struct IndexSubtable
+{
+  inline bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const
+  {
+    TRACE_SANITIZE (this);
+    if (!u.header.sanitize (c)) return_trace (false);
+    switch (u.header.indexFormat) {
+    case 1: return_trace (u.format1.sanitize (c, glyph_count));
+    case 3: return_trace (u.format3.sanitize (c, glyph_count));
+    default:return_trace (true);
+    }
+  }
+
+  inline bool get_extents (hb_glyph_extents_t *extents) const
+  {
+    switch (u.header.indexFormat) {
+    case 2: case 5: /* TODO */
+    case 1: case 3: case 4: /* Variable-metrics formats do not have metrics here. */
+    default:return (false);
+    }
+  }
+
+  bool get_image_data (unsigned int idx,
+		       unsigned int *offset,
+		       unsigned int *length,
+		       unsigned int *format) const
+  {
+    *format = u.header.imageFormat;
+    switch (u.header.indexFormat) {
+    case 1: return u.format1.get_image_data (idx, offset, length);
+    case 3: return u.format3.get_image_data (idx, offset, length);
+    default: return false;
+    }
+  }
+
+  protected:
+  union {
+  IndexSubtableHeader	header;
+  IndexSubtableFormat1	format1;
+  IndexSubtableFormat3	format3;
+  /* TODO: Format 2, 4, 5. */
+  } u;
+  public:
+  DEFINE_SIZE_UNION (8, header);
+};
+
+struct IndexSubtableRecord
+{
+  inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this) &&
+		  firstGlyphIndex <= lastGlyphIndex &&
+		  offsetToSubtable.sanitize (c, this, lastGlyphIndex - firstGlyphIndex + 1));
+  }
+
+  inline bool get_extents (hb_glyph_extents_t *extents) const
+  {
+    return (this+offsetToSubtable).get_extents (extents);
+  }
+
+  bool get_image_data (unsigned int gid,
+		       unsigned int *offset,
+		       unsigned int *length,
+		       unsigned int *format) const
+  {
+    if (gid < firstGlyphIndex || gid > lastGlyphIndex)
+    {
+      return false;
+    }
+    return (this+offsetToSubtable).get_image_data (gid - firstGlyphIndex,
+						   offset, length, format);
+  }
+
+  USHORT firstGlyphIndex;
+  USHORT lastGlyphIndex;
+  OffsetTo<IndexSubtable, ULONG> offsetToSubtable;
+
+  DEFINE_SIZE_STATIC(8);
+};
+
+struct IndexSubtableArray
+{
+  inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
+  {
+    TRACE_SANITIZE (this);
+    if (unlikely (!c->check_array (&indexSubtablesZ, indexSubtablesZ[0].static_size, count)))
+      return_trace (false);
+    for (unsigned int i = 0; i < count; i++)
+      if (unlikely (!indexSubtablesZ[i].sanitize (c, this)))
+	return_trace (false);
+    return_trace (true);
+  }
+
+  public:
+  const IndexSubtableRecord* find_table (hb_codepoint_t glyph, unsigned int numTables) const
+  {
+    for (unsigned int i = 0; i < numTables; ++i)
+    {
+      unsigned int firstGlyphIndex = indexSubtablesZ[i].firstGlyphIndex;
+      unsigned int lastGlyphIndex = indexSubtablesZ[i].lastGlyphIndex;
+      if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex) {
+        return &indexSubtablesZ[i];
+      }
+    }
+    return NULL;
+  }
+
+  protected:
+  IndexSubtableRecord indexSubtablesZ[VAR];
+
+  public:
+  DEFINE_SIZE_ARRAY(0, indexSubtablesZ);
+};
+
+struct BitmapSizeTable
+{
+  friend struct CBLC;
+
+  inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this) &&
+		  indexSubtableArrayOffset.sanitize (c, base, numberOfIndexSubtables) &&
+		  c->check_range (&(base+indexSubtableArrayOffset), indexTablesSize) &&
+		  horizontal.sanitize (c) &&
+		  vertical.sanitize (c));
+  }
+
+  const IndexSubtableRecord *find_table (hb_codepoint_t glyph, const void *base) const
+  {
+    return (base+indexSubtableArrayOffset).find_table (glyph, numberOfIndexSubtables);
+  }
+
+  protected:
+  OffsetTo<IndexSubtableArray, ULONG> indexSubtableArrayOffset;
+  ULONG indexTablesSize;
+  ULONG numberOfIndexSubtables;
+  ULONG colorRef;
+  SBitLineMetrics horizontal;
+  SBitLineMetrics vertical;
+  USHORT startGlyphIndex;
+  USHORT endGlyphIndex;
+  BYTE ppemX;
+  BYTE ppemY;
+  BYTE bitDepth;
+  CHAR flags;
+
+public:
+  DEFINE_SIZE_STATIC(48);
+};
+
+
+/*
+ * Glyph Bitmap Data Formats.
+ */
+
+struct GlyphBitmapDataFormat17
+{
+  SmallGlyphMetrics glyphMetrics;
+  ULONG dataLen;
+  BYTE dataZ[VAR];
+
+  DEFINE_SIZE_ARRAY(9, dataZ);
+};
+
+
+/*
+ * CBLC -- Color Bitmap Location Table
+ */
+
+#define HB_OT_TAG_CBLC HB_TAG('C','B','L','C')
+
+struct CBLC
+{
+  static const hb_tag_t tableTag = HB_OT_TAG_CBLC;
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this) &&
+		  likely (version.major == 2 || version.major == 3) &&
+		  sizeTables.sanitize (c, this));
+  }
+
+  public:
+  const IndexSubtableRecord *find_table (hb_codepoint_t glyph,
+					 unsigned int *x_ppem, unsigned int *y_ppem) const
+  {
+    /* TODO: Make it possible to select strike. */
+
+    unsigned int count = sizeTables.len;
+    for (uint32_t i = 0; i < count; ++i)
+    {
+      unsigned int startGlyphIndex = sizeTables.array[i].startGlyphIndex;
+      unsigned int endGlyphIndex = sizeTables.array[i].endGlyphIndex;
+      if (startGlyphIndex <= glyph && glyph <= endGlyphIndex)
+      {
+	*x_ppem = sizeTables[i].ppemX;
+	*y_ppem = sizeTables[i].ppemY;
+	return sizeTables[i].find_table (glyph, this);
+      }
+    }
+
+    return NULL;
+  }
+
+  protected:
+  FixedVersion<>version;
+  ArrayOf<BitmapSizeTable, ULONG> sizeTables;
+
+  public:
+  DEFINE_SIZE_ARRAY(8, sizeTables);
+};
+
+/*
+ * CBDT -- Color Bitmap Data Table
+ */
+#define HB_OT_TAG_CBDT HB_TAG('C','B','D','T')
+
+struct CBDT
+{
+  static const hb_tag_t tableTag = HB_OT_TAG_CBDT;
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this) &&
+		  likely (version.major == 2 || version.major == 3));
+  }
+
+  protected:
+  FixedVersion<>version;
+  BYTE dataZ[VAR];
+
+  public:
+  DEFINE_SIZE_ARRAY(4, dataZ);
+};
+
+} /* namespace OT */
+
+#endif /* HB_OT_CBDT_TABLE_HH */
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-font.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-font.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -31,6 +31,7 @@
 #include "hb-font-private.hh"
 
 #include "hb-ot-cmap-table.hh"
+#include "hb-ot-cbdt-table.hh"
 #include "hb-ot-glyf-table.hh"
 #include "hb-ot-head-table.hh"
 #include "hb-ot-hhea-table.hh"
@@ -47,6 +48,7 @@
   unsigned short ascender;
   unsigned short descender;
   unsigned short line_gap;
+  bool has_font_extents;
 
   const OT::_mtx *table;
   hb_blob_t *blob;
@@ -54,9 +56,10 @@
   inline void init (hb_face_t *face,
                     hb_tag_t _hea_tag,
                     hb_tag_t _mtx_tag,
-                    hb_tag_t os2_tag)
+                    hb_tag_t os2_tag,
+                    unsigned int default_advance = 0)
   {
-    this->default_advance = face->get_upem ();
+    this->default_advance = default_advance ? default_advance : face->get_upem ();
 
     bool got_font_extents = false;
     if (os2_tag)
@@ -82,9 +85,12 @@
       this->ascender = _hea->ascender;
       this->descender = _hea->descender;
       this->line_gap = _hea->lineGap;
+      got_font_extents = (this->ascender | this->descender) != 0;
     }
     hb_blob_destroy (_hea_blob);
 
+    this->has_font_extents = got_font_extents;
+
     this->blob = OT::Sanitizer<OT::_mtx>::sanitize (face->reference_table (_mtx_tag));
 
     /* Cap num_metrics() and num_advances() based on table length. */
@@ -202,6 +208,91 @@
   }
 };
 
+struct hb_ot_face_cbdt_accelerator_t
+{
+  hb_blob_t *cblc_blob;
+  hb_blob_t *cbdt_blob;
+  const OT::CBLC *cblc;
+  const OT::CBDT *cbdt;
+
+  unsigned int cbdt_len;
+  float upem;
+
+  inline void init (hb_face_t *face)
+  {
+    upem = face->get_upem();
+
+    cblc_blob = OT::Sanitizer<OT::CBLC>::sanitize (face->reference_table (HB_OT_TAG_CBLC));
+    cbdt_blob = OT::Sanitizer<OT::CBDT>::sanitize (face->reference_table (HB_OT_TAG_CBDT));
+    cbdt_len = hb_blob_get_length (cbdt_blob);
+
+    if (hb_blob_get_length (cblc_blob) == 0) {
+      cblc = NULL;
+      cbdt = NULL;
+      return;  /* Not a bitmap font. */
+    }
+    cblc = OT::Sanitizer<OT::CBLC>::lock_instance (cblc_blob);
+    cbdt = OT::Sanitizer<OT::CBDT>::lock_instance (cbdt_blob);
+
+  }
+
+  inline void fini (void)
+  {
+    hb_blob_destroy (this->cblc_blob);
+    hb_blob_destroy (this->cbdt_blob);
+  }
+
+  inline bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
+  {
+    unsigned int x_ppem = upem, y_ppem = upem; /* TODO Use font ppem if available. */
+
+    if (cblc == NULL)
+      return false;  // Not a color bitmap font.
+
+    const OT::IndexSubtableRecord *subtable_record = this->cblc->find_table(glyph, &x_ppem, &y_ppem);
+    if (subtable_record == NULL)
+      return false;
+
+    if (subtable_record->get_extents (extents))
+      return true;
+
+    unsigned int image_offset = 0, image_length = 0, image_format = 0;
+    if (!subtable_record->get_image_data (glyph, &image_offset, &image_length, &image_format))
+      return false;
+
+    {
+      /* TODO Move the following into CBDT struct when adding more formats. */
+
+      if (unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length))
+        return false;
+
+      switch (image_format)
+      {
+        case 17: {
+          if (unlikely (image_length < OT::GlyphBitmapDataFormat17::min_size))
+            return false;
+
+          const OT::GlyphBitmapDataFormat17& glyphFormat17 =
+              OT::StructAtOffset<OT::GlyphBitmapDataFormat17> (this->cbdt, image_offset);
+          glyphFormat17.glyphMetrics.get_extents (extents);
+        }
+        break;
+        default:
+          // TODO: Support other image formats.
+          return false;
+      }
+    }
+
+    /* Convert to the font units. */
+    extents->x_bearing *= upem / (float) x_ppem;
+    extents->y_bearing *= upem / (float) y_ppem;
+    extents->width *= upem / (float) x_ppem;
+    extents->height *= upem / (float) y_ppem;
+
+    return true;
+  }
+};
+
 typedef bool (*hb_cmap_get_glyph_func_t) (const void *obj,
                                           hb_codepoint_t codepoint,
                                           hb_codepoint_t *glyph);
@@ -264,7 +355,11 @@
     if (!subtable) subtable = cmap->find_subtable (0, 2);
     if (!subtable) subtable = cmap->find_subtable (0, 1);
     if (!subtable) subtable = cmap->find_subtable (0, 0);
-    if (!subtable)(subtable = cmap->find_subtable (3, 0)) && (symbol = true);
+    if (!subtable)
+    {
+      subtable = cmap->find_subtable (3, 0);
+      if (subtable) symbol = true;
+    }
     /* Meh. */
     if (!subtable) subtable = &OT::Null(OT::CmapSubtable);
 
@@ -374,6 +469,7 @@
   hb_ot_face_metrics_accelerator_t h_metrics;
   hb_ot_face_metrics_accelerator_t v_metrics;
   hb_lazy_loader_t<hb_ot_face_glyf_accelerator_t> glyf;
+  hb_lazy_loader_t<hb_ot_face_cbdt_accelerator_t> cbdt;
 };
 
 
@@ -387,8 +483,10 @@
 
   ot_font->cmap.init (face);
   ot_font->h_metrics.init (face, HB_OT_TAG_hhea, HB_OT_TAG_hmtx, HB_OT_TAG_os2);
-  ot_font->v_metrics.init (face, HB_OT_TAG_vhea, HB_OT_TAG_vmtx, HB_TAG_NONE); /* TODO Can we do this lazily? */
+  ot_font->v_metrics.init (face, HB_OT_TAG_vhea, HB_OT_TAG_vmtx, HB_TAG_NONE,
+                           ot_font->h_metrics.ascender - ot_font->h_metrics.descender); /* TODO Can we do this lazily? */
   ot_font->glyf.init (face);
+  ot_font->cbdt.init (face);
 
   return ot_font;
 }
@@ -400,6 +498,7 @@
   ot_font->h_metrics.fini ();
   ot_font->v_metrics.fini ();
   ot_font->glyf.fini ();
+  ot_font->cbdt.fini ();
 
   free (ot_font);
 }
@@ -458,6 +557,8 @@
 {
   const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
   bool ret = ot_font->glyf->get_extents (glyph, extents);
+  if (!ret)
+    ret = ot_font->cbdt->get_extents (glyph, extents);
   extents->x_bearing = font->em_scale_x (extents->x_bearing);
   extents->y_bearing = font->em_scale_y (extents->y_bearing);
   extents->width     = font->em_scale_x (extents->width);
@@ -475,7 +576,7 @@
   metrics->ascender = font->em_scale_y (ot_font->h_metrics.ascender);
   metrics->descender = font->em_scale_y (ot_font->h_metrics.descender);
   metrics->line_gap = font->em_scale_y (ot_font->h_metrics.line_gap);
-  return true;
+  return ot_font->h_metrics.has_font_extents;
 }
 
 static hb_bool_t
@@ -488,7 +589,7 @@
   metrics->ascender = font->em_scale_x (ot_font->v_metrics.ascender);
   metrics->descender = font->em_scale_x (ot_font->v_metrics.descender);
   metrics->line_gap = font->em_scale_x (ot_font->v_metrics.line_gap);
-  return true;
+  return ot_font->v_metrics.has_font_extents;
 }
 
 static hb_font_funcs_t *static_ot_funcs = NULL;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-common-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-common-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -507,7 +507,7 @@
   { return this+featureParams; }
 
   inline bool sanitize (hb_sanitize_context_t *c,
-                        const Record<Feature>::sanitize_closure_t *closure) const
+                        const Record<Feature>::sanitize_closure_t *closure = NULL) const
   {
     TRACE_SANITIZE (this);
     if (unlikely (!(c->check_struct (this) && lookupIndex.sanitize (c))))
@@ -731,8 +731,8 @@
     inline void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; };
     inline bool more (void) { return i < c->glyphArray.len; }
     inline void next (void) { i++; }
-    inline uint16_t get_glyph (void) { return c->glyphArray[i]; }
-    inline uint16_t get_coverage (void) { return i; }
+    inline hb_codepoint_t get_glyph (void) { return c->glyphArray[i]; }
+    inline unsigned int get_coverage (void) { return i; }
 
     private:
     const struct CoverageFormat1 *c;
@@ -829,26 +829,33 @@
 
   public:
   /* Older compilers need this to be public. */
-  struct Iter {
-    inline void init (const CoverageFormat2 &c_) {
+  struct Iter
+  {
+    inline void init (const CoverageFormat2 &c_)
+    {
       c = &c_;
       coverage = 0;
       i = 0;
       j = c->rangeRecord.len ? c_.rangeRecord[0].start : 0;
     }
     inline bool more (void) { return i < c->rangeRecord.len; }
-    inline void next (void) {
-      coverage++;
-      if (j == c->rangeRecord[i].end) {
+    inline void next (void)
+    {
+      if (j >= c->rangeRecord[i].end)
+      {
         i++;
         if (more ())
+        {
           j = c->rangeRecord[i].start;
+          coverage = c->rangeRecord[i].value;
+        }
         return;
       }
+      coverage++;
       j++;
     }
-    inline uint16_t get_glyph (void) { return j; }
-    inline uint16_t get_coverage (void) { return coverage; }
+    inline hb_codepoint_t get_glyph (void) { return j; }
+    inline unsigned int get_coverage (void) { return coverage; }
 
     private:
     const struct CoverageFormat2 *c;
@@ -957,14 +964,14 @@
       default:                   break;
       }
     }
-    inline uint16_t get_glyph (void) {
+    inline hb_codepoint_t get_glyph (void) {
       switch (format) {
       case 1: return u.format1.get_glyph ();
       case 2: return u.format2.get_glyph ();
       default:return 0;
       }
     }
-    inline uint16_t get_coverage (void) {
+    inline unsigned int get_coverage (void) {
       switch (format) {
       case 1: return u.format1.get_coverage ();
       case 2: return u.format2.get_coverage ();
@@ -1162,11 +1169,380 @@
 
 
 /*
+ * Item Variation Store
+ */
+
+struct VarRegionAxis
+{
+  inline float evaluate (int coord) const
+  {
+    int start = startCoord, peak = peakCoord, end = endCoord;
+
+    /* TODO Move these to sanitize(). */
+    if (unlikely (start > peak || peak > end))
+      return 1.;
+    if (unlikely (start < 0 && end > 0 && peak != 0))
+      return 1.;
+
+    if (peak == 0 || coord == peak)
+      return 1.;
+
+    if (coord <= start || end <= coord)
+      return 0.;
+
+    /* Interpolate */
+    if (coord < peak)
+      return float (coord - start) / (peak - start);
+    else
+      return float (end - coord) / (end - peak);
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this));
+    /* TODO Handle invalid start/peak/end configs, so we don't
+     * have to do that at runtime. */
+  }
+
+  public:
+  F2DOT14       startCoord;
+  F2DOT14       peakCoord;
+  F2DOT14       endCoord;
+  public:
+  DEFINE_SIZE_STATIC (6);
+};
+
+struct VarRegionList
+{
+  inline float evaluate (unsigned int region_index,
+                         int *coords, unsigned int coord_len) const
+  {
+    if (unlikely (region_index >= regionCount))
+      return 0.;
+
+    const VarRegionAxis *axes = axesZ + (region_index * axisCount);
+
+    float v = 1.;
+    unsigned int count = MIN (coord_len, (unsigned int) axisCount);
+    for (unsigned int i = 0; i < count; i++)
+    {
+      float factor = axes[i].evaluate (coords[i]);
+      if (factor == 0.)
+        return 0.;
+      v *= factor;
+    }
+    return v;
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this) &&
+                  c->check_array (axesZ, axesZ[0].static_size,
+                                  (unsigned int) axisCount * (unsigned int) regionCount));
+  }
+
+  protected:
+  USHORT        axisCount;
+  USHORT        regionCount;
+  VarRegionAxis axesZ[VAR];
+  public:
+  DEFINE_SIZE_ARRAY (4, axesZ);
+};
+
+struct VarData
+{
+  inline unsigned int get_row_size (void) const
+  { return shortCount + regionIndices.len; }
+
+  inline unsigned int get_size (void) const
+  { return itemCount * get_row_size (); }
+
+  inline float get_delta (unsigned int inner,
+                          int *coords, unsigned int coord_count,
+                          const VarRegionList &regions) const
+  {
+    if (unlikely (inner >= itemCount))
+      return 0.;
+
+   unsigned int count = regionIndices.len;
+   unsigned int scount = shortCount;
+
+   const BYTE *bytes = &StructAfter<BYTE> (regionIndices);
+   const BYTE *row = bytes + inner * (scount + count);
+
+   float delta = 0.;
+   unsigned int i = 0;
+
+   const SHORT *scursor = reinterpret_cast<const SHORT *> (row);
+   for (; i < scount; i++)
+   {
+     float scalar = regions.evaluate (regionIndices.array[i], coords, coord_count);
+     delta += scalar * *scursor++;
+   }
+   const INT8 *bcursor = reinterpret_cast<const INT8 *> (scursor);
+   for (; i < count; i++)
+   {
+     float scalar = regions.evaluate (regionIndices.array[i], coords, coord_count);
+     delta += scalar * *bcursor++;
+   }
+
+   return delta;
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this) &&
+                  regionIndices.sanitize(c) &&
+                  shortCount <= regionIndices.len &&
+                  c->check_array (&StructAfter<BYTE> (regionIndices),
+                                  get_row_size (), itemCount));
+  }
+
+  protected:
+  USHORT                itemCount;
+  USHORT                shortCount;
+  ArrayOf<USHORT>       regionIndices;
+  BYTE                  bytesX[VAR];
+  public:
+  DEFINE_SIZE_ARRAY2 (6, regionIndices, bytesX);
+};
+
+struct VariationStore
+{
+  inline float get_delta (unsigned int outer, unsigned int inner,
+                          int *coords, unsigned int coord_count) const
+  {
+    if (unlikely (outer >= dataSets.len))
+      return 0.;
+
+    return (this+dataSets[outer]).get_delta (inner,
+                                             coords, coord_count,
+                                             this+regions);
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this) &&
+                  format == 1 &&
+                  regions.sanitize (c, this) &&
+                  dataSets.sanitize (c, this));
+  }
+
+  protected:
+  USHORT                                format;
+  OffsetTo<VarRegionList, ULONG>        regions;
+  OffsetArrayOf<VarData, ULONG>         dataSets;
+  public:
+  DEFINE_SIZE_ARRAY (8, dataSets);
+};
+
+/*
+ * Feature Variations
+ */
+
+struct ConditionFormat1
+{
+  friend struct Condition;
+
+  private:
+  inline bool evaluate (const int *coords, unsigned int coord_len) const
+  {
+    int coord = axisIndex < coord_len ? coords[axisIndex] : 0;
+    return filterRangeMinValue <= coord && coord <= filterRangeMaxValue;
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this));
+  }
+
+  protected:
+  USHORT        format;         /* Format identifier--format = 1 */
+  USHORT        axisIndex;
+  F2DOT14       filterRangeMinValue;
+  F2DOT14       filterRangeMaxValue;
+  public:
+  DEFINE_SIZE_STATIC (8);
+};
+
+struct Condition
+{
+  inline bool evaluate (const int *coords, unsigned int coord_len) const
+  {
+    switch (u.format) {
+    case 1: return u.format1.evaluate (coords, coord_len);
+    default:return false;
+    }
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    if (!u.format.sanitize (c)) return_trace (false);
+    switch (u.format) {
+    case 1: return_trace (u.format1.sanitize (c));
+    default:return_trace (true);
+    }
+  }
+
+  protected:
+  union {
+  USHORT                format;         /* Format identifier */
+  ConditionFormat1      format1;
+  } u;
+  public:
+  DEFINE_SIZE_UNION (2, format);
+};
+
+struct ConditionSet
+{
+  inline bool evaluate (const int *coords, unsigned int coord_len) const
+  {
+    unsigned int count = conditions.len;
+    for (unsigned int i = 0; i < count; i++)
+      if (!(this+conditions.array[i]).evaluate (coords, coord_len))
+        return false;
+    return true;
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (conditions.sanitize (c, this));
+  }
+
+  protected:
+  OffsetArrayOf<Condition, ULONG> conditions;
+  public:
+  DEFINE_SIZE_ARRAY (2, conditions);
+};
+
+struct FeatureTableSubstitutionRecord
+{
+  friend struct FeatureTableSubstitution;
+
+  inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this) && feature.sanitize (c, base));
+  }
+
+  protected:
+  USHORT                        featureIndex;
+  OffsetTo<Feature, ULONG>      feature;
+  public:
+  DEFINE_SIZE_STATIC (6);
+};
+
+struct FeatureTableSubstitution
+{
+  inline const Feature *find_substitute (unsigned int feature_index) const
+  {
+    unsigned int count = substitutions.len;
+    for (unsigned int i = 0; i < count; i++)
+    {
+      const FeatureTableSubstitutionRecord &record = substitutions.array[i];
+      if (record.featureIndex == feature_index)
+        return &(this+record.feature);
+    }
+    return NULL;
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (version.sanitize (c) &&
+                  likely (version.major == 1) &&
+                  substitutions.sanitize (c, this));
+  }
+
+  protected:
+  FixedVersion<>        version;        /* Version--0x00010000u */
+  ArrayOf<FeatureTableSubstitutionRecord>
+                        substitutions;
+  public:
+  DEFINE_SIZE_ARRAY (6, substitutions);
+};
+
+struct FeatureVariationRecord
+{
+  friend struct FeatureVariations;
+
+  inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (conditions.sanitize (c, base) &&
+                  substitutions.sanitize (c, base));
+  }
+
+  protected:
+  OffsetTo<ConditionSet, ULONG>
+                        conditions;
+  OffsetTo<FeatureTableSubstitution, ULONG>
+                        substitutions;
+  public:
+  DEFINE_SIZE_STATIC (8);
+};
+
+struct FeatureVariations
+{
+  static const unsigned int NOT_FOUND_INDEX = 0xFFFFFFFFu;
+
+  inline bool find_index (const int *coords, unsigned int coord_len,
+                          unsigned int *index) const
+  {
+    unsigned int count = varRecords.len;
+    for (unsigned int i = 0; i < count; i++)
+    {
+      const FeatureVariationRecord &record = varRecords.array[i];
+      if ((this+record.conditions).evaluate (coords, coord_len))
+      {
+        *index = i;
+        return true;
+      }
+    }
+    *index = NOT_FOUND_INDEX;
+    return false;
+  }
+
+  inline const Feature *find_substitute (unsigned int variations_index,
+                                         unsigned int feature_index) const
+  {
+    const FeatureVariationRecord &record = varRecords[variations_index];
+    return (this+record.substitutions).find_substitute (feature_index);
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (version.sanitize (c) &&
+                  likely (version.major == 1) &&
+                  varRecords.sanitize (c, this));
+  }
+
+  protected:
+  FixedVersion<>        version;        /* Version--0x00010000u */
+  ArrayOf<FeatureVariationRecord, ULONG>
+                        varRecords;
+  public:
+  DEFINE_SIZE_ARRAY (8, varRecords);
+};
+
+
+/*
  * Device Tables
  */
 
-struct Device
+struct HintingDevice
 {
+  friend struct Device;
+
+  private:
 
   inline hb_position_t get_x_delta (hb_font_t *font) const
   { return get_delta (font->x_ppem, font->x_scale); }
@@ -1235,6 +1611,101 @@
   DEFINE_SIZE_ARRAY (6, deltaValue);
 };
 
+struct VariationDevice
+{
+  friend struct Device;
+
+  private:
+
+  inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store) const
+  { return font->em_scalef_x (get_delta (font, store)); }
+
+  inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store) const
+  { return font->em_scalef_y (get_delta (font, store)); }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (c->check_struct (this));
+  }
+
+  private:
+
+  inline float get_delta (hb_font_t *font, const VariationStore &store) const
+  {
+    return store.get_delta (outerIndex, innerIndex, font->coords, font->num_coords);
+  }
+
+  protected:
+  USHORT        outerIndex;
+  USHORT        innerIndex;
+  USHORT        deltaFormat;    /* Format identifier for this table: 0x0x8000 */
+  public:
+  DEFINE_SIZE_STATIC (6);
+};
+
+struct DeviceHeader
+{
+  protected:
+  USHORT                reserved1;
+  USHORT                reserved2;
+  public:
+  USHORT                format;         /* Format identifier */
+  public:
+  DEFINE_SIZE_STATIC (6);
+};
+
+struct Device
+{
+  inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store=Null(VariationStore)) const
+  {
+    switch (u.b.format)
+    {
+    case 1: case 2: case 3:
+      return u.hinting.get_x_delta (font);
+    case 0x8000:
+      return u.variation.get_x_delta (font, store);
+    default:
+      return 0;
+    }
+  }
+  inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store=Null(VariationStore)) const
+  {
+    switch (u.b.format)
+    {
+    case 1: case 2: case 3:
+      return u.hinting.get_y_delta (font);
+    case 0x8000:
+      return u.variation.get_y_delta (font, store);
+    default:
+      return 0;
+    }
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    if (!u.b.format.sanitize (c)) return_trace (false);
+    switch (u.b.format) {
+    case 1: case 2: case 3:
+      return_trace (u.hinting.sanitize (c));
+    case 0x8000:
+      return_trace (u.variation.sanitize (c));
+    default:
+      return_trace (true);
+    }
+  }
+
+  protected:
+  union {
+  DeviceHeader          b;
+  HintingDevice         hinting;
+  VariationDevice       variation;
+  } u;
+  public:
+  DEFINE_SIZE_UNION (6, b);
+};
+
 
 } /* namespace OT */
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gdef-table.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gdef-table.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -97,7 +97,7 @@
   friend struct CaretValue;
 
   private:
-  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const
+  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction) const
   {
     return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate) : font->em_scale_y (coordinate);
   }
@@ -146,11 +146,11 @@
 {
   friend struct CaretValue;
 
-  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const
+  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, const VariationStore &var_store) const
   {
     return HB_DIRECTION_IS_HORIZONTAL (direction) ?
-           font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font) :
-           font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font);
+           font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font, var_store) :
+           font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font, var_store);
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -172,12 +172,15 @@
 
 struct CaretValue
 {
-  inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
+  inline hb_position_t get_caret_value (hb_font_t *font,
+                                        hb_direction_t direction,
+                                        hb_codepoint_t glyph_id,
+                                        const VariationStore &var_store) const
   {
     switch (u.format) {
-    case 1: return u.format1.get_caret_value (font, direction, glyph_id);
+    case 1: return u.format1.get_caret_value (font, direction);
     case 2: return u.format2.get_caret_value (font, direction, glyph_id);
-    case 3: return u.format3.get_caret_value (font, direction, glyph_id);
+    case 3: return u.format3.get_caret_value (font, direction, var_store);
     default:return 0;
     }
   }
@@ -210,6 +213,7 @@
   inline unsigned int get_lig_carets (hb_font_t *font,
                                       hb_direction_t direction,
                                       hb_codepoint_t glyph_id,
+                                      const VariationStore &var_store,
                                       unsigned int start_offset,
                                       unsigned int *caret_count /* IN/OUT */,
                                       hb_position_t *caret_array /* OUT */) const
@@ -218,7 +222,7 @@
       const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_count);
       unsigned int count = *caret_count;
       for (unsigned int i = 0; i < count; i++)
-        caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id);
+        caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id, var_store);
     }
 
     return carets.len;
@@ -244,6 +248,7 @@
   inline unsigned int get_lig_carets (hb_font_t *font,
                                       hb_direction_t direction,
                                       hb_codepoint_t glyph_id,
+                                      const VariationStore &var_store,
                                       unsigned int start_offset,
                                       unsigned int *caret_count /* IN/OUT */,
                                       hb_position_t *caret_array /* OUT */) const
@@ -256,7 +261,7 @@
       return 0;
     }
     const LigGlyph &lig_glyph = this+ligGlyph[index];
-    return lig_glyph.get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array);
+    return lig_glyph.get_lig_carets (font, direction, glyph_id, var_store, start_offset, caret_count, caret_array);
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -367,11 +372,17 @@
                                       unsigned int start_offset,
                                       unsigned int *caret_count /* IN/OUT */,
                                       hb_position_t *caret_array /* OUT */) const
-  { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array); }
+  { return (this+ligCaretList).get_lig_carets (font,
+                                               direction, glyph_id, get_var_store(),
+                                               start_offset, caret_count, caret_array); }
 
-  inline bool has_mark_sets (void) const { return version.to_int () >= 0x00010002u && markGlyphSetsDef[0] != 0; }
+  inline bool has_mark_sets (void) const { return version.to_int () >= 0x00010002u && markGlyphSetsDef != 0; }
   inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
-  { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
+  { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef).covers (set_index, glyph_id); }
+
+  inline bool has_var_store (void) const { return version.to_int () >= 0x00010003u && varStore != 0; }
+  inline const VariationStore &get_var_store (void) const
+  { return version.to_int () >= 0x00010003u ? this+varStore : Null(VariationStore); }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
@@ -382,10 +393,10 @@
                   attachList.sanitize (c, this) &&
                   ligCaretList.sanitize (c, this) &&
                   markAttachClassDef.sanitize (c, this) &&
-                  (version.to_int () < 0x00010002u || markGlyphSetsDef[0].sanitize (c, this)));
+                  (version.to_int () < 0x00010002u || markGlyphSetsDef.sanitize (c, this)) &&
+                  (version.to_int () < 0x00010003u || varStore.sanitize (c, this)));
   }
 
-
   /* glyph_props is a 16-bit integer where the lower 8-bit have bits representing
    * glyph class and other bits, and high 8-bit gthe mark attachment type (if any).
    * Not to be confused with lookup_props which is very similar. */
@@ -410,7 +421,7 @@
 
   protected:
   FixedVersion<>version;                /* Version of the GDEF table--currently
-                                         * 0x00010002u */
+                                         * 0x00010003u */
   OffsetTo<ClassDef>
                 glyphClassDef;          /* Offset to class definition table
                                          * for glyph type--from beginning of
@@ -428,12 +439,17 @@
                                          * mark attachment type--from beginning
                                          * of GDEF header (may be Null) */
   OffsetTo<MarkGlyphSets>
-                markGlyphSetsDef[VAR];  /* Offset to the table of mark set
+                markGlyphSetsDef;       /* Offset to the table of mark set
                                          * definitions--from beginning of GDEF
                                          * header (may be NULL).  Introduced
-                                         * in version 00010002. */
+                                         * in version 0x00010002. */
+  OffsetTo<VariationStore, ULONG>
+                varStore;               /* Offset to the table of Item Variation
+                                         * Store--from beginning of GDEF
+                                         * header (may be NULL).  Introduced
+                                         * in version 0x00010003. */
   public:
-  DEFINE_SIZE_ARRAY (12, markGlyphSetsDef);
+  DEFINE_SIZE_MIN (12);
 };
 
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gpos-table.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gpos-table.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -103,17 +103,16 @@
   inline unsigned int get_size (void) const
   { return get_len () * Value::static_size; }
 
-  void apply_value (hb_font_t            *font,
-                    hb_direction_t        direction,
+  void apply_value (hb_apply_context_t   *c,
                     const void           *base,
                     const Value          *values,
                     hb_glyph_position_t  &glyph_pos) const
   {
-    unsigned int x_ppem, y_ppem;
     unsigned int format = *this;
-    hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (direction);
+    if (!format) return;
 
-    if (!format) return;
+    hb_font_t *font = c->font;
+    hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (c->direction);
 
     if (format & xPlacement) glyph_pos.x_offset  += font->em_scale_x (get_short (values++));
     if (format & yPlacement) glyph_pos.y_offset  += font->em_scale_y (get_short (values++));
@@ -129,27 +128,29 @@
 
     if (!has_device ()) return;
 
-    x_ppem = font->x_ppem;
-    y_ppem = font->y_ppem;
+    bool use_x_device = font->x_ppem || font->num_coords;
+    bool use_y_device = font->y_ppem || font->num_coords;
 
-    if (!x_ppem && !y_ppem) return;
+    if (!use_x_device && !use_y_device) return;
+
+    const VariationStore &store = c->var_store;
 
     /* pixel -> fractional pixel */
     if (format & xPlaDevice) {
-      if (x_ppem) glyph_pos.x_offset  += (base + get_device (values)).get_x_delta (font);
+      if (use_x_device) glyph_pos.x_offset  += (base + get_device (values)).get_x_delta (font, store);
       values++;
     }
     if (format & yPlaDevice) {
-      if (y_ppem) glyph_pos.y_offset  += (base + get_device (values)).get_y_delta (font);
+      if (use_y_device) glyph_pos.y_offset  += (base + get_device (values)).get_y_delta (font, store);
       values++;
     }
     if (format & xAdvDevice) {
-      if (horizontal && x_ppem) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font);
+      if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font, store);
       values++;
     }
     if (format & yAdvDevice) {
       /* y_advance values grow downward but font-space grows upward, hence negation */
-      if (!horizontal && y_ppem) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font);
+      if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font, store);
       values++;
     }
   }
@@ -231,11 +232,12 @@
 
 struct AnchorFormat1
 {
-  inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
+  inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
                           hb_position_t *x, hb_position_t *y) const
   {
-      *x = font->em_scale_x (xCoordinate);
-      *y = font->em_scale_y (yCoordinate);
+    hb_font_t *font = c->font;
+    *x = font->em_scale_x (xCoordinate);
+    *y = font->em_scale_y (yCoordinate);
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -254,18 +256,19 @@
 
 struct AnchorFormat2
 {
-  inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id,
+  inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id,
                           hb_position_t *x, hb_position_t *y) const
   {
-      unsigned int x_ppem = font->x_ppem;
-      unsigned int y_ppem = font->y_ppem;
-      hb_position_t cx, cy;
-      hb_bool_t ret;
+    hb_font_t *font = c->font;
+    unsigned int x_ppem = font->x_ppem;
+    unsigned int y_ppem = font->y_ppem;
+    hb_position_t cx, cy;
+    hb_bool_t ret;
 
-      ret = (x_ppem || y_ppem) &&
-             font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy);
-      *x = ret && x_ppem ? cx : font->em_scale_x (xCoordinate);
-      *y = ret && y_ppem ? cy : font->em_scale_y (yCoordinate);
+    ret = (x_ppem || y_ppem) &&
+           font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy);
+    *x = ret && x_ppem ? cx : font->em_scale_x (xCoordinate);
+    *y = ret && y_ppem ? cy : font->em_scale_y (yCoordinate);
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -285,16 +288,17 @@
 
 struct AnchorFormat3
 {
-  inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
+  inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
                           hb_position_t *x, hb_position_t *y) const
   {
-      *x = font->em_scale_x (xCoordinate);
-      *y = font->em_scale_y (yCoordinate);
+    hb_font_t *font = c->font;
+    *x = font->em_scale_x (xCoordinate);
+    *y = font->em_scale_y (yCoordinate);
 
-      if (font->x_ppem)
-        *x += (this+xDeviceTable).get_x_delta (font);
-      if (font->y_ppem)
-        *y += (this+yDeviceTable).get_x_delta (font);
+    if (font->x_ppem || font->num_coords)
+      *x += (this+xDeviceTable).get_x_delta (font, c->var_store);
+    if (font->y_ppem || font->num_coords)
+      *y += (this+yDeviceTable).get_y_delta (font, c->var_store);
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -321,14 +325,14 @@
 
 struct Anchor
 {
-  inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id,
+  inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id,
                           hb_position_t *x, hb_position_t *y) const
   {
     *x = *y = 0;
     switch (u.format) {
-    case 1: u.format1.get_anchor (font, glyph_id, x, y); return;
-    case 2: u.format2.get_anchor (font, glyph_id, x, y); return;
-    case 3: u.format3.get_anchor (font, glyph_id, x, y); return;
+    case 1: u.format1.get_anchor (c, glyph_id, x, y); return;
+    case 2: u.format2.get_anchor (c, glyph_id, x, y); return;
+    case 3: u.format3.get_anchor (c, glyph_id, x, y); return;
     default:                                             return;
     }
   }
@@ -370,7 +374,7 @@
   {
     TRACE_SANITIZE (this);
     if (!c->check_struct (this)) return_trace (false);
-    if (unlikely (rows > 0 && cols >= ((unsigned int) -1) / rows)) return_trace (false);
+    if (unlikely (_hb_unsigned_int_mul_overflows (rows, cols))) return_trace (false);
     unsigned int count = rows * cols;
     if (!c->check_array (matrixZ, matrixZ[0].static_size, count)) return_trace (false);
     for (unsigned int i = 0; i < count; i++)
@@ -428,8 +432,8 @@
 
     hb_position_t mark_x, mark_y, base_x, base_y;
 
-    mark_anchor.get_anchor (c->font, buffer->cur().codepoint, &mark_x, &mark_y);
-    glyph_anchor.get_anchor (c->font, buffer->info[glyph_pos].codepoint, &base_x, &base_y);
+    mark_anchor.get_anchor (c, buffer->cur().codepoint, &mark_x, &mark_y);
+    glyph_anchor.get_anchor (c, buffer->info[glyph_pos].codepoint, &base_x, &base_y);
 
     hb_glyph_position_t &o = buffer->cur_pos();
     o.x_offset = base_x - mark_x;
@@ -472,8 +476,7 @@
     unsigned int index = (this+coverage).get_coverage  (buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return_trace (false);
 
-    valueFormat.apply_value (c->font, c->direction, this,
-                             values, buffer->cur_pos());
+    valueFormat.apply_value (c, this, values, buffer->cur_pos());
 
     buffer->idx++;
     return_trace (true);
@@ -523,7 +526,7 @@
 
     if (likely (index >= valueCount)) return_trace (false);
 
-    valueFormat.apply_value (c->font, c->direction, this,
+    valueFormat.apply_value (c, this,
                              &values[index * valueFormat.get_len ()],
                              buffer->cur_pos());
 
@@ -640,10 +643,8 @@
         min = mid + 1;
       else
       {
-        valueFormats[0].apply_value (c->font, c->direction, this,
-                                     &record->values[0], buffer->cur_pos());
-        valueFormats[1].apply_value (c->font, c->direction, this,
-                                     &record->values[len1], buffer->pos[pos]);
+        valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos());
+        valueFormats[1].apply_value (c, this, &record->values[len1], buffer->pos[pos]);
         if (len2)
           pos++;
         buffer->idx = pos;
@@ -689,7 +690,7 @@
     (this+coverage).add_coverage (c->input);
     unsigned int count = pairSet.len;
     for (unsigned int i = 0; i < count; i++)
-      (this+pairSet[i]).collect_glyphs (c, &valueFormat1);
+      (this+pairSet[i]).collect_glyphs (c, valueFormat);
   }
 
   inline const Coverage &get_coverage (void) const
@@ -708,7 +709,7 @@
     skippy_iter.reset (buffer->idx, 1);
     if (!skippy_iter.next ()) return_trace (false);
 
-    return_trace ((this+pairSet[index]).apply (c, &valueFormat1, skippy_iter.idx));
+    return_trace ((this+pairSet[index]).apply (c, valueFormat, skippy_iter.idx));
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -717,11 +718,11 @@
 
     if (!c->check_struct (this)) return_trace (false);
 
-    unsigned int len1 = valueFormat1.get_len ();
-    unsigned int len2 = valueFormat2.get_len ();
+    unsigned int len1 = valueFormat[0].get_len ();
+    unsigned int len2 = valueFormat[1].get_len ();
     PairSet::sanitize_closure_t closure = {
       this,
-      &valueFormat1,
+      valueFormat,
       len1,
       1 + len1 + len2
     };
@@ -734,10 +735,10 @@
   OffsetTo<Coverage>
                 coverage;               /* Offset to Coverage table--from
                                          * beginning of subtable */
-  ValueFormat   valueFormat1;           /* Defines the types of data in
+  ValueFormat   valueFormat[2];         /* [0] Defines the types of data in
                                          * ValueRecord1--for the first glyph
                                          * in the pair--may be zero (0) */
-  ValueFormat   valueFormat2;           /* Defines the types of data in
+                                        /* [1] Defines the types of data in
                                          * ValueRecord2--for the second glyph
                                          * in the pair--may be zero (0) */
   OffsetArrayOf<PairSet>
@@ -790,10 +791,8 @@
     if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return_trace (false);
 
     const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
-    valueFormat1.apply_value (c->font, c->direction, this,
-                              v, buffer->cur_pos());
-    valueFormat2.apply_value (c->font, c->direction, this,
-                              v + len1, buffer->pos[skippy_iter.idx]);
+    valueFormat1.apply_value (c, this, v, buffer->cur_pos());
+    valueFormat2.apply_value (c, this, v + len1, buffer->pos[skippy_iter.idx]);
 
     buffer->idx = skippy_iter.idx;
     if (len2)
@@ -931,8 +930,8 @@
     unsigned int j = skippy_iter.idx;
 
     hb_position_t entry_x, entry_y, exit_x, exit_y;
-    (this+this_record.exitAnchor).get_anchor (c->font, buffer->info[i].codepoint, &exit_x, &exit_y);
-    (this+next_record.entryAnchor).get_anchor (c->font, buffer->info[j].codepoint, &entry_x, &entry_y);
+    (this+this_record.exitAnchor).get_anchor (c, buffer->info[i].codepoint, &exit_x, &exit_y);
+    (this+next_record.entryAnchor).get_anchor (c, buffer->info[j].codepoint, &entry_x, &entry_y);
 
     hb_glyph_position_t *pos = buffer->pos;
 
@@ -1519,8 +1518,6 @@
     const OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
     return_trace (list.sanitize (c, this));
   }
-  public:
-  DEFINE_SIZE_STATIC (10);
 };
 
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsub-table.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsub-table.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -41,7 +41,10 @@
   {
     TRACE_CLOSURE (this);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      /* TODO Switch to range-based API to work around malicious fonts.
+       * https://github.com/behdad/harfbuzz/issues/363 */
       hb_codepoint_t glyph_id = iter.get_glyph ();
       if (c->glyphs->has (glyph_id))
         c->glyphs->add ((glyph_id + deltaGlyphID) & 0xFFFFu);
@@ -52,7 +55,10 @@
   {
     TRACE_COLLECT_GLYPHS (this);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      /* TODO Switch to range-based API to work around malicious fonts.
+       * https://github.com/behdad/harfbuzz/issues/363 */
       hb_codepoint_t glyph_id = iter.get_glyph ();
       c->input->add (glyph_id);
       c->output->add ((glyph_id + deltaGlyphID) & 0xFFFFu);
@@ -120,7 +126,11 @@
   {
     TRACE_CLOSURE (this);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    unsigned int count = substitute.len;
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      if (unlikely (iter.get_coverage () >= count))
+        break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
       if (c->glyphs->has (iter.get_glyph ()))
         c->glyphs->add (substitute[iter.get_coverage ()]);
     }
@@ -130,7 +140,11 @@
   {
     TRACE_COLLECT_GLYPHS (this);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    unsigned int count = substitute.len;
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      if (unlikely (iter.get_coverage () >= count))
+        break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
       c->input->add (iter.get_glyph ());
       c->output->add (substitute[iter.get_coverage ()]);
     }
@@ -321,7 +335,11 @@
   {
     TRACE_CLOSURE (this);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    unsigned int count = sequence.len;
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      if (unlikely (iter.get_coverage () >= count))
+        break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
       if (c->glyphs->has (iter.get_glyph ()))
         (this+sequence[iter.get_coverage ()]).closure (c);
     }
@@ -439,7 +457,11 @@
   {
     TRACE_CLOSURE (this);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    unsigned int count = alternateSet.len;
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      if (unlikely (iter.get_coverage () >= count))
+        break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
       if (c->glyphs->has (iter.get_glyph ())) {
         const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()];
         unsigned int count = alt_set.len;
@@ -453,7 +475,11 @@
   {
     TRACE_COLLECT_GLYPHS (this);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    unsigned int count = alternateSet.len;
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      if (unlikely (iter.get_coverage () >= count))
+        break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
       c->input->add (iter.get_glyph ());
       const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()];
       unsigned int count = alt_set.len;
@@ -762,7 +788,11 @@
   {
     TRACE_CLOSURE (this);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    unsigned int count = ligatureSet.len;
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      if (unlikely (iter.get_coverage () >= count))
+        break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
       if (c->glyphs->has (iter.get_glyph ()))
         (this+ligatureSet[iter.get_coverage ()]).closure (c);
     }
@@ -772,7 +802,11 @@
   {
     TRACE_COLLECT_GLYPHS (this);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    unsigned int count = ligatureSet.len;
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      if (unlikely (iter.get_coverage () >= count))
+        break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
       c->input->add (iter.get_glyph ());
       (this+ligatureSet[iter.get_coverage ()]).collect_glyphs (c);
     }
@@ -923,7 +957,11 @@
 
     const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
     Coverage::Iter iter;
-    for (iter.init (this+coverage); iter.more (); iter.next ()) {
+    count = substitute.len;
+    for (iter.init (this+coverage); iter.more (); iter.next ())
+    {
+      if (unlikely (iter.get_coverage () >= count))
+        break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
       if (c->glyphs->has (iter.get_glyph ()))
         c->glyphs->add (substitute[iter.get_coverage ()]);
     }
@@ -1273,8 +1311,6 @@
     const OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList);
     return_trace (list.sanitize (c, this));
   }
-  public:
-  DEFINE_SIZE_STATIC (10);
 };
 
 
@@ -1285,28 +1321,10 @@
 
   const GDEF &gdef = *hb_ot_layout_from_face (font->face)->gdef;
   unsigned int count = buffer->len;
-  hb_glyph_info_t *info = buffer->info;
   for (unsigned int i = 0; i < count; i++)
   {
-    unsigned int props = gdef.get_glyph_props (info[i].codepoint);
-    if (!props)
-    {
-      /* Never mark default-ignorables as marks.
-       * They won't get in the way of lookups anyway,
-       * but having them as mark will cause them to be skipped
-       * over if the lookup-flag says so, but at least for the
-       * Mongolian variation selectors, looks like Uniscribe
-       * marks them as non-mark.  Some Mongolian fonts without
-       * GDEF rely on this.  Another notable character that
-       * this applies to is COMBINING GRAPHEME JOINER. */
-      props = (_hb_glyph_info_get_general_category (&info[i]) !=
-               HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK ||
-               _hb_glyph_info_is_default_ignorable (&info[i])) ?
-              HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH :
-              HB_OT_LAYOUT_GLYPH_PROPS_MARK;
-    }
-    _hb_glyph_info_set_glyph_props (&info[i], props);
-    _hb_glyph_info_clear_lig_props (&info[i]);
+    _hb_glyph_info_set_glyph_props (&buffer->info[i], gdef.get_glyph_props (buffer->info[i].codepoint));
+    _hb_glyph_info_clear_lig_props (&buffer->info[i]);
     buffer->info[i].syllable() = 0;
   }
 }
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -469,6 +469,7 @@
   unsigned int lookup_props;
   const GDEF &gdef;
   bool has_glyph_classes;
+  const VariationStore &var_store;
   skipping_iterator_t iter_input, iter_context;
   unsigned int lookup_index;
   unsigned int debug_depth;
@@ -487,6 +488,7 @@
                         lookup_props (0),
                         gdef (*hb_ot_layout_from_face (face)->gdef),
                         has_glyph_classes (gdef.has_glyph_classes ()),
+                        var_store (gdef.get_var_store ()),
                         iter_input (),
                         iter_context (),
                         lookup_index ((unsigned int) -1),
@@ -999,8 +1001,12 @@
     end = int (end) + delta;
     if (end <= match_positions[idx])
     {
+      /* End might end up being smaller than match_positions[idx] if the recursed
+       * lookup ended up removing many items, more than we have had matched.
+       * Just never rewind end back and get out of here.
+       * https://bugs.chromium.org/p/chromium/issues/detail?id=659496 */
+      end = match_positions[idx];
       /* There can't be any further changes. */
-      assert (end == match_positions[idx]);
       break;
     }
 
@@ -2269,6 +2275,24 @@
   inline const Lookup& get_lookup (unsigned int i) const
   { return (this+lookupList)[i]; }
 
+  inline bool find_variations_index (const int *coords, unsigned int num_coords,
+                                     unsigned int *index) const
+  { return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations))
+           .find_index (coords, num_coords, index); }
+  inline const Feature& get_feature_variation (unsigned int feature_index,
+                                               unsigned int variations_index) const
+  {
+    if (FeatureVariations::NOT_FOUND_INDEX != variations_index &&
+        version.to_int () >= 0x00010001u)
+    {
+      const Feature *feature = (this+featureVars).find_substitute (variations_index,
+                                                                   feature_index);
+      if (feature)
+        return *feature;
+    }
+    return get_feature (feature_index);
+  }
+
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
@@ -2276,7 +2300,8 @@
                   likely (version.major == 1) &&
                   scriptList.sanitize (c, this) &&
                   featureList.sanitize (c, this) &&
-                  lookupList.sanitize (c, this));
+                  lookupList.sanitize (c, this) &&
+                  (version.to_int () < 0x00010001u || featureVars.sanitize (c, this)));
   }
 
   protected:
@@ -2288,8 +2313,13 @@
                 featureList;    /* FeatureList table */
   OffsetTo<LookupList>
                 lookupList;     /* LookupList table */
+  OffsetTo<FeatureVariations, ULONG>
+                featureVars;    /* Offset to Feature Variations
+                                   table--from beginning of table
+                                 * (may be NULL).  Introduced
+                                 * in version 0x00010001. */
   public:
-  DEFINE_SIZE_STATIC (10);
+  DEFINE_SIZE_MIN (10);
 };
 
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -124,6 +124,7 @@
   struct GDEF;
   struct GSUB;
   struct GPOS;
+  struct MATH;
 }
 
 struct hb_ot_layout_lookup_accelerator_t
@@ -152,10 +153,12 @@
   hb_blob_t *gdef_blob;
   hb_blob_t *gsub_blob;
   hb_blob_t *gpos_blob;
+  hb_blob_t *math_blob;
 
   const struct OT::GDEF *gdef;
   const struct OT::GSUB *gsub;
   const struct OT::GPOS *gpos;
+  const struct OT::MATH *math;
 
   unsigned int gsub_lookup_count;
   unsigned int gpos_lookup_count;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -60,6 +60,10 @@
   layout->gpos_blob = OT::Sanitizer<OT::GPOS>::sanitize (face->reference_table (HB_OT_TAG_GPOS));
   layout->gpos = OT::Sanitizer<OT::GPOS>::lock_instance (layout->gpos_blob);
 
+  /* The MATH table is rarely used, so only try and load it in _get_math. */
+  layout->math_blob = NULL;
+  layout->math = NULL;
+
   {
     /*
      * The ugly business of blacklisting individual fonts' tables happen here!
@@ -120,6 +124,14 @@
       /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f  cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */
       /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b  cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */
       || (188 == gdef_len && 3426 == gpos_len && 264 == gsub_len)
+      /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */
+      || (1046 == gdef_len && 17112 == gpos_len && 71788 == gsub_len)
+      /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */
+      || (1058 == gdef_len && 17514 == gpos_len && 71794 == gsub_len)
+      /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */
+      || (1330 == gdef_len && 57938 == gpos_len && 109904 == gsub_len)
+      /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */
+      || (1330 == gdef_len && 58972 == gpos_len && 109904 == gsub_len)
     )
     {
       /* Many versions of Tahoma have bad GDEF tables that incorrectly classify some spacing marks
@@ -169,6 +181,7 @@
   hb_blob_destroy (layout->gdef_blob);
   hb_blob_destroy (layout->gsub_blob);
   hb_blob_destroy (layout->gpos_blob);
+  hb_blob_destroy (layout->math_blob);
 
   free (layout);
 }
@@ -192,7 +205,6 @@
   return *hb_ot_layout_from_face (face)->gpos;
 }
 
-
 /*
  * GDEF
  */
@@ -544,10 +556,13 @@
                                   unsigned int *lookup_count /* IN/OUT */,
                                   unsigned int *lookup_indexes /* OUT */)
 {
-  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
-  const OT::Feature &f = g.get_feature (feature_index);
-
-  return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes);
+  return hb_ot_layout_feature_with_variations_get_lookups (face,
+                                                           table_tag,
+                                                           feature_index,
+                                                           HB_OT_LAYOUT_NO_VARIATIONS_INDEX,
+                                                           start_offset,
+                                                           lookup_count,
+                                                           lookup_indexes);
 }
 
 /**
@@ -798,6 +813,38 @@
 }
 
 
+/* Variations support */
+
+hb_bool_t
+hb_ot_layout_table_find_feature_variations (hb_face_t    *face,
+                                            hb_tag_t      table_tag,
+                                            const int    *coords,
+                                            unsigned int  num_coords,
+                                            unsigned int *variations_index /* out */)
+{
+  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
+
+  return g.find_variations_index (coords, num_coords, variations_index);
+}
+
+unsigned int
+hb_ot_layout_feature_with_variations_get_lookups (hb_face_t    *face,
+                                                  hb_tag_t      table_tag,
+                                                  unsigned int  feature_index,
+                                                  unsigned int  variations_index,
+                                                  unsigned int  start_offset,
+                                                  unsigned int *lookup_count /* IN/OUT */,
+                                                  unsigned int *lookup_indexes /* OUT */)
+{
+  ASSERT_STATIC (OT::FeatureVariations::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_VARIATIONS_INDEX);
+  const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
+
+  const OT::Feature &f = g.get_feature_variation (feature_index, variations_index);
+
+  return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes);
+}
+
+
 /*
  * OT::GSUB
  */
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.h	Tue Jan 24 00:30:25 2017 +0100
@@ -95,6 +95,7 @@
 #define HB_OT_LAYOUT_NO_SCRIPT_INDEX            0xFFFFu
 #define HB_OT_LAYOUT_NO_FEATURE_INDEX           0xFFFFu
 #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX     0xFFFFu
+#define HB_OT_LAYOUT_NO_VARIATIONS_INDEX        0xFFFFFFFFu
 
 HB_EXTERN unsigned int
 hb_ot_layout_table_get_script_tags (hb_face_t    *face,
@@ -236,6 +237,24 @@
                                          void         *user_data);
 #endif
 
+/* Variations support */
+
+HB_EXTERN hb_bool_t
+hb_ot_layout_table_find_feature_variations (hb_face_t    *face,
+                                            hb_tag_t      table_tag,
+                                            const int    *coords,
+                                            unsigned int  num_coords,
+                                            unsigned int *variations_index /* out */);
+
+HB_EXTERN unsigned int
+hb_ot_layout_feature_with_variations_get_lookups (hb_face_t    *face,
+                                                  hb_tag_t      table_tag,
+                                                  unsigned int  feature_index,
+                                                  unsigned int  variations_index,
+                                                  unsigned int  start_offset,
+                                                  unsigned int *lookup_count /* IN/OUT */,
+                                                  unsigned int *lookup_indexes /* OUT */);
+
 
 /*
  * GSUB
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -139,12 +139,6 @@
 
   private:
 
-  HB_INTERNAL void add_lookups (hb_face_t    *face,
-                                unsigned int  table_index,
-                                unsigned int  feature_index,
-                                hb_mask_t     mask,
-                                bool          auto_zwj);
-
   hb_mask_t global_mask;
 
   hb_prealloced_array_t<feature_map_t, 8> features;
@@ -182,7 +176,9 @@
   inline void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func)
   { add_pause (1, pause_func); }
 
-  HB_INTERNAL void compile (struct hb_ot_map_t &m);
+  HB_INTERNAL void compile (hb_ot_map_t  &m,
+                            const int    *coords,
+                            unsigned int  num_coords);
 
   inline void finish (void) {
     feature_infos.finish ();
@@ -194,6 +190,14 @@
 
   private:
 
+  HB_INTERNAL void add_lookups (hb_ot_map_t  &m,
+                                hb_face_t    *face,
+                                unsigned int  table_index,
+                                unsigned int  feature_index,
+                                unsigned int  variations_index,
+                                hb_mask_t     mask,
+                                bool          auto_zwj);
+
   struct feature_info_t {
     hb_tag_t tag;
     unsigned int seq; /* sequence#, used for stable sorting only */
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -31,43 +31,12 @@
 #include "hb-ot-layout-private.hh"
 
 
-void
-hb_ot_map_t::add_lookups (hb_face_t    *face,
-                          unsigned int  table_index,
-                          unsigned int  feature_index,
-                          hb_mask_t     mask,
-                          bool          auto_zwj)
+void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const
 {
-  unsigned int lookup_indices[32];
-  unsigned int offset, len;
-  unsigned int table_lookup_count;
-
-  table_lookup_count = hb_ot_layout_table_get_lookup_count (face, table_tags[table_index]);
+  for (unsigned int i = 0; i < lookups[table_index].len; i++)
+    hb_set_add (lookups_out, lookups[table_index][i].index);
+}
 
-  offset = 0;
-  do {
-    len = ARRAY_LENGTH (lookup_indices);
-    hb_ot_layout_feature_get_lookups (face,
-                                      table_tags[table_index],
-                                      feature_index,
-                                      offset, &len,
-                                      lookup_indices);
-
-    for (unsigned int i = 0; i < len; i++)
-    {
-      if (lookup_indices[i] >= table_lookup_count)
-        continue;
-      hb_ot_map_t::lookup_map_t *lookup = lookups[table_index].push ();
-      if (unlikely (!lookup))
-        return;
-      lookup->mask = mask;
-      lookup->index = lookup_indices[i];
-      lookup->auto_zwj = auto_zwj;
-    }
-
-    offset += len;
-  } while (len == ARRAY_LENGTH (lookup_indices));
-}
 
 hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_,
                                           const hb_segment_properties_t *props_)
@@ -109,13 +78,48 @@
   info->stage[1] = current_stage[1];
 }
 
-
-void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const
+void
+hb_ot_map_builder_t::add_lookups (hb_ot_map_t  &m,
+                                  hb_face_t    *face,
+                                  unsigned int  table_index,
+                                  unsigned int  feature_index,
+                                  unsigned int  variations_index,
+                                  hb_mask_t     mask,
+                                  bool          auto_zwj)
 {
-  for (unsigned int i = 0; i < lookups[table_index].len; i++)
-    hb_set_add (lookups_out, lookups[table_index][i].index);
+  unsigned int lookup_indices[32];
+  unsigned int offset, len;
+  unsigned int table_lookup_count;
+
+  table_lookup_count = hb_ot_layout_table_get_lookup_count (face, table_tags[table_index]);
+
+  offset = 0;
+  do {
+    len = ARRAY_LENGTH (lookup_indices);
+    hb_ot_layout_feature_with_variations_get_lookups (face,
+                                                      table_tags[table_index],
+                                                      feature_index,
+                                                      variations_index,
+                                                      offset, &len,
+                                                      lookup_indices);
+
+    for (unsigned int i = 0; i < len; i++)
+    {
+      if (lookup_indices[i] >= table_lookup_count)
+        continue;
+      hb_ot_map_t::lookup_map_t *lookup = m.lookups[table_index].push ();
+      if (unlikely (!lookup))
+        return;
+      lookup->mask = mask;
+      lookup->index = lookup_indices[i];
+      lookup->auto_zwj = auto_zwj;
+    }
+
+    offset += len;
+  } while (len == ARRAY_LENGTH (lookup_indices));
 }
 
+
 void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func)
 {
   stage_info_t *s = stages[table_index].push ();
@@ -128,7 +132,9 @@
 }
 
 void
-hb_ot_map_builder_t::compile (hb_ot_map_t &m)
+hb_ot_map_builder_t::compile (hb_ot_map_t  &m,
+                              const int    *coords,
+                              unsigned int  num_coords)
 {
   m.global_mask = 1;
 
@@ -193,7 +199,8 @@
       /* Uses the global bit */
       bits_needed = 0;
     else
-      bits_needed = _hb_bit_storage (info->max_value);
+      /* Limit to 8 bits per feature. */
+      bits_needed = MIN(8u, _hb_bit_storage (info->max_value));
 
     if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t))
       continue; /* Feature disabled, or not enough bits. */
@@ -243,11 +250,11 @@
       map->mask = 1;
     } else {
       map->shift = next_bit;
-      map->mask = (1 << (next_bit + bits_needed)) - (1 << next_bit);
+      map->mask = (1u << (next_bit + bits_needed)) - (1u << next_bit);
       next_bit += bits_needed;
       m.global_mask |= (info->default_value << map->shift) & map->mask;
     }
-    map->_1_mask = (1 << map->shift) & map->mask;
+    map->_1_mask = (1u << map->shift) & map->mask;
     map->needs_fallback = !found;
 
   }
@@ -261,23 +268,32 @@
   {
     /* Collect lookup indices for features */
 
+    unsigned int variations_index;
+    hb_ot_layout_table_find_feature_variations (face,
+                                                table_tags[table_index],
+                                                coords,
+                                                num_coords,
+                                                &variations_index);
+
     unsigned int stage_index = 0;
     unsigned int last_num_lookups = 0;
     for (unsigned stage = 0; stage < current_stage[table_index]; stage++)
     {
       if (required_feature_index[table_index] != HB_OT_LAYOUT_NO_FEATURE_INDEX &&
           required_feature_stage[table_index] == stage)
-        m.add_lookups (face, table_index,
-                       required_feature_index[table_index],
-                       1 /* mask */,
-                       true /* auto_zwj */);
+        add_lookups (m, face, table_index,
+                     required_feature_index[table_index],
+                     variations_index,
+                     1 /* mask */,
+                     true /* auto_zwj */);
 
       for (unsigned i = 0; i < m.features.len; i++)
         if (m.features[i].stage[table_index] == stage)
-          m.add_lookups (face, table_index,
-                         m.features[i].index[table_index],
-                         m.features[i].mask,
-                         m.features[i].auto_zwj);
+          add_lookups (m, face, table_index,
+                       m.features[i].index[table_index],
+                       variations_index,
+                       m.features[i].mask,
+                       m.features[i].auto_zwj);
 
       /* Sort lookups and merge duplicates */
       if (last_num_lookups < m.lookups[table_index].len)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-math.h	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,209 @@
+/*
+ * Copyright © 2016  Igalia S.L.
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Igalia Author(s): Frédéric Wang
+ */
+
+#ifndef HB_OT_H_IN
+#error "Include <hb-ot.h> instead."
+#endif
+
+#ifndef HB_OT_MATH_H
+#define HB_OT_MATH_H
+
+#include "hb.h"
+
+HB_BEGIN_DECLS
+
+
+/*
+ * MATH
+ */
+
+#define HB_OT_TAG_MATH HB_TAG('M','A','T','H')
+
+/* Use with hb_buffer_set_script() for math shaping. */
+#define HB_OT_MATH_SCRIPT HB_TAG('m','a','t','h')
+
+/* Types */
+
+/**
+ * hb_ot_math_constant_t:
+ *
+ * Since: 1.3.3
+ */
+typedef enum {
+  HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN = 0,
+  HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN = 1,
+  HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT = 2,
+  HB_OT_MATH_CONSTANT_DISPLAY_OPERATOR_MIN_HEIGHT = 3,
+  HB_OT_MATH_CONSTANT_MATH_LEADING = 4,
+  HB_OT_MATH_CONSTANT_AXIS_HEIGHT = 5,
+  HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT = 6,
+  HB_OT_MATH_CONSTANT_FLATTENED_ACCENT_BASE_HEIGHT = 7,
+  HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN = 8,
+  HB_OT_MATH_CONSTANT_SUBSCRIPT_TOP_MAX = 9,
+  HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN = 10,
+  HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP = 11,
+  HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED = 12,
+  HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MIN = 13,
+  HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX = 14,
+  HB_OT_MATH_CONSTANT_SUB_SUPERSCRIPT_GAP_MIN = 15,
+  HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MAX_WITH_SUBSCRIPT = 16,
+  HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT = 17,
+  HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN = 18,
+  HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN = 19,
+  HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN = 20,
+  HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN = 21,
+  HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP = 22,
+  HB_OT_MATH_CONSTANT_STACK_TOP_DISPLAY_STYLE_SHIFT_UP = 23,
+  HB_OT_MATH_CONSTANT_STACK_BOTTOM_SHIFT_DOWN = 24,
+  HB_OT_MATH_CONSTANT_STACK_BOTTOM_DISPLAY_STYLE_SHIFT_DOWN = 25,
+  HB_OT_MATH_CONSTANT_STACK_GAP_MIN = 26,
+  HB_OT_MATH_CONSTANT_STACK_DISPLAY_STYLE_GAP_MIN = 27,
+  HB_OT_MATH_CONSTANT_STRETCH_STACK_TOP_SHIFT_UP = 28,
+  HB_OT_MATH_CONSTANT_STRETCH_STACK_BOTTOM_SHIFT_DOWN = 29,
+  HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_ABOVE_MIN = 30,
+  HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_BELOW_MIN = 31,
+  HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP = 32,
+  HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP = 33,
+  HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN = 34,
+  HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN = 35,
+  HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_GAP_MIN = 36,
+  HB_OT_MATH_CONSTANT_FRACTION_NUM_DISPLAY_STYLE_GAP_MIN = 37,
+  HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS = 38,
+  HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_GAP_MIN = 39,
+  HB_OT_MATH_CONSTANT_FRACTION_DENOM_DISPLAY_STYLE_GAP_MIN = 40,
+  HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP = 41,
+  HB_OT_MATH_CONSTANT_SKEWED_FRACTION_VERTICAL_GAP = 42,
+  HB_OT_MATH_CONSTANT_OVERBAR_VERTICAL_GAP = 43,
+  HB_OT_MATH_CONSTANT_OVERBAR_RULE_THICKNESS = 44,
+  HB_OT_MATH_CONSTANT_OVERBAR_EXTRA_ASCENDER = 45,
+  HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP = 46,
+  HB_OT_MATH_CONSTANT_UNDERBAR_RULE_THICKNESS = 47,
+  HB_OT_MATH_CONSTANT_UNDERBAR_EXTRA_DESCENDER = 48,
+  HB_OT_MATH_CONSTANT_RADICAL_VERTICAL_GAP = 49,
+  HB_OT_MATH_CONSTANT_RADICAL_DISPLAY_STYLE_VERTICAL_GAP = 50,
+  HB_OT_MATH_CONSTANT_RADICAL_RULE_THICKNESS = 51,
+  HB_OT_MATH_CONSTANT_RADICAL_EXTRA_ASCENDER = 52,
+  HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE = 53,
+  HB_OT_MATH_CONSTANT_RADICAL_KERN_AFTER_DEGREE = 54,
+  HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT = 55
+} hb_ot_math_constant_t;
+
+/**
+ * hb_ot_math_kern_t:
+ *
+ * Since: 1.3.3
+ */
+typedef enum {
+  HB_OT_MATH_KERN_TOP_RIGHT = 0,
+  HB_OT_MATH_KERN_TOP_LEFT = 1,
+  HB_OT_MATH_KERN_BOTTOM_RIGHT = 2,
+  HB_OT_MATH_KERN_BOTTOM_LEFT = 3
+} hb_ot_math_kern_t;
+
+/**
+ * hb_ot_math_glyph_variant_t:
+ *
+ * Since: 1.3.3
+ */
+typedef struct hb_ot_math_glyph_variant_t {
+  hb_codepoint_t glyph;
+  hb_position_t advance;
+} hb_ot_math_glyph_variant_t;
+
+/**
+ * hb_ot_math_glyph_part_flags_t:
+ *
+ * Since: 1.3.3
+ */
+typedef enum { /*< flags >*/
+  HB_MATH_GLYPH_PART_FLAG_EXTENDER      = 0x00000001u  /* Extender glyph */
+} hb_ot_math_glyph_part_flags_t;
+
+/**
+ * hb_ot_math_glyph_part_t:
+ *
+ * Since: 1.3.3
+ */
+typedef struct hb_ot_math_glyph_part_t {
+  hb_codepoint_t glyph;
+  hb_position_t start_connector_length;
+  hb_position_t end_connector_length;
+  hb_position_t full_advance;
+  hb_ot_math_glyph_part_flags_t flags;
+} hb_ot_math_glyph_part_t;
+
+/* Methods */
+
+HB_EXTERN hb_bool_t
+hb_ot_math_has_data (hb_face_t *face);
+
+HB_EXTERN hb_position_t
+hb_ot_math_get_constant (hb_font_t *font,
+                         hb_ot_math_constant_t constant);
+
+HB_EXTERN hb_position_t
+hb_ot_math_get_glyph_italics_correction (hb_font_t *font,
+                                         hb_codepoint_t glyph);
+
+HB_EXTERN hb_position_t
+hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font,
+                                            hb_codepoint_t glyph);
+
+HB_EXTERN hb_bool_t
+hb_ot_math_is_glyph_extended_shape (hb_face_t *face,
+                                    hb_codepoint_t glyph);
+
+HB_EXTERN hb_position_t
+hb_ot_math_get_glyph_kerning (hb_font_t *font,
+                              hb_codepoint_t glyph,
+                              hb_ot_math_kern_t kern,
+                              hb_position_t correction_height);
+
+HB_EXTERN unsigned int
+hb_ot_math_get_glyph_variants (hb_font_t *font,
+                               hb_codepoint_t glyph,
+                               hb_direction_t direction,
+                               unsigned int start_offset,
+                               unsigned int *variants_count, /* IN/OUT */
+                               hb_ot_math_glyph_variant_t *variants /* OUT */);
+
+HB_EXTERN hb_position_t
+hb_ot_math_get_min_connector_overlap (hb_font_t *font,
+                                      hb_direction_t direction);
+
+HB_EXTERN unsigned int
+hb_ot_math_get_glyph_assembly (hb_font_t *font,
+                               hb_codepoint_t glyph,
+                               hb_direction_t direction,
+                               unsigned int start_offset,
+                               unsigned int *parts_count, /* IN/OUT */
+                               hb_ot_math_glyph_part_t *parts, /* OUT */
+                               hb_position_t *italics_correction /* OUT */);
+
+
+HB_END_DECLS
+
+#endif /* HB_OT_MATH_H */
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-arabic.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-arabic.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -618,6 +618,7 @@
   NULL, /* decompose */
   NULL, /* compose */
   setup_masks_arabic,
+  NULL, /* disable_otl */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   true, /* fallback_position */
 };
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-default.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-default.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -40,6 +40,7 @@
   NULL, /* decompose */
   NULL, /* compose */
   NULL, /* setup_masks */
+  NULL, /* disable_otl */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   true, /* fallback_position */
 };
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hangul.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hangul.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -419,6 +419,7 @@
   NULL, /* decompose */
   NULL, /* compose */
   setup_masks_hangul,
+  NULL, /* disable_otl */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
   false, /* fallback_position */
 };
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hebrew.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hebrew.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -154,6 +154,18 @@
   return found;
 }
 
+static bool
+disable_otl_hebrew (const hb_ot_shape_plan_t *plan)
+{
+  /* For Hebrew shaper, use fallback if GPOS does not have 'hebr'
+   * script.  This matches Uniscribe better, and makes fonts like
+   * Arial that have GSUB/GPOS/GDEF but no data for Hebrew work.
+   * See:
+   * https://github.com/behdad/harfbuzz/issues/347#issuecomment-267838368
+   */
+  return plan->map.chosen_script[1] != HB_TAG ('h','e','b','r');
+}
+
 
 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hebrew =
 {
@@ -168,6 +180,7 @@
   NULL, /* decompose */
   compose_hebrew,
   NULL, /* setup_masks */
+  disable_otl_hebrew,
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   true, /* fallback_position */
 };
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic-machine.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic-machine.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -34,1316 +34,1316 @@
 
 #line 36 "hb-ot-shape-complex-indic-machine.hh"
 static const unsigned char _indic_syllable_machine_trans_keys[] = {
-        8u, 8u, 1u, 16u, 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u,
-        7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u,
-        6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u,
-        4u, 8u, 6u, 6u, 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u,
-        4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, 8u, 13u,
-        5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u,
-        7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u,
-        6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u,
-        4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u,
-        4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u,
-        5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u,
-        7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u,
-        6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u,
-        4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u,
-        8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u,
-        5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u,
-        4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u,
-        16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u,
-        4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 5u, 8u, 4u, 14u, 4u, 14u, 5u, 8u,
-        5u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u,
-        5u, 7u, 7u, 7u, 8u, 8u, 1u, 16u, 8u, 13u, 4u, 8u, 6u, 6u, 16u, 16u,
-        4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u,
-        16u, 16u, 8u, 8u, 1u, 18u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u,
-        3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u,
-        3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u,
-        5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u,
-        3u, 10u, 5u, 10u, 3u, 10u, 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u,
-        3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u,
-        5u, 14u, 3u, 14u, 1u, 16u, 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u,
-        1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u,
-        1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u,
-        1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u,
-        3u, 17u, 3u, 17u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u,
-        4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u,
-        4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u,
-        9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u,
-        5u, 10u, 3u, 10u, 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u,
-        4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u,
-        3u, 14u, 1u, 16u, 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u,
-        1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u,
-        1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u,
-        3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 14u, 1u, 16u,
-        3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u,
-        3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u,
-        3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, 9u, 10u, 9u, 9u,
-        9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u,
-        3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u,
-        3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 1u, 16u,
-        4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u,
-        3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u,
-        3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u,
-        1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 14u, 3u, 17u, 4u, 14u,
-        3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u,
-        3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u,
-        3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, 9u, 10u, 9u, 9u,
-        9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u,
-        3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u,
-        3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 1u, 16u,
-        4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u,
-        3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u,
-        3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u,
-        1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 1u, 17u, 3u, 17u,
-        1u, 17u, 4u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u,
-        5u, 10u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 3u, 17u, 3u, 17u, 1u, 16u,
-        3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u,
-        5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u,
-        3u, 13u, 1u, 16u, 3u, 10u, 5u, 10u, 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u,
+        8u, 8u, 1u, 16u, 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 
+        7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 
+        6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 
+        4u, 8u, 6u, 6u, 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 
+        4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, 8u, 13u, 
+        5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 
+        7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 
+        6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 
+        4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 
+        4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, 
+        5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 
+        7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 
+        6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, 
+        4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, 
+        8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 
+        5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 
+        4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 
+        16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 
+        4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 5u, 8u, 4u, 14u, 4u, 14u, 5u, 8u, 
+        5u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 
+        5u, 7u, 7u, 7u, 8u, 8u, 1u, 16u, 8u, 13u, 4u, 8u, 6u, 6u, 16u, 16u, 
+        4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 
+        16u, 16u, 8u, 8u, 1u, 18u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 
+        3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 
+        3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 
+        5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 
+        3u, 10u, 5u, 10u, 3u, 10u, 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 
+        3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 
+        5u, 14u, 3u, 14u, 1u, 16u, 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 
+        1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 
+        1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 
+        1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 
+        3u, 17u, 3u, 17u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 
+        4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 
+        4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, 
+        9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, 
+        5u, 10u, 3u, 10u, 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 
+        4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 
+        3u, 14u, 1u, 16u, 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 
+        1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 
+        1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 
+        3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 14u, 1u, 16u, 
+        3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 
+        3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 
+        3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, 
+        9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u, 
+        3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 
+        3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 1u, 16u, 
+        4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 
+        3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 
+        3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 
+        1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 14u, 3u, 17u, 4u, 14u, 
+        3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 
+        3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 
+        3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, 
+        9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u, 
+        3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 
+        3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 1u, 16u, 
+        4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 
+        3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 
+        3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 
+        1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 1u, 17u, 3u, 17u, 
+        1u, 17u, 4u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 
+        5u, 10u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 3u, 17u, 3u, 17u, 1u, 16u, 
+        3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 
+        5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u, 
+        3u, 13u, 1u, 16u, 3u, 10u, 5u, 10u, 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 
         9u, 10u, 9u, 9u, 5u, 10u, 0
 };
 
 static const char _indic_syllable_machine_key_spans[] = {
-        1, 16, 6, 4, 3, 1, 4, 3,
-        1, 4, 3, 1, 4, 3, 1, 5,
-        1, 1, 5, 1, 1, 5, 1, 1,
-        5, 1, 1, 11, 11, 11, 11, 11,
-        11, 11, 11, 11, 11, 1, 16, 6,
-        4, 3, 1, 4, 3, 1, 4, 3,
-        1, 4, 3, 1, 5, 1, 1, 5,
-        1, 1, 5, 1, 1, 5, 1, 1,
-        11, 11, 11, 11, 11, 11, 11, 11,
-        11, 11, 1, 16, 6, 4, 3, 1,
-        4, 3, 1, 4, 3, 1, 4, 3,
-        1, 5, 1, 1, 5, 1, 1, 5,
-        1, 1, 5, 1, 1, 11, 11, 11,
-        11, 11, 11, 11, 11, 11, 1, 16,
-        6, 4, 3, 1, 4, 3, 1, 4,
-        3, 1, 4, 3, 1, 5, 1, 1,
-        5, 1, 1, 5, 1, 1, 5, 1,
-        1, 11, 11, 11, 11, 11, 11, 11,
-        11, 11, 11, 11, 4, 11, 11, 4,
-        3, 4, 3, 1, 4, 3, 1, 4,
-        3, 1, 1, 16, 6, 5, 1, 1,
-        5, 1, 1, 5, 1, 1, 5, 1,
-        1, 1, 18, 15, 15, 14, 16, 15,
-        15, 14, 16, 15, 15, 14, 16, 15,
-        15, 14, 16, 15, 15, 14, 10, 10,
-        6, 2, 1, 2, 2, 1, 6, 11,
-        8, 6, 8, 11, 12, 12, 11, 10,
-        12, 11, 10, 12, 11, 10, 12, 11,
-        10, 12, 16, 11, 15, 15, 16, 16,
-        16, 16, 16, 15, 15, 16, 16, 16,
-        16, 16, 15, 15, 16, 16, 16, 16,
-        16, 15, 15, 16, 16, 16, 16, 16,
-        15, 15, 15, 15, 14, 16, 15, 15,
-        14, 16, 15, 15, 14, 16, 15, 15,
-        14, 16, 15, 15, 14, 10, 10, 6,
-        2, 1, 2, 2, 1, 6, 11, 8,
-        6, 8, 11, 12, 12, 11, 10, 12,
-        11, 10, 12, 11, 10, 12, 11, 10,
-        12, 16, 11, 15, 15, 16, 16, 16,
-        16, 16, 15, 15, 16, 16, 16, 16,
-        16, 15, 15, 16, 16, 16, 16, 16,
-        15, 15, 16, 16, 16, 16, 11, 16,
-        15, 15, 14, 16, 15, 15, 14, 16,
-        15, 15, 14, 16, 15, 15, 14, 16,
-        15, 15, 14, 10, 10, 6, 2, 1,
-        2, 2, 1, 6, 11, 8, 6, 8,
-        11, 12, 12, 11, 10, 12, 11, 10,
-        12, 11, 10, 12, 11, 10, 12, 16,
-        11, 15, 15, 16, 16, 16, 16, 16,
-        15, 15, 16, 16, 16, 16, 16, 15,
-        15, 16, 16, 16, 16, 16, 15, 15,
-        16, 16, 16, 16, 16, 11, 15, 11,
-        15, 15, 14, 16, 15, 15, 14, 16,
-        15, 15, 14, 16, 15, 15, 14, 16,
-        15, 15, 14, 10, 10, 6, 2, 1,
-        2, 2, 1, 6, 11, 8, 6, 8,
-        11, 12, 12, 11, 10, 12, 11, 10,
-        12, 11, 10, 12, 11, 10, 12, 16,
-        11, 15, 15, 16, 16, 16, 16, 16,
-        15, 15, 16, 16, 16, 16, 16, 15,
-        15, 16, 16, 16, 16, 16, 15, 15,
-        16, 16, 16, 16, 16, 15, 17, 15,
-        17, 11, 6, 2, 1, 2, 2, 1,
-        6, 16, 15, 15, 14, 15, 15, 16,
-        12, 11, 10, 12, 11, 10, 12, 11,
-        10, 12, 11, 10, 11, 8, 6, 8,
-        11, 16, 8, 6, 6, 2, 1, 2,
+        1, 16, 6, 4, 3, 1, 4, 3, 
+        1, 4, 3, 1, 4, 3, 1, 5, 
+        1, 1, 5, 1, 1, 5, 1, 1, 
+        5, 1, 1, 11, 11, 11, 11, 11, 
+        11, 11, 11, 11, 11, 1, 16, 6, 
+        4, 3, 1, 4, 3, 1, 4, 3, 
+        1, 4, 3, 1, 5, 1, 1, 5, 
+        1, 1, 5, 1, 1, 5, 1, 1, 
+        11, 11, 11, 11, 11, 11, 11, 11, 
+        11, 11, 1, 16, 6, 4, 3, 1, 
+        4, 3, 1, 4, 3, 1, 4, 3, 
+        1, 5, 1, 1, 5, 1, 1, 5, 
+        1, 1, 5, 1, 1, 11, 11, 11, 
+        11, 11, 11, 11, 11, 11, 1, 16, 
+        6, 4, 3, 1, 4, 3, 1, 4, 
+        3, 1, 4, 3, 1, 5, 1, 1, 
+        5, 1, 1, 5, 1, 1, 5, 1, 
+        1, 11, 11, 11, 11, 11, 11, 11, 
+        11, 11, 11, 11, 4, 11, 11, 4, 
+        3, 4, 3, 1, 4, 3, 1, 4, 
+        3, 1, 1, 16, 6, 5, 1, 1, 
+        5, 1, 1, 5, 1, 1, 5, 1, 
+        1, 1, 18, 15, 15, 14, 16, 15, 
+        15, 14, 16, 15, 15, 14, 16, 15, 
+        15, 14, 16, 15, 15, 14, 10, 10, 
+        6, 2, 1, 2, 2, 1, 6, 11, 
+        8, 6, 8, 11, 12, 12, 11, 10, 
+        12, 11, 10, 12, 11, 10, 12, 11, 
+        10, 12, 16, 11, 15, 15, 16, 16, 
+        16, 16, 16, 15, 15, 16, 16, 16, 
+        16, 16, 15, 15, 16, 16, 16, 16, 
+        16, 15, 15, 16, 16, 16, 16, 16, 
+        15, 15, 15, 15, 14, 16, 15, 15, 
+        14, 16, 15, 15, 14, 16, 15, 15, 
+        14, 16, 15, 15, 14, 10, 10, 6, 
+        2, 1, 2, 2, 1, 6, 11, 8, 
+        6, 8, 11, 12, 12, 11, 10, 12, 
+        11, 10, 12, 11, 10, 12, 11, 10, 
+        12, 16, 11, 15, 15, 16, 16, 16, 
+        16, 16, 15, 15, 16, 16, 16, 16, 
+        16, 15, 15, 16, 16, 16, 16, 16, 
+        15, 15, 16, 16, 16, 16, 11, 16, 
+        15, 15, 14, 16, 15, 15, 14, 16, 
+        15, 15, 14, 16, 15, 15, 14, 16, 
+        15, 15, 14, 10, 10, 6, 2, 1, 
+        2, 2, 1, 6, 11, 8, 6, 8, 
+        11, 12, 12, 11, 10, 12, 11, 10, 
+        12, 11, 10, 12, 11, 10, 12, 16, 
+        11, 15, 15, 16, 16, 16, 16, 16, 
+        15, 15, 16, 16, 16, 16, 16, 15, 
+        15, 16, 16, 16, 16, 16, 15, 15, 
+        16, 16, 16, 16, 16, 11, 15, 11, 
+        15, 15, 14, 16, 15, 15, 14, 16, 
+        15, 15, 14, 16, 15, 15, 14, 16, 
+        15, 15, 14, 10, 10, 6, 2, 1, 
+        2, 2, 1, 6, 11, 8, 6, 8, 
+        11, 12, 12, 11, 10, 12, 11, 10, 
+        12, 11, 10, 12, 11, 10, 12, 16, 
+        11, 15, 15, 16, 16, 16, 16, 16, 
+        15, 15, 16, 16, 16, 16, 16, 15, 
+        15, 16, 16, 16, 16, 16, 15, 15, 
+        16, 16, 16, 16, 16, 15, 17, 15, 
+        17, 11, 6, 2, 1, 2, 2, 1, 
+        6, 16, 15, 15, 14, 15, 15, 16, 
+        12, 11, 10, 12, 11, 10, 12, 11, 
+        10, 12, 11, 10, 11, 8, 6, 8, 
+        11, 16, 8, 6, 6, 2, 1, 2, 
         2, 1, 6
 };
 
 static const short _indic_syllable_machine_index_offsets[] = {
-        0, 2, 19, 26, 31, 35, 37, 42,
-        46, 48, 53, 57, 59, 64, 68, 70,
-        76, 78, 80, 86, 88, 90, 96, 98,
-        100, 106, 108, 110, 122, 134, 146, 158,
-        170, 182, 194, 206, 218, 230, 232, 249,
-        256, 261, 265, 267, 272, 276, 278, 283,
-        287, 289, 294, 298, 300, 306, 308, 310,
-        316, 318, 320, 326, 328, 330, 336, 338,
-        340, 352, 364, 376, 388, 400, 412, 424,
-        436, 448, 460, 462, 479, 486, 491, 495,
-        497, 502, 506, 508, 513, 517, 519, 524,
-        528, 530, 536, 538, 540, 546, 548, 550,
-        556, 558, 560, 566, 568, 570, 582, 594,
-        606, 618, 630, 642, 654, 666, 678, 680,
-        697, 704, 709, 713, 715, 720, 724, 726,
-        731, 735, 737, 742, 746, 748, 754, 756,
-        758, 764, 766, 768, 774, 776, 778, 784,
-        786, 788, 800, 812, 824, 836, 848, 860,
-        872, 884, 896, 908, 920, 925, 937, 949,
-        954, 958, 963, 967, 969, 974, 978, 980,
-        985, 989, 991, 993, 1010, 1017, 1023, 1025,
-        1027, 1033, 1035, 1037, 1043, 1045, 1047, 1053,
-        1055, 1057, 1059, 1078, 1094, 1110, 1125, 1142,
-        1158, 1174, 1189, 1206, 1222, 1238, 1253, 1270,
-        1286, 1302, 1317, 1334, 1350, 1366, 1381, 1392,
-        1403, 1410, 1413, 1415, 1418, 1421, 1423, 1430,
-        1442, 1451, 1458, 1467, 1479, 1492, 1505, 1517,
-        1528, 1541, 1553, 1564, 1577, 1589, 1600, 1613,
-        1625, 1636, 1649, 1666, 1678, 1694, 1710, 1727,
-        1744, 1761, 1778, 1795, 1811, 1827, 1844, 1861,
-        1878, 1895, 1912, 1928, 1944, 1961, 1978, 1995,
-        2012, 2029, 2045, 2061, 2078, 2095, 2112, 2129,
-        2146, 2162, 2178, 2194, 2210, 2225, 2242, 2258,
-        2274, 2289, 2306, 2322, 2338, 2353, 2370, 2386,
-        2402, 2417, 2434, 2450, 2466, 2481, 2492, 2503,
-        2510, 2513, 2515, 2518, 2521, 2523, 2530, 2542,
-        2551, 2558, 2567, 2579, 2592, 2605, 2617, 2628,
-        2641, 2653, 2664, 2677, 2689, 2700, 2713, 2725,
-        2736, 2749, 2766, 2778, 2794, 2810, 2827, 2844,
-        2861, 2878, 2895, 2911, 2927, 2944, 2961, 2978,
-        2995, 3012, 3028, 3044, 3061, 3078, 3095, 3112,
-        3129, 3145, 3161, 3178, 3195, 3212, 3229, 3241,
-        3258, 3274, 3290, 3305, 3322, 3338, 3354, 3369,
-        3386, 3402, 3418, 3433, 3450, 3466, 3482, 3497,
-        3514, 3530, 3546, 3561, 3572, 3583, 3590, 3593,
-        3595, 3598, 3601, 3603, 3610, 3622, 3631, 3638,
-        3647, 3659, 3672, 3685, 3697, 3708, 3721, 3733,
-        3744, 3757, 3769, 3780, 3793, 3805, 3816, 3829,
-        3846, 3858, 3874, 3890, 3907, 3924, 3941, 3958,
-        3975, 3991, 4007, 4024, 4041, 4058, 4075, 4092,
-        4108, 4124, 4141, 4158, 4175, 4192, 4209, 4225,
-        4241, 4258, 4275, 4292, 4309, 4326, 4338, 4354,
-        4366, 4382, 4398, 4413, 4430, 4446, 4462, 4477,
-        4494, 4510, 4526, 4541, 4558, 4574, 4590, 4605,
-        4622, 4638, 4654, 4669, 4680, 4691, 4698, 4701,
-        4703, 4706, 4709, 4711, 4718, 4730, 4739, 4746,
-        4755, 4767, 4780, 4793, 4805, 4816, 4829, 4841,
-        4852, 4865, 4877, 4888, 4901, 4913, 4924, 4937,
-        4954, 4966, 4982, 4998, 5015, 5032, 5049, 5066,
-        5083, 5099, 5115, 5132, 5149, 5166, 5183, 5200,
-        5216, 5232, 5249, 5266, 5283, 5300, 5317, 5333,
-        5349, 5366, 5383, 5400, 5417, 5434, 5450, 5468,
-        5484, 5502, 5514, 5521, 5524, 5526, 5529, 5532,
-        5534, 5541, 5558, 5574, 5590, 5605, 5621, 5637,
-        5654, 5667, 5679, 5690, 5703, 5715, 5726, 5739,
-        5751, 5762, 5775, 5787, 5798, 5810, 5819, 5826,
-        5835, 5847, 5864, 5873, 5880, 5887, 5890, 5892,
+        0, 2, 19, 26, 31, 35, 37, 42, 
+        46, 48, 53, 57, 59, 64, 68, 70, 
+        76, 78, 80, 86, 88, 90, 96, 98, 
+        100, 106, 108, 110, 122, 134, 146, 158, 
+        170, 182, 194, 206, 218, 230, 232, 249, 
+        256, 261, 265, 267, 272, 276, 278, 283, 
+        287, 289, 294, 298, 300, 306, 308, 310, 
+        316, 318, 320, 326, 328, 330, 336, 338, 
+        340, 352, 364, 376, 388, 400, 412, 424, 
+        436, 448, 460, 462, 479, 486, 491, 495, 
+        497, 502, 506, 508, 513, 517, 519, 524, 
+        528, 530, 536, 538, 540, 546, 548, 550, 
+        556, 558, 560, 566, 568, 570, 582, 594, 
+        606, 618, 630, 642, 654, 666, 678, 680, 
+        697, 704, 709, 713, 715, 720, 724, 726, 
+        731, 735, 737, 742, 746, 748, 754, 756, 
+        758, 764, 766, 768, 774, 776, 778, 784, 
+        786, 788, 800, 812, 824, 836, 848, 860, 
+        872, 884, 896, 908, 920, 925, 937, 949, 
+        954, 958, 963, 967, 969, 974, 978, 980, 
+        985, 989, 991, 993, 1010, 1017, 1023, 1025, 
+        1027, 1033, 1035, 1037, 1043, 1045, 1047, 1053, 
+        1055, 1057, 1059, 1078, 1094, 1110, 1125, 1142, 
+        1158, 1174, 1189, 1206, 1222, 1238, 1253, 1270, 
+        1286, 1302, 1317, 1334, 1350, 1366, 1381, 1392, 
+        1403, 1410, 1413, 1415, 1418, 1421, 1423, 1430, 
+        1442, 1451, 1458, 1467, 1479, 1492, 1505, 1517, 
+        1528, 1541, 1553, 1564, 1577, 1589, 1600, 1613, 
+        1625, 1636, 1649, 1666, 1678, 1694, 1710, 1727, 
+        1744, 1761, 1778, 1795, 1811, 1827, 1844, 1861, 
+        1878, 1895, 1912, 1928, 1944, 1961, 1978, 1995, 
+        2012, 2029, 2045, 2061, 2078, 2095, 2112, 2129, 
+        2146, 2162, 2178, 2194, 2210, 2225, 2242, 2258, 
+        2274, 2289, 2306, 2322, 2338, 2353, 2370, 2386, 
+        2402, 2417, 2434, 2450, 2466, 2481, 2492, 2503, 
+        2510, 2513, 2515, 2518, 2521, 2523, 2530, 2542, 
+        2551, 2558, 2567, 2579, 2592, 2605, 2617, 2628, 
+        2641, 2653, 2664, 2677, 2689, 2700, 2713, 2725, 
+        2736, 2749, 2766, 2778, 2794, 2810, 2827, 2844, 
+        2861, 2878, 2895, 2911, 2927, 2944, 2961, 2978, 
+        2995, 3012, 3028, 3044, 3061, 3078, 3095, 3112, 
+        3129, 3145, 3161, 3178, 3195, 3212, 3229, 3241, 
+        3258, 3274, 3290, 3305, 3322, 3338, 3354, 3369, 
+        3386, 3402, 3418, 3433, 3450, 3466, 3482, 3497, 
+        3514, 3530, 3546, 3561, 3572, 3583, 3590, 3593, 
+        3595, 3598, 3601, 3603, 3610, 3622, 3631, 3638, 
+        3647, 3659, 3672, 3685, 3697, 3708, 3721, 3733, 
+        3744, 3757, 3769, 3780, 3793, 3805, 3816, 3829, 
+        3846, 3858, 3874, 3890, 3907, 3924, 3941, 3958, 
+        3975, 3991, 4007, 4024, 4041, 4058, 4075, 4092, 
+        4108, 4124, 4141, 4158, 4175, 4192, 4209, 4225, 
+        4241, 4258, 4275, 4292, 4309, 4326, 4338, 4354, 
+        4366, 4382, 4398, 4413, 4430, 4446, 4462, 4477, 
+        4494, 4510, 4526, 4541, 4558, 4574, 4590, 4605, 
+        4622, 4638, 4654, 4669, 4680, 4691, 4698, 4701, 
+        4703, 4706, 4709, 4711, 4718, 4730, 4739, 4746, 
+        4755, 4767, 4780, 4793, 4805, 4816, 4829, 4841, 
+        4852, 4865, 4877, 4888, 4901, 4913, 4924, 4937, 
+        4954, 4966, 4982, 4998, 5015, 5032, 5049, 5066, 
+        5083, 5099, 5115, 5132, 5149, 5166, 5183, 5200, 
+        5216, 5232, 5249, 5266, 5283, 5300, 5317, 5333, 
+        5349, 5366, 5383, 5400, 5417, 5434, 5450, 5468, 
+        5484, 5502, 5514, 5521, 5524, 5526, 5529, 5532, 
+        5534, 5541, 5558, 5574, 5590, 5605, 5621, 5637, 
+        5654, 5667, 5679, 5690, 5703, 5715, 5726, 5739, 
+        5751, 5762, 5775, 5787, 5798, 5810, 5819, 5826, 
+        5835, 5847, 5864, 5873, 5880, 5887, 5890, 5892, 
         5895, 5898, 5900
 };
 
 static const short _indic_syllable_machine_indicies[] = {
-        1, 0, 2, 3, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 2, 0, 1, 0, 0, 0, 0,
-        4, 0, 5, 5, 6, 1, 0, 7,
-        7, 6, 0, 6, 0, 8, 8, 9,
-        1, 0, 10, 10, 9, 0, 9, 0,
-        11, 11, 12, 1, 0, 13, 13, 12,
-        0, 12, 0, 14, 14, 15, 1, 0,
-        16, 16, 15, 0, 15, 0, 17, 0,
-        0, 0, 1, 0, 18, 0, 19, 0,
-        20, 14, 14, 15, 1, 0, 21, 0,
-        22, 0, 23, 11, 11, 12, 1, 0,
-        24, 0, 25, 0, 26, 8, 8, 9,
-        1, 0, 27, 0, 28, 0, 29, 5,
-        5, 6, 1, 0, 0, 0, 0, 0,
-        29, 0, 29, 5, 5, 6, 1, 0,
-        0, 0, 0, 30, 29, 0, 31, 5,
-        5, 6, 1, 0, 0, 0, 0, 0,
-        31, 0, 31, 5, 5, 6, 1, 0,
-        0, 0, 0, 32, 31, 0, 33, 5,
-        5, 6, 1, 0, 0, 0, 0, 0,
-        33, 0, 33, 5, 5, 6, 1, 0,
-        0, 0, 0, 34, 33, 0, 35, 5,
-        5, 6, 1, 0, 0, 0, 0, 0,
-        35, 0, 35, 5, 5, 6, 1, 0,
-        0, 0, 0, 36, 35, 0, 37, 5,
-        5, 6, 1, 0, 0, 0, 0, 0,
-        37, 0, 37, 5, 5, 6, 1, 0,
-        0, 0, 0, 38, 37, 0, 40, 39,
-        41, 42, 39, 39, 39, 39, 39, 39,
-        39, 39, 39, 39, 39, 39, 39, 41,
-        39, 40, 39, 39, 39, 39, 43, 39,
-        44, 44, 45, 40, 39, 46, 46, 45,
-        39, 45, 39, 47, 47, 48, 40, 39,
-        49, 49, 48, 39, 48, 39, 50, 50,
-        51, 40, 39, 52, 52, 51, 39, 51,
-        39, 53, 53, 54, 40, 39, 55, 55,
-        54, 39, 54, 39, 56, 39, 39, 39,
-        40, 39, 57, 39, 58, 39, 59, 53,
-        53, 54, 40, 39, 60, 39, 61, 39,
-        62, 50, 50, 51, 40, 39, 63, 39,
-        64, 39, 65, 47, 47, 48, 40, 39,
-        66, 39, 67, 39, 68, 44, 44, 45,
-        40, 39, 39, 39, 39, 39, 68, 39,
-        68, 44, 44, 45, 40, 39, 39, 39,
-        39, 69, 68, 39, 70, 44, 44, 45,
-        40, 39, 39, 39, 39, 39, 70, 39,
-        70, 44, 44, 45, 40, 39, 39, 39,
-        39, 71, 70, 39, 72, 44, 44, 45,
-        40, 39, 39, 39, 39, 39, 72, 39,
-        72, 44, 44, 45, 40, 39, 39, 39,
-        39, 73, 72, 39, 74, 44, 44, 45,
-        40, 39, 39, 39, 39, 39, 74, 39,
-        74, 44, 44, 45, 40, 39, 39, 39,
-        39, 75, 74, 39, 76, 44, 44, 45,
-        40, 39, 39, 39, 39, 39, 76, 39,
-        76, 44, 44, 45, 40, 39, 39, 39,
-        39, 77, 76, 39, 79, 78, 80, 81,
-        78, 78, 78, 78, 78, 78, 78, 78,
-        78, 78, 78, 78, 78, 80, 78, 79,
-        78, 78, 78, 78, 82, 78, 83, 83,
-        84, 79, 78, 86, 86, 84, 85, 84,
-        85, 87, 87, 88, 79, 78, 89, 89,
-        88, 78, 88, 78, 90, 90, 91, 79,
-        78, 92, 92, 91, 78, 91, 78, 93,
-        93, 94, 79, 78, 95, 95, 94, 78,
-        94, 78, 96, 78, 78, 78, 79, 78,
-        97, 78, 98, 78, 99, 93, 93, 94,
-        79, 78, 100, 78, 101, 78, 102, 90,
-        90, 91, 79, 78, 103, 78, 104, 78,
-        105, 87, 87, 88, 79, 78, 106, 78,
-        107, 78, 108, 83, 83, 84, 79, 78,
-        78, 78, 78, 78, 108, 78, 108, 83,
-        83, 84, 79, 78, 78, 78, 78, 109,
-        108, 78, 110, 83, 83, 84, 79, 78,
-        78, 78, 78, 78, 110, 78, 110, 83,
-        83, 84, 79, 78, 78, 78, 78, 111,
-        110, 78, 112, 83, 83, 84, 79, 78,
-        78, 78, 78, 78, 112, 78, 112, 83,
-        83, 84, 79, 78, 78, 78, 78, 113,
-        112, 78, 114, 83, 83, 84, 79, 78,
-        78, 78, 78, 78, 114, 78, 114, 83,
-        83, 84, 79, 78, 78, 78, 78, 115,
-        114, 78, 116, 83, 83, 84, 79, 78,
-        78, 78, 78, 78, 116, 78, 118, 117,
-        119, 120, 117, 117, 117, 117, 117, 117,
-        117, 117, 117, 117, 117, 117, 117, 119,
-        117, 118, 117, 117, 117, 117, 121, 117,
-        122, 122, 123, 118, 117, 124, 124, 123,
-        117, 123, 117, 125, 125, 126, 118, 117,
-        127, 127, 126, 117, 126, 117, 128, 128,
-        129, 118, 117, 130, 130, 129, 117, 129,
-        117, 131, 131, 132, 118, 117, 133, 133,
-        132, 117, 132, 117, 134, 117, 117, 117,
-        118, 117, 135, 117, 136, 117, 137, 131,
-        131, 132, 118, 117, 138, 117, 139, 117,
-        140, 128, 128, 129, 118, 117, 141, 117,
-        142, 117, 143, 125, 125, 126, 118, 117,
-        144, 117, 145, 117, 146, 122, 122, 123,
-        118, 117, 117, 117, 117, 117, 146, 117,
-        146, 122, 122, 123, 118, 117, 117, 117,
-        117, 147, 146, 117, 148, 122, 122, 123,
-        118, 117, 117, 117, 117, 117, 148, 117,
-        148, 122, 122, 123, 118, 117, 117, 117,
-        117, 149, 148, 117, 150, 122, 122, 123,
-        118, 117, 117, 117, 117, 117, 150, 117,
-        150, 122, 122, 123, 118, 117, 117, 117,
-        117, 151, 150, 117, 152, 122, 122, 123,
-        118, 117, 117, 117, 117, 117, 152, 117,
-        152, 122, 122, 123, 118, 117, 117, 117,
-        117, 153, 152, 117, 154, 122, 122, 123,
-        118, 117, 117, 117, 117, 117, 154, 117,
-        154, 122, 122, 123, 118, 117, 117, 117,
-        117, 155, 154, 117, 116, 83, 83, 84,
-        79, 78, 78, 78, 78, 156, 116, 78,
-        86, 86, 84, 1, 0, 114, 83, 83,
-        84, 157, 0, 0, 0, 0, 0, 114,
-        0, 114, 83, 83, 84, 157, 0, 0,
-        0, 0, 158, 114, 0, 159, 159, 160,
-        1, 0, 7, 7, 160, 0, 161, 161,
-        162, 157, 0, 163, 163, 162, 0, 162,
-        0, 164, 164, 165, 157, 0, 166, 166,
-        165, 0, 165, 0, 167, 167, 168, 157,
-        0, 169, 169, 168, 0, 168, 0, 157,
-        0, 170, 171, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        170, 0, 157, 0, 0, 0, 0, 172,
-        0, 173, 0, 0, 0, 157, 0, 174,
-        0, 175, 0, 176, 167, 167, 168, 157,
-        0, 177, 0, 178, 0, 179, 164, 164,
-        165, 157, 0, 180, 0, 181, 0, 182,
-        161, 161, 162, 157, 0, 183, 0, 184,
-        0, 186, 185, 188, 189, 190, 191, 192,
-        193, 84, 79, 194, 195, 196, 196, 156,
-        197, 198, 199, 200, 201, 187, 203, 204,
-        205, 206, 6, 1, 207, 208, 202, 202,
-        38, 209, 202, 202, 210, 202, 211, 204,
-        212, 212, 6, 1, 207, 208, 202, 202,
-        202, 209, 202, 202, 210, 202, 204, 212,
-        212, 6, 1, 207, 208, 202, 202, 202,
-        209, 202, 202, 210, 202, 213, 202, 202,
-        202, 19, 214, 202, 1, 207, 208, 202,
-        202, 202, 215, 202, 213, 202, 216, 217,
-        218, 219, 6, 1, 207, 208, 202, 202,
-        36, 220, 202, 202, 210, 202, 221, 217,
-        222, 222, 6, 1, 207, 208, 202, 202,
-        202, 220, 202, 202, 210, 202, 217, 222,
-        222, 6, 1, 207, 208, 202, 202, 202,
-        220, 202, 202, 210, 202, 223, 202, 202,
-        202, 19, 224, 202, 1, 207, 208, 202,
-        202, 202, 215, 202, 223, 202, 225, 226,
-        227, 228, 6, 1, 207, 208, 202, 202,
-        34, 229, 202, 202, 210, 202, 230, 226,
-        231, 231, 6, 1, 207, 208, 202, 202,
-        202, 229, 202, 202, 210, 202, 226, 231,
-        231, 6, 1, 207, 208, 202, 202, 202,
-        229, 202, 202, 210, 202, 232, 202, 202,
-        202, 19, 233, 202, 1, 207, 208, 202,
-        202, 202, 215, 202, 232, 202, 234, 235,
-        236, 237, 6, 1, 207, 208, 202, 202,
-        32, 238, 202, 202, 210, 202, 239, 235,
-        240, 240, 6, 1, 207, 208, 202, 202,
-        202, 238, 202, 202, 210, 202, 235, 240,
-        240, 6, 1, 207, 208, 202, 202, 202,
-        238, 202, 202, 210, 202, 241, 202, 202,
-        202, 19, 242, 202, 1, 207, 208, 202,
-        202, 202, 215, 202, 241, 202, 243, 244,
-        245, 246, 6, 1, 207, 208, 202, 202,
-        30, 247, 202, 202, 210, 202, 248, 244,
-        249, 249, 6, 1, 207, 208, 202, 202,
-        202, 247, 202, 202, 210, 202, 244, 249,
-        249, 6, 1, 207, 208, 202, 202, 202,
-        247, 202, 202, 210, 202, 19, 250, 202,
-        1, 207, 208, 202, 202, 202, 215, 202,
-        251, 251, 202, 1, 207, 208, 202, 202,
-        202, 215, 202, 252, 202, 202, 253, 207,
-        208, 202, 207, 208, 202, 254, 202, 207,
-        255, 202, 207, 256, 202, 207, 202, 252,
-        202, 202, 202, 207, 208, 202, 257, 202,
-        258, 259, 202, 1, 207, 208, 202, 202,
-        4, 202, 3, 202, 251, 251, 202, 1,
-        207, 208, 202, 251, 251, 202, 1, 207,
-        208, 202, 257, 202, 251, 251, 202, 1,
-        207, 208, 202, 257, 202, 258, 251, 202,
-        1, 207, 208, 202, 202, 4, 202, 19,
-        202, 260, 260, 6, 1, 207, 208, 202,
-        202, 202, 215, 202, 261, 28, 262, 263,
-        9, 1, 207, 208, 202, 202, 202, 215,
-        202, 28, 262, 263, 9, 1, 207, 208,
-        202, 202, 202, 215, 202, 262, 262, 9,
-        1, 207, 208, 202, 202, 202, 215, 202,
-        264, 25, 265, 266, 12, 1, 207, 208,
-        202, 202, 202, 215, 202, 25, 265, 266,
-        12, 1, 207, 208, 202, 202, 202, 215,
-        202, 265, 265, 12, 1, 207, 208, 202,
-        202, 202, 215, 202, 267, 22, 268, 269,
-        15, 1, 207, 208, 202, 202, 202, 215,
-        202, 22, 268, 269, 15, 1, 207, 208,
-        202, 202, 202, 215, 202, 268, 268, 15,
-        1, 207, 208, 202, 202, 202, 215, 202,
-        270, 19, 251, 271, 202, 1, 207, 208,
-        202, 202, 202, 215, 202, 19, 251, 271,
-        202, 1, 207, 208, 202, 202, 202, 215,
-        202, 251, 272, 202, 1, 207, 208, 202,
-        202, 202, 215, 202, 19, 202, 251, 251,
-        202, 1, 207, 208, 202, 202, 202, 215,
-        202, 2, 3, 202, 202, 19, 250, 202,
-        1, 207, 208, 202, 202, 202, 215, 202,
-        2, 202, 244, 249, 249, 6, 1, 207,
-        208, 202, 202, 202, 247, 202, 243, 244,
-        249, 249, 6, 1, 207, 208, 202, 202,
-        202, 247, 202, 202, 210, 202, 243, 244,
-        245, 249, 6, 1, 207, 208, 202, 202,
-        30, 247, 202, 202, 210, 202, 241, 202,
-        273, 202, 260, 260, 6, 1, 207, 208,
-        202, 202, 202, 215, 202, 241, 202, 241,
-        202, 202, 202, 251, 251, 202, 1, 207,
-        208, 202, 202, 202, 215, 202, 241, 202,
-        241, 202, 202, 202, 251, 274, 202, 1,
-        207, 208, 202, 202, 202, 215, 202, 241,
-        202, 241, 202, 273, 202, 251, 251, 202,
-        1, 207, 208, 202, 202, 202, 215, 202,
-        241, 202, 241, 3, 202, 202, 19, 242,
-        202, 1, 207, 208, 202, 202, 202, 215,
-        202, 241, 202, 234, 235, 240, 240, 6,
-        1, 207, 208, 202, 202, 202, 238, 202,
-        202, 210, 202, 234, 235, 236, 240, 6,
-        1, 207, 208, 202, 202, 32, 238, 202,
-        202, 210, 202, 232, 202, 275, 202, 260,
-        260, 6, 1, 207, 208, 202, 202, 202,
-        215, 202, 232, 202, 232, 202, 202, 202,
-        251, 251, 202, 1, 207, 208, 202, 202,
-        202, 215, 202, 232, 202, 232, 202, 202,
-        202, 251, 276, 202, 1, 207, 208, 202,
-        202, 202, 215, 202, 232, 202, 232, 202,
-        275, 202, 251, 251, 202, 1, 207, 208,
-        202, 202, 202, 215, 202, 232, 202, 232,
-        3, 202, 202, 19, 233, 202, 1, 207,
-        208, 202, 202, 202, 215, 202, 232, 202,
-        225, 226, 231, 231, 6, 1, 207, 208,
-        202, 202, 202, 229, 202, 202, 210, 202,
-        225, 226, 227, 231, 6, 1, 207, 208,
-        202, 202, 34, 229, 202, 202, 210, 202,
-        223, 202, 277, 202, 260, 260, 6, 1,
-        207, 208, 202, 202, 202, 215, 202, 223,
-        202, 223, 202, 202, 202, 251, 251, 202,
-        1, 207, 208, 202, 202, 202, 215, 202,
-        223, 202, 223, 202, 202, 202, 251, 278,
-        202, 1, 207, 208, 202, 202, 202, 215,
-        202, 223, 202, 223, 202, 277, 202, 251,
-        251, 202, 1, 207, 208, 202, 202, 202,
-        215, 202, 223, 202, 223, 3, 202, 202,
-        19, 224, 202, 1, 207, 208, 202, 202,
-        202, 215, 202, 223, 202, 216, 217, 222,
-        222, 6, 1, 207, 208, 202, 202, 202,
-        220, 202, 202, 210, 202, 216, 217, 218,
-        222, 6, 1, 207, 208, 202, 202, 36,
-        220, 202, 202, 210, 202, 213, 202, 279,
-        202, 260, 260, 6, 1, 207, 208, 202,
-        202, 202, 215, 202, 213, 202, 213, 202,
-        202, 202, 251, 251, 202, 1, 207, 208,
-        202, 202, 202, 215, 202, 213, 202, 213,
-        202, 202, 202, 251, 280, 202, 1, 207,
-        208, 202, 202, 202, 215, 202, 213, 202,
-        213, 202, 279, 202, 251, 251, 202, 1,
-        207, 208, 202, 202, 202, 215, 202, 213,
-        202, 213, 3, 202, 202, 19, 214, 202,
-        1, 207, 208, 202, 202, 202, 215, 202,
-        213, 202, 203, 204, 212, 212, 6, 1,
-        207, 208, 202, 202, 202, 209, 202, 202,
-        210, 202, 203, 204, 205, 212, 6, 1,
-        207, 208, 202, 202, 38, 209, 202, 202,
-        210, 202, 282, 283, 284, 285, 45, 40,
-        286, 287, 281, 281, 77, 288, 281, 281,
-        289, 281, 290, 283, 291, 285, 45, 40,
-        286, 287, 281, 281, 281, 288, 281, 281,
-        289, 281, 283, 291, 285, 45, 40, 286,
-        287, 281, 281, 281, 288, 281, 281, 289,
-        281, 292, 281, 281, 281, 58, 293, 281,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        292, 281, 295, 296, 297, 298, 45, 40,
-        286, 287, 281, 281, 75, 299, 281, 281,
-        289, 281, 300, 296, 301, 301, 45, 40,
-        286, 287, 281, 281, 281, 299, 281, 281,
-        289, 281, 296, 301, 301, 45, 40, 286,
-        287, 281, 281, 281, 299, 281, 281, 289,
-        281, 302, 281, 281, 281, 58, 303, 281,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        302, 281, 304, 305, 306, 307, 45, 40,
-        286, 287, 281, 281, 73, 308, 281, 281,
-        289, 281, 309, 305, 310, 310, 45, 40,
-        286, 287, 281, 281, 281, 308, 281, 281,
-        289, 281, 305, 310, 310, 45, 40, 286,
-        287, 281, 281, 281, 308, 281, 281, 289,
-        281, 311, 281, 281, 281, 58, 312, 281,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        311, 281, 313, 314, 315, 316, 45, 40,
-        286, 287, 281, 281, 71, 317, 281, 281,
-        289, 281, 318, 314, 319, 319, 45, 40,
-        286, 287, 281, 281, 281, 317, 281, 281,
-        289, 281, 314, 319, 319, 45, 40, 286,
-        287, 281, 281, 281, 317, 281, 281, 289,
-        281, 320, 281, 281, 281, 58, 321, 281,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        320, 281, 322, 323, 324, 325, 45, 40,
-        286, 287, 281, 281, 69, 326, 281, 281,
-        289, 281, 327, 323, 328, 328, 45, 40,
-        286, 287, 281, 281, 281, 326, 281, 281,
-        289, 281, 323, 328, 328, 45, 40, 286,
-        287, 281, 281, 281, 326, 281, 281, 289,
-        281, 58, 329, 281, 40, 286, 287, 281,
-        281, 281, 294, 281, 330, 330, 281, 40,
-        286, 287, 281, 281, 281, 294, 281, 331,
-        281, 281, 332, 286, 287, 281, 286, 287,
-        281, 333, 281, 286, 334, 281, 286, 335,
-        281, 286, 281, 331, 281, 281, 281, 286,
-        287, 281, 336, 281, 337, 338, 281, 40,
-        286, 287, 281, 281, 43, 281, 42, 281,
-        330, 330, 281, 40, 286, 287, 281, 330,
-        330, 281, 40, 286, 287, 281, 336, 281,
-        330, 330, 281, 40, 286, 287, 281, 336,
-        281, 337, 330, 281, 40, 286, 287, 281,
-        281, 43, 281, 58, 281, 339, 339, 45,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        340, 67, 341, 342, 48, 40, 286, 287,
-        281, 281, 281, 294, 281, 67, 341, 342,
-        48, 40, 286, 287, 281, 281, 281, 294,
-        281, 341, 341, 48, 40, 286, 287, 281,
-        281, 281, 294, 281, 343, 64, 344, 345,
-        51, 40, 286, 287, 281, 281, 281, 294,
-        281, 64, 344, 345, 51, 40, 286, 287,
-        281, 281, 281, 294, 281, 344, 344, 51,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        346, 61, 347, 348, 54, 40, 286, 287,
-        281, 281, 281, 294, 281, 61, 347, 348,
-        54, 40, 286, 287, 281, 281, 281, 294,
-        281, 347, 347, 54, 40, 286, 287, 281,
-        281, 281, 294, 281, 349, 58, 330, 350,
-        281, 40, 286, 287, 281, 281, 281, 294,
-        281, 58, 330, 350, 281, 40, 286, 287,
-        281, 281, 281, 294, 281, 330, 351, 281,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        58, 281, 330, 330, 281, 40, 286, 287,
-        281, 281, 281, 294, 281, 41, 42, 281,
-        281, 58, 329, 281, 40, 286, 287, 281,
-        281, 281, 294, 281, 41, 281, 323, 328,
-        328, 45, 40, 286, 287, 281, 281, 281,
-        326, 281, 322, 323, 328, 328, 45, 40,
-        286, 287, 281, 281, 281, 326, 281, 281,
-        289, 281, 322, 323, 324, 328, 45, 40,
-        286, 287, 281, 281, 69, 326, 281, 281,
-        289, 281, 320, 281, 352, 281, 339, 339,
-        45, 40, 286, 287, 281, 281, 281, 294,
-        281, 320, 281, 320, 281, 281, 281, 330,
-        330, 281, 40, 286, 287, 281, 281, 281,
-        294, 281, 320, 281, 320, 281, 281, 281,
-        330, 353, 281, 40, 286, 287, 281, 281,
-        281, 294, 281, 320, 281, 320, 281, 352,
-        281, 330, 330, 281, 40, 286, 287, 281,
-        281, 281, 294, 281, 320, 281, 320, 42,
-        281, 281, 58, 321, 281, 40, 286, 287,
-        281, 281, 281, 294, 281, 320, 281, 313,
-        314, 319, 319, 45, 40, 286, 287, 281,
-        281, 281, 317, 281, 281, 289, 281, 313,
-        314, 315, 319, 45, 40, 286, 287, 281,
-        281, 71, 317, 281, 281, 289, 281, 311,
-        281, 354, 281, 339, 339, 45, 40, 286,
-        287, 281, 281, 281, 294, 281, 311, 281,
-        311, 281, 281, 281, 330, 330, 281, 40,
-        286, 287, 281, 281, 281, 294, 281, 311,
-        281, 311, 281, 281, 281, 330, 355, 281,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        311, 281, 311, 281, 354, 281, 330, 330,
-        281, 40, 286, 287, 281, 281, 281, 294,
-        281, 311, 281, 311, 42, 281, 281, 58,
-        312, 281, 40, 286, 287, 281, 281, 281,
-        294, 281, 311, 281, 304, 305, 310, 310,
-        45, 40, 286, 287, 281, 281, 281, 308,
-        281, 281, 289, 281, 304, 305, 306, 310,
-        45, 40, 286, 287, 281, 281, 73, 308,
-        281, 281, 289, 281, 302, 281, 356, 281,
-        339, 339, 45, 40, 286, 287, 281, 281,
-        281, 294, 281, 302, 281, 302, 281, 281,
-        281, 330, 330, 281, 40, 286, 287, 281,
-        281, 281, 294, 281, 302, 281, 302, 281,
-        281, 281, 330, 357, 281, 40, 286, 287,
-        281, 281, 281, 294, 281, 302, 281, 302,
-        281, 356, 281, 330, 330, 281, 40, 286,
-        287, 281, 281, 281, 294, 281, 302, 281,
-        302, 42, 281, 281, 58, 303, 281, 40,
-        286, 287, 281, 281, 281, 294, 281, 302,
-        281, 295, 296, 301, 301, 45, 40, 286,
-        287, 281, 281, 281, 299, 281, 281, 289,
-        281, 295, 296, 297, 301, 45, 40, 286,
-        287, 281, 281, 75, 299, 281, 281, 289,
-        281, 292, 281, 358, 281, 339, 339, 45,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        292, 281, 292, 281, 281, 281, 330, 330,
-        281, 40, 286, 287, 281, 281, 281, 294,
-        281, 292, 281, 292, 281, 281, 281, 330,
-        359, 281, 40, 286, 287, 281, 281, 281,
-        294, 281, 292, 281, 292, 281, 358, 281,
-        330, 330, 281, 40, 286, 287, 281, 281,
-        281, 294, 281, 292, 281, 76, 44, 44,
-        45, 40, 281, 281, 281, 281, 281, 76,
-        281, 292, 42, 281, 281, 58, 293, 281,
-        40, 286, 287, 281, 281, 281, 294, 281,
-        292, 281, 282, 283, 291, 285, 45, 40,
-        286, 287, 281, 281, 281, 288, 281, 281,
-        289, 281, 361, 191, 362, 362, 84, 79,
-        194, 195, 360, 360, 360, 197, 360, 360,
-        200, 360, 191, 362, 362, 84, 79, 194,
-        195, 360, 360, 360, 197, 360, 360, 200,
-        360, 363, 360, 360, 360, 98, 364, 360,
-        79, 194, 195, 360, 360, 360, 365, 360,
-        363, 360, 366, 367, 368, 369, 84, 79,
-        194, 195, 360, 360, 115, 370, 360, 360,
-        200, 360, 371, 367, 372, 372, 84, 79,
-        194, 195, 360, 360, 360, 370, 360, 360,
-        200, 360, 367, 372, 372, 84, 79, 194,
-        195, 360, 360, 360, 370, 360, 360, 200,
-        360, 373, 360, 360, 360, 98, 374, 360,
-        79, 194, 195, 360, 360, 360, 365, 360,
-        373, 360, 375, 376, 377, 378, 84, 79,
-        194, 195, 360, 360, 113, 379, 360, 360,
-        200, 360, 380, 376, 381, 381, 84, 79,
-        194, 195, 360, 360, 360, 379, 360, 360,
-        200, 360, 376, 381, 381, 84, 79, 194,
-        195, 360, 360, 360, 379, 360, 360, 200,
-        360, 382, 360, 360, 360, 98, 383, 360,
-        79, 194, 195, 360, 360, 360, 365, 360,
-        382, 360, 384, 385, 386, 387, 84, 79,
-        194, 195, 360, 360, 111, 388, 360, 360,
-        200, 360, 389, 385, 390, 390, 84, 79,
-        194, 195, 360, 360, 360, 388, 360, 360,
-        200, 360, 385, 390, 390, 84, 79, 194,
-        195, 360, 360, 360, 388, 360, 360, 200,
-        360, 391, 360, 360, 360, 98, 392, 360,
-        79, 194, 195, 360, 360, 360, 365, 360,
-        391, 360, 393, 394, 395, 396, 84, 79,
-        194, 195, 360, 360, 109, 397, 360, 360,
-        200, 360, 398, 394, 399, 399, 84, 79,
-        194, 195, 360, 360, 360, 397, 360, 360,
-        200, 360, 394, 399, 399, 84, 79, 194,
-        195, 360, 360, 360, 397, 360, 360, 200,
-        360, 98, 400, 360, 79, 194, 195, 360,
-        360, 360, 365, 360, 401, 401, 360, 79,
-        194, 195, 360, 360, 360, 365, 360, 402,
-        360, 360, 403, 194, 195, 360, 194, 195,
-        360, 404, 360, 194, 405, 360, 194, 406,
-        360, 194, 360, 402, 360, 360, 360, 194,
-        195, 360, 407, 360, 408, 409, 360, 79,
-        194, 195, 360, 360, 82, 360, 81, 360,
-        401, 401, 360, 79, 194, 195, 360, 401,
-        401, 360, 79, 194, 195, 360, 407, 360,
-        401, 401, 360, 79, 194, 195, 360, 407,
-        360, 408, 401, 360, 79, 194, 195, 360,
-        360, 82, 360, 98, 360, 410, 410, 84,
-        79, 194, 195, 360, 360, 360, 365, 360,
-        411, 107, 412, 413, 88, 79, 194, 195,
-        360, 360, 360, 365, 360, 107, 412, 413,
-        88, 79, 194, 195, 360, 360, 360, 365,
-        360, 412, 412, 88, 79, 194, 195, 360,
-        360, 360, 365, 360, 414, 104, 415, 416,
-        91, 79, 194, 195, 360, 360, 360, 365,
-        360, 104, 415, 416, 91, 79, 194, 195,
-        360, 360, 360, 365, 360, 415, 415, 91,
-        79, 194, 195, 360, 360, 360, 365, 360,
-        417, 101, 418, 419, 94, 79, 194, 195,
-        360, 360, 360, 365, 360, 101, 418, 419,
-        94, 79, 194, 195, 360, 360, 360, 365,
-        360, 418, 418, 94, 79, 194, 195, 360,
-        360, 360, 365, 360, 420, 98, 401, 421,
-        360, 79, 194, 195, 360, 360, 360, 365,
-        360, 98, 401, 421, 360, 79, 194, 195,
-        360, 360, 360, 365, 360, 401, 422, 360,
-        79, 194, 195, 360, 360, 360, 365, 360,
-        98, 360, 401, 401, 360, 79, 194, 195,
-        360, 360, 360, 365, 360, 80, 81, 360,
-        360, 98, 400, 360, 79, 194, 195, 360,
-        360, 360, 365, 360, 80, 360, 394, 399,
-        399, 84, 79, 194, 195, 360, 360, 360,
-        397, 360, 393, 394, 399, 399, 84, 79,
-        194, 195, 360, 360, 360, 397, 360, 360,
-        200, 360, 393, 394, 395, 399, 84, 79,
-        194, 195, 360, 360, 109, 397, 360, 360,
-        200, 360, 391, 360, 423, 360, 410, 410,
-        84, 79, 194, 195, 360, 360, 360, 365,
-        360, 391, 360, 391, 360, 360, 360, 401,
-        401, 360, 79, 194, 195, 360, 360, 360,
-        365, 360, 391, 360, 391, 360, 360, 360,
-        401, 424, 360, 79, 194, 195, 360, 360,
-        360, 365, 360, 391, 360, 391, 360, 423,
-        360, 401, 401, 360, 79, 194, 195, 360,
-        360, 360, 365, 360, 391, 360, 391, 81,
-        360, 360, 98, 392, 360, 79, 194, 195,
-        360, 360, 360, 365, 360, 391, 360, 384,
-        385, 390, 390, 84, 79, 194, 195, 360,
-        360, 360, 388, 360, 360, 200, 360, 384,
-        385, 386, 390, 84, 79, 194, 195, 360,
-        360, 111, 388, 360, 360, 200, 360, 382,
-        360, 425, 360, 410, 410, 84, 79, 194,
-        195, 360, 360, 360, 365, 360, 382, 360,
-        382, 360, 360, 360, 401, 401, 360, 79,
-        194, 195, 360, 360, 360, 365, 360, 382,
-        360, 382, 360, 360, 360, 401, 426, 360,
-        79, 194, 195, 360, 360, 360, 365, 360,
-        382, 360, 382, 360, 425, 360, 401, 401,
-        360, 79, 194, 195, 360, 360, 360, 365,
-        360, 382, 360, 382, 81, 360, 360, 98,
-        383, 360, 79, 194, 195, 360, 360, 360,
-        365, 360, 382, 360, 375, 376, 381, 381,
-        84, 79, 194, 195, 360, 360, 360, 379,
-        360, 360, 200, 360, 375, 376, 377, 381,
-        84, 79, 194, 195, 360, 360, 113, 379,
-        360, 360, 200, 360, 373, 360, 427, 360,
-        410, 410, 84, 79, 194, 195, 360, 360,
-        360, 365, 360, 373, 360, 373, 360, 360,
-        360, 401, 401, 360, 79, 194, 195, 360,
-        360, 360, 365, 360, 373, 360, 373, 360,
-        360, 360, 401, 428, 360, 79, 194, 195,
-        360, 360, 360, 365, 360, 373, 360, 373,
-        360, 427, 360, 401, 401, 360, 79, 194,
-        195, 360, 360, 360, 365, 360, 373, 360,
-        373, 81, 360, 360, 98, 374, 360, 79,
-        194, 195, 360, 360, 360, 365, 360, 373,
-        360, 366, 367, 372, 372, 84, 79, 194,
-        195, 360, 360, 360, 370, 360, 360, 200,
-        360, 366, 367, 368, 372, 84, 79, 194,
-        195, 360, 360, 115, 370, 360, 360, 200,
-        360, 363, 360, 429, 360, 410, 410, 84,
-        79, 194, 195, 360, 360, 360, 365, 360,
-        363, 360, 363, 360, 360, 360, 401, 401,
-        360, 79, 194, 195, 360, 360, 360, 365,
-        360, 363, 360, 363, 360, 360, 360, 401,
-        430, 360, 79, 194, 195, 360, 360, 360,
-        365, 360, 363, 360, 363, 360, 429, 360,
-        401, 401, 360, 79, 194, 195, 360, 360,
-        360, 365, 360, 363, 360, 363, 81, 360,
-        360, 98, 364, 360, 79, 194, 195, 360,
-        360, 360, 365, 360, 363, 360, 116, 83,
-        83, 84, 79, 431, 431, 431, 431, 156,
-        116, 431, 190, 191, 362, 362, 84, 79,
-        194, 195, 360, 360, 360, 197, 360, 360,
-        200, 360, 116, 83, 83, 84, 79, 431,
-        431, 431, 431, 431, 116, 431, 433, 434,
-        435, 436, 123, 118, 437, 438, 432, 432,
-        155, 439, 432, 432, 440, 432, 441, 434,
-        436, 436, 123, 118, 437, 438, 432, 432,
-        432, 439, 432, 432, 440, 432, 434, 436,
-        436, 123, 118, 437, 438, 432, 432, 432,
-        439, 432, 432, 440, 432, 442, 432, 432,
-        432, 136, 443, 432, 118, 437, 438, 432,
-        432, 432, 444, 432, 442, 432, 445, 446,
-        447, 448, 123, 118, 437, 438, 432, 432,
-        153, 449, 432, 432, 440, 432, 450, 446,
-        451, 451, 123, 118, 437, 438, 432, 432,
-        432, 449, 432, 432, 440, 432, 446, 451,
-        451, 123, 118, 437, 438, 432, 432, 432,
-        449, 432, 432, 440, 432, 452, 432, 432,
-        432, 136, 453, 432, 118, 437, 438, 432,
-        432, 432, 444, 432, 452, 432, 454, 455,
-        456, 457, 123, 118, 437, 438, 432, 432,
-        151, 458, 432, 432, 440, 432, 459, 455,
-        460, 460, 123, 118, 437, 438, 432, 432,
-        432, 458, 432, 432, 440, 432, 455, 460,
-        460, 123, 118, 437, 438, 432, 432, 432,
-        458, 432, 432, 440, 432, 461, 432, 432,
-        432, 136, 462, 432, 118, 437, 438, 432,
-        432, 432, 444, 432, 461, 432, 463, 464,
-        465, 466, 123, 118, 437, 438, 432, 432,
-        149, 467, 432, 432, 440, 432, 468, 464,
-        469, 469, 123, 118, 437, 438, 432, 432,
-        432, 467, 432, 432, 440, 432, 464, 469,
-        469, 123, 118, 437, 438, 432, 432, 432,
-        467, 432, 432, 440, 432, 470, 432, 432,
-        432, 136, 471, 432, 118, 437, 438, 432,
-        432, 432, 444, 432, 470, 432, 472, 473,
-        474, 475, 123, 118, 437, 438, 432, 432,
-        147, 476, 432, 432, 440, 432, 477, 473,
-        478, 478, 123, 118, 437, 438, 432, 432,
-        432, 476, 432, 432, 440, 432, 473, 478,
-        478, 123, 118, 437, 438, 432, 432, 432,
-        476, 432, 432, 440, 432, 136, 479, 432,
-        118, 437, 438, 432, 432, 432, 444, 432,
-        480, 480, 432, 118, 437, 438, 432, 432,
-        432, 444, 432, 481, 432, 432, 482, 437,
-        438, 432, 437, 438, 432, 483, 432, 437,
-        484, 432, 437, 485, 432, 437, 432, 481,
-        432, 432, 432, 437, 438, 432, 486, 432,
-        487, 488, 432, 118, 437, 438, 432, 432,
-        121, 432, 120, 432, 480, 480, 432, 118,
-        437, 438, 432, 480, 480, 432, 118, 437,
-        438, 432, 486, 432, 480, 480, 432, 118,
-        437, 438, 432, 486, 432, 487, 480, 432,
-        118, 437, 438, 432, 432, 121, 432, 136,
-        432, 489, 489, 123, 118, 437, 438, 432,
-        432, 432, 444, 432, 490, 145, 491, 492,
-        126, 118, 437, 438, 432, 432, 432, 444,
-        432, 145, 491, 492, 126, 118, 437, 438,
-        432, 432, 432, 444, 432, 491, 491, 126,
-        118, 437, 438, 432, 432, 432, 444, 432,
-        493, 142, 494, 495, 129, 118, 437, 438,
-        432, 432, 432, 444, 432, 142, 494, 495,
-        129, 118, 437, 438, 432, 432, 432, 444,
-        432, 494, 494, 129, 118, 437, 438, 432,
-        432, 432, 444, 432, 496, 139, 497, 498,
-        132, 118, 437, 438, 432, 432, 432, 444,
-        432, 139, 497, 498, 132, 118, 437, 438,
-        432, 432, 432, 444, 432, 497, 497, 132,
-        118, 437, 438, 432, 432, 432, 444, 432,
-        499, 136, 480, 500, 432, 118, 437, 438,
-        432, 432, 432, 444, 432, 136, 480, 500,
-        432, 118, 437, 438, 432, 432, 432, 444,
-        432, 480, 501, 432, 118, 437, 438, 432,
-        432, 432, 444, 432, 136, 432, 480, 480,
-        432, 118, 437, 438, 432, 432, 432, 444,
-        432, 119, 120, 432, 432, 136, 479, 432,
-        118, 437, 438, 432, 432, 432, 444, 432,
-        119, 432, 473, 478, 478, 123, 118, 437,
-        438, 432, 432, 432, 476, 432, 472, 473,
-        478, 478, 123, 118, 437, 438, 432, 432,
-        432, 476, 432, 432, 440, 432, 472, 473,
-        474, 478, 123, 118, 437, 438, 432, 432,
-        147, 476, 432, 432, 440, 432, 470, 432,
-        502, 432, 489, 489, 123, 118, 437, 438,
-        432, 432, 432, 444, 432, 470, 432, 470,
-        432, 432, 432, 480, 480, 432, 118, 437,
-        438, 432, 432, 432, 444, 432, 470, 432,
-        470, 432, 432, 432, 480, 503, 432, 118,
-        437, 438, 432, 432, 432, 444, 432, 470,
-        432, 470, 432, 502, 432, 480, 480, 432,
-        118, 437, 438, 432, 432, 432, 444, 432,
-        470, 432, 470, 120, 432, 432, 136, 471,
-        432, 118, 437, 438, 432, 432, 432, 444,
-        432, 470, 432, 463, 464, 469, 469, 123,
-        118, 437, 438, 432, 432, 432, 467, 432,
-        432, 440, 432, 463, 464, 465, 469, 123,
-        118, 437, 438, 432, 432, 149, 467, 432,
-        432, 440, 432, 461, 432, 504, 432, 489,
-        489, 123, 118, 437, 438, 432, 432, 432,
-        444, 432, 461, 432, 461, 432, 432, 432,
-        480, 480, 432, 118, 437, 438, 432, 432,
-        432, 444, 432, 461, 432, 461, 432, 432,
-        432, 480, 505, 432, 118, 437, 438, 432,
-        432, 432, 444, 432, 461, 432, 461, 432,
-        504, 432, 480, 480, 432, 118, 437, 438,
-        432, 432, 432, 444, 432, 461, 432, 461,
-        120, 432, 432, 136, 462, 432, 118, 437,
-        438, 432, 432, 432, 444, 432, 461, 432,
-        454, 455, 460, 460, 123, 118, 437, 438,
-        432, 432, 432, 458, 432, 432, 440, 432,
-        454, 455, 456, 460, 123, 118, 437, 438,
-        432, 432, 151, 458, 432, 432, 440, 432,
-        452, 432, 506, 432, 489, 489, 123, 118,
-        437, 438, 432, 432, 432, 444, 432, 452,
-        432, 452, 432, 432, 432, 480, 480, 432,
-        118, 437, 438, 432, 432, 432, 444, 432,
-        452, 432, 452, 432, 432, 432, 480, 507,
-        432, 118, 437, 438, 432, 432, 432, 444,
-        432, 452, 432, 452, 432, 506, 432, 480,
-        480, 432, 118, 437, 438, 432, 432, 432,
-        444, 432, 452, 432, 452, 120, 432, 432,
-        136, 453, 432, 118, 437, 438, 432, 432,
-        432, 444, 432, 452, 432, 445, 446, 451,
-        451, 123, 118, 437, 438, 432, 432, 432,
-        449, 432, 432, 440, 432, 445, 446, 447,
-        451, 123, 118, 437, 438, 432, 432, 153,
-        449, 432, 432, 440, 432, 442, 432, 508,
-        432, 489, 489, 123, 118, 437, 438, 432,
-        432, 432, 444, 432, 442, 432, 442, 432,
-        432, 432, 480, 480, 432, 118, 437, 438,
-        432, 432, 432, 444, 432, 442, 432, 442,
-        432, 432, 432, 480, 509, 432, 118, 437,
-        438, 432, 432, 432, 444, 432, 442, 432,
-        442, 432, 508, 432, 480, 480, 432, 118,
-        437, 438, 432, 432, 432, 444, 432, 442,
-        432, 442, 120, 432, 432, 136, 443, 432,
-        118, 437, 438, 432, 432, 432, 444, 432,
-        442, 432, 433, 434, 436, 436, 123, 118,
-        437, 438, 432, 432, 432, 439, 432, 432,
-        440, 432, 188, 189, 190, 191, 510, 362,
-        84, 79, 194, 195, 196, 196, 156, 197,
-        360, 188, 200, 360, 203, 511, 205, 206,
-        6, 1, 207, 208, 202, 202, 38, 209,
-        202, 202, 210, 202, 213, 189, 190, 191,
-        512, 513, 84, 157, 514, 515, 202, 196,
-        156, 516, 202, 213, 200, 202, 116, 517,
-        517, 84, 157, 207, 208, 202, 202, 156,
-        518, 202, 519, 202, 202, 520, 514, 515,
-        202, 514, 515, 202, 254, 202, 514, 521,
-        202, 514, 522, 202, 514, 202, 519, 202,
-        202, 202, 514, 515, 202, 523, 3, 360,
-        360, 401, 430, 360, 79, 194, 195, 360,
-        360, 360, 365, 360, 523, 360, 524, 367,
-        525, 526, 84, 157, 514, 515, 202, 202,
-        158, 370, 202, 202, 200, 202, 527, 367,
-        528, 528, 84, 157, 514, 515, 202, 202,
-        202, 370, 202, 202, 200, 202, 367, 528,
-        528, 84, 157, 514, 515, 202, 202, 202,
-        370, 202, 202, 200, 202, 524, 367, 528,
-        528, 84, 157, 514, 515, 202, 202, 202,
-        370, 202, 202, 200, 202, 524, 367, 525,
-        528, 84, 157, 514, 515, 202, 202, 158,
-        370, 202, 202, 200, 202, 213, 202, 279,
-        116, 529, 529, 160, 157, 207, 208, 202,
-        202, 202, 518, 202, 213, 202, 530, 184,
-        531, 532, 162, 157, 514, 515, 202, 202,
-        202, 533, 202, 184, 531, 532, 162, 157,
-        514, 515, 202, 202, 202, 533, 202, 531,
-        531, 162, 157, 514, 515, 202, 202, 202,
-        533, 202, 534, 181, 535, 536, 165, 157,
-        514, 515, 202, 202, 202, 533, 202, 181,
-        535, 536, 165, 157, 514, 515, 202, 202,
-        202, 533, 202, 535, 535, 165, 157, 514,
-        515, 202, 202, 202, 533, 202, 537, 178,
-        538, 539, 168, 157, 514, 515, 202, 202,
-        202, 533, 202, 178, 538, 539, 168, 157,
-        514, 515, 202, 202, 202, 533, 202, 538,
-        538, 168, 157, 514, 515, 202, 202, 202,
-        533, 202, 540, 175, 541, 542, 202, 157,
-        514, 515, 202, 202, 202, 533, 202, 175,
-        541, 542, 202, 157, 514, 515, 202, 202,
-        202, 533, 202, 541, 541, 202, 157, 514,
-        515, 202, 202, 202, 533, 202, 543, 202,
-        544, 545, 202, 157, 514, 515, 202, 202,
-        172, 202, 171, 202, 541, 541, 202, 157,
-        514, 515, 202, 541, 541, 202, 157, 514,
-        515, 202, 543, 202, 541, 541, 202, 157,
-        514, 515, 202, 543, 202, 544, 541, 202,
-        157, 514, 515, 202, 202, 172, 202, 523,
-        171, 360, 360, 98, 364, 360, 79, 194,
-        195, 360, 360, 360, 365, 360, 523, 360,
-        547, 546, 548, 548, 546, 186, 549, 550,
-        546, 548, 548, 546, 186, 549, 550, 546,
-        551, 546, 546, 552, 549, 550, 546, 549,
-        550, 546, 553, 546, 549, 554, 546, 549,
-        555, 546, 549, 546, 551, 546, 546, 546,
+        1, 0, 2, 3, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 2, 0, 1, 0, 0, 0, 0, 
+        4, 0, 5, 5, 6, 1, 0, 7, 
+        7, 6, 0, 6, 0, 8, 8, 9, 
+        1, 0, 10, 10, 9, 0, 9, 0, 
+        11, 11, 12, 1, 0, 13, 13, 12, 
+        0, 12, 0, 14, 14, 15, 1, 0, 
+        16, 16, 15, 0, 15, 0, 17, 0, 
+        0, 0, 1, 0, 18, 0, 19, 0, 
+        20, 14, 14, 15, 1, 0, 21, 0, 
+        22, 0, 23, 11, 11, 12, 1, 0, 
+        24, 0, 25, 0, 26, 8, 8, 9, 
+        1, 0, 27, 0, 28, 0, 29, 5, 
+        5, 6, 1, 0, 0, 0, 0, 0, 
+        29, 0, 29, 5, 5, 6, 1, 0, 
+        0, 0, 0, 30, 29, 0, 31, 5, 
+        5, 6, 1, 0, 0, 0, 0, 0, 
+        31, 0, 31, 5, 5, 6, 1, 0, 
+        0, 0, 0, 32, 31, 0, 33, 5, 
+        5, 6, 1, 0, 0, 0, 0, 0, 
+        33, 0, 33, 5, 5, 6, 1, 0, 
+        0, 0, 0, 34, 33, 0, 35, 5, 
+        5, 6, 1, 0, 0, 0, 0, 0, 
+        35, 0, 35, 5, 5, 6, 1, 0, 
+        0, 0, 0, 36, 35, 0, 37, 5, 
+        5, 6, 1, 0, 0, 0, 0, 0, 
+        37, 0, 37, 5, 5, 6, 1, 0, 
+        0, 0, 0, 38, 37, 0, 40, 39, 
+        41, 42, 39, 39, 39, 39, 39, 39, 
+        39, 39, 39, 39, 39, 39, 39, 41, 
+        39, 40, 39, 39, 39, 39, 43, 39, 
+        44, 44, 45, 40, 39, 46, 46, 45, 
+        39, 45, 39, 47, 47, 48, 40, 39, 
+        49, 49, 48, 39, 48, 39, 50, 50, 
+        51, 40, 39, 52, 52, 51, 39, 51, 
+        39, 53, 53, 54, 40, 39, 55, 55, 
+        54, 39, 54, 39, 56, 39, 39, 39, 
+        40, 39, 57, 39, 58, 39, 59, 53, 
+        53, 54, 40, 39, 60, 39, 61, 39, 
+        62, 50, 50, 51, 40, 39, 63, 39, 
+        64, 39, 65, 47, 47, 48, 40, 39, 
+        66, 39, 67, 39, 68, 44, 44, 45, 
+        40, 39, 39, 39, 39, 39, 68, 39, 
+        68, 44, 44, 45, 40, 39, 39, 39, 
+        39, 69, 68, 39, 70, 44, 44, 45, 
+        40, 39, 39, 39, 39, 39, 70, 39, 
+        70, 44, 44, 45, 40, 39, 39, 39, 
+        39, 71, 70, 39, 72, 44, 44, 45, 
+        40, 39, 39, 39, 39, 39, 72, 39, 
+        72, 44, 44, 45, 40, 39, 39, 39, 
+        39, 73, 72, 39, 74, 44, 44, 45, 
+        40, 39, 39, 39, 39, 39, 74, 39, 
+        74, 44, 44, 45, 40, 39, 39, 39, 
+        39, 75, 74, 39, 76, 44, 44, 45, 
+        40, 39, 39, 39, 39, 39, 76, 39, 
+        76, 44, 44, 45, 40, 39, 39, 39, 
+        39, 77, 76, 39, 79, 78, 80, 81, 
+        78, 78, 78, 78, 78, 78, 78, 78, 
+        78, 78, 78, 78, 78, 80, 78, 79, 
+        78, 78, 78, 78, 82, 78, 83, 83, 
+        84, 79, 78, 86, 86, 84, 85, 84, 
+        85, 87, 87, 88, 79, 78, 89, 89, 
+        88, 78, 88, 78, 90, 90, 91, 79, 
+        78, 92, 92, 91, 78, 91, 78, 93, 
+        93, 94, 79, 78, 95, 95, 94, 78, 
+        94, 78, 96, 78, 78, 78, 79, 78, 
+        97, 78, 98, 78, 99, 93, 93, 94, 
+        79, 78, 100, 78, 101, 78, 102, 90, 
+        90, 91, 79, 78, 103, 78, 104, 78, 
+        105, 87, 87, 88, 79, 78, 106, 78, 
+        107, 78, 108, 83, 83, 84, 79, 78, 
+        78, 78, 78, 78, 108, 78, 108, 83, 
+        83, 84, 79, 78, 78, 78, 78, 109, 
+        108, 78, 110, 83, 83, 84, 79, 78, 
+        78, 78, 78, 78, 110, 78, 110, 83, 
+        83, 84, 79, 78, 78, 78, 78, 111, 
+        110, 78, 112, 83, 83, 84, 79, 78, 
+        78, 78, 78, 78, 112, 78, 112, 83, 
+        83, 84, 79, 78, 78, 78, 78, 113, 
+        112, 78, 114, 83, 83, 84, 79, 78, 
+        78, 78, 78, 78, 114, 78, 114, 83, 
+        83, 84, 79, 78, 78, 78, 78, 115, 
+        114, 78, 116, 83, 83, 84, 79, 78, 
+        78, 78, 78, 78, 116, 78, 118, 117, 
+        119, 120, 117, 117, 117, 117, 117, 117, 
+        117, 117, 117, 117, 117, 117, 117, 119, 
+        117, 118, 117, 117, 117, 117, 121, 117, 
+        122, 122, 123, 118, 117, 124, 124, 123, 
+        117, 123, 117, 125, 125, 126, 118, 117, 
+        127, 127, 126, 117, 126, 117, 128, 128, 
+        129, 118, 117, 130, 130, 129, 117, 129, 
+        117, 131, 131, 132, 118, 117, 133, 133, 
+        132, 117, 132, 117, 134, 117, 117, 117, 
+        118, 117, 135, 117, 136, 117, 137, 131, 
+        131, 132, 118, 117, 138, 117, 139, 117, 
+        140, 128, 128, 129, 118, 117, 141, 117, 
+        142, 117, 143, 125, 125, 126, 118, 117, 
+        144, 117, 145, 117, 146, 122, 122, 123, 
+        118, 117, 117, 117, 117, 117, 146, 117, 
+        146, 122, 122, 123, 118, 117, 117, 117, 
+        117, 147, 146, 117, 148, 122, 122, 123, 
+        118, 117, 117, 117, 117, 117, 148, 117, 
+        148, 122, 122, 123, 118, 117, 117, 117, 
+        117, 149, 148, 117, 150, 122, 122, 123, 
+        118, 117, 117, 117, 117, 117, 150, 117, 
+        150, 122, 122, 123, 118, 117, 117, 117, 
+        117, 151, 150, 117, 152, 122, 122, 123, 
+        118, 117, 117, 117, 117, 117, 152, 117, 
+        152, 122, 122, 123, 118, 117, 117, 117, 
+        117, 153, 152, 117, 154, 122, 122, 123, 
+        118, 117, 117, 117, 117, 117, 154, 117, 
+        154, 122, 122, 123, 118, 117, 117, 117, 
+        117, 155, 154, 117, 116, 83, 83, 84, 
+        79, 78, 78, 78, 78, 156, 116, 78, 
+        86, 86, 84, 1, 0, 114, 83, 83, 
+        84, 157, 0, 0, 0, 0, 0, 114, 
+        0, 114, 83, 83, 84, 157, 0, 0, 
+        0, 0, 158, 114, 0, 159, 159, 160, 
+        1, 0, 7, 7, 160, 0, 161, 161, 
+        162, 157, 0, 163, 163, 162, 0, 162, 
+        0, 164, 164, 165, 157, 0, 166, 166, 
+        165, 0, 165, 0, 167, 167, 168, 157, 
+        0, 169, 169, 168, 0, 168, 0, 157, 
+        0, 170, 171, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        170, 0, 157, 0, 0, 0, 0, 172, 
+        0, 173, 0, 0, 0, 157, 0, 174, 
+        0, 175, 0, 176, 167, 167, 168, 157, 
+        0, 177, 0, 178, 0, 179, 164, 164, 
+        165, 157, 0, 180, 0, 181, 0, 182, 
+        161, 161, 162, 157, 0, 183, 0, 184, 
+        0, 186, 185, 188, 189, 190, 191, 192, 
+        193, 84, 79, 194, 195, 196, 196, 156, 
+        197, 198, 199, 200, 201, 187, 203, 204, 
+        205, 206, 6, 1, 207, 208, 202, 202, 
+        38, 209, 202, 202, 210, 202, 211, 204, 
+        212, 212, 6, 1, 207, 208, 202, 202, 
+        202, 209, 202, 202, 210, 202, 204, 212, 
+        212, 6, 1, 207, 208, 202, 202, 202, 
+        209, 202, 202, 210, 202, 213, 202, 202, 
+        202, 19, 214, 202, 1, 207, 208, 202, 
+        202, 202, 215, 202, 213, 202, 216, 217, 
+        218, 219, 6, 1, 207, 208, 202, 202, 
+        36, 220, 202, 202, 210, 202, 221, 217, 
+        222, 222, 6, 1, 207, 208, 202, 202, 
+        202, 220, 202, 202, 210, 202, 217, 222, 
+        222, 6, 1, 207, 208, 202, 202, 202, 
+        220, 202, 202, 210, 202, 223, 202, 202, 
+        202, 19, 224, 202, 1, 207, 208, 202, 
+        202, 202, 215, 202, 223, 202, 225, 226, 
+        227, 228, 6, 1, 207, 208, 202, 202, 
+        34, 229, 202, 202, 210, 202, 230, 226, 
+        231, 231, 6, 1, 207, 208, 202, 202, 
+        202, 229, 202, 202, 210, 202, 226, 231, 
+        231, 6, 1, 207, 208, 202, 202, 202, 
+        229, 202, 202, 210, 202, 232, 202, 202, 
+        202, 19, 233, 202, 1, 207, 208, 202, 
+        202, 202, 215, 202, 232, 202, 234, 235, 
+        236, 237, 6, 1, 207, 208, 202, 202, 
+        32, 238, 202, 202, 210, 202, 239, 235, 
+        240, 240, 6, 1, 207, 208, 202, 202, 
+        202, 238, 202, 202, 210, 202, 235, 240, 
+        240, 6, 1, 207, 208, 202, 202, 202, 
+        238, 202, 202, 210, 202, 241, 202, 202, 
+        202, 19, 242, 202, 1, 207, 208, 202, 
+        202, 202, 215, 202, 241, 202, 243, 244, 
+        245, 246, 6, 1, 207, 208, 202, 202, 
+        30, 247, 202, 202, 210, 202, 248, 244, 
+        249, 249, 6, 1, 207, 208, 202, 202, 
+        202, 247, 202, 202, 210, 202, 244, 249, 
+        249, 6, 1, 207, 208, 202, 202, 202, 
+        247, 202, 202, 210, 202, 19, 250, 202, 
+        1, 207, 208, 202, 202, 202, 215, 202, 
+        251, 251, 202, 1, 207, 208, 202, 202, 
+        202, 215, 202, 252, 202, 202, 253, 207, 
+        208, 202, 207, 208, 202, 254, 202, 207, 
+        255, 202, 207, 256, 202, 207, 202, 252, 
+        202, 202, 202, 207, 208, 202, 257, 202, 
+        258, 259, 202, 1, 207, 208, 202, 202, 
+        4, 202, 3, 202, 251, 251, 202, 1, 
+        207, 208, 202, 251, 251, 202, 1, 207, 
+        208, 202, 257, 202, 251, 251, 202, 1, 
+        207, 208, 202, 257, 202, 258, 251, 202, 
+        1, 207, 208, 202, 202, 4, 202, 19, 
+        202, 260, 260, 6, 1, 207, 208, 202, 
+        202, 202, 215, 202, 261, 28, 262, 263, 
+        9, 1, 207, 208, 202, 202, 202, 215, 
+        202, 28, 262, 263, 9, 1, 207, 208, 
+        202, 202, 202, 215, 202, 262, 262, 9, 
+        1, 207, 208, 202, 202, 202, 215, 202, 
+        264, 25, 265, 266, 12, 1, 207, 208, 
+        202, 202, 202, 215, 202, 25, 265, 266, 
+        12, 1, 207, 208, 202, 202, 202, 215, 
+        202, 265, 265, 12, 1, 207, 208, 202, 
+        202, 202, 215, 202, 267, 22, 268, 269, 
+        15, 1, 207, 208, 202, 202, 202, 215, 
+        202, 22, 268, 269, 15, 1, 207, 208, 
+        202, 202, 202, 215, 202, 268, 268, 15, 
+        1, 207, 208, 202, 202, 202, 215, 202, 
+        270, 19, 251, 271, 202, 1, 207, 208, 
+        202, 202, 202, 215, 202, 19, 251, 271, 
+        202, 1, 207, 208, 202, 202, 202, 215, 
+        202, 251, 272, 202, 1, 207, 208, 202, 
+        202, 202, 215, 202, 19, 202, 251, 251, 
+        202, 1, 207, 208, 202, 202, 202, 215, 
+        202, 2, 3, 202, 202, 19, 250, 202, 
+        1, 207, 208, 202, 202, 202, 215, 202, 
+        2, 202, 244, 249, 249, 6, 1, 207, 
+        208, 202, 202, 202, 247, 202, 243, 244, 
+        249, 249, 6, 1, 207, 208, 202, 202, 
+        202, 247, 202, 202, 210, 202, 243, 244, 
+        245, 249, 6, 1, 207, 208, 202, 202, 
+        30, 247, 202, 202, 210, 202, 241, 202, 
+        273, 202, 260, 260, 6, 1, 207, 208, 
+        202, 202, 202, 215, 202, 241, 202, 241, 
+        202, 202, 202, 251, 251, 202, 1, 207, 
+        208, 202, 202, 202, 215, 202, 241, 202, 
+        241, 202, 202, 202, 251, 274, 202, 1, 
+        207, 208, 202, 202, 202, 215, 202, 241, 
+        202, 241, 202, 273, 202, 251, 251, 202, 
+        1, 207, 208, 202, 202, 202, 215, 202, 
+        241, 202, 241, 3, 202, 202, 19, 242, 
+        202, 1, 207, 208, 202, 202, 202, 215, 
+        202, 241, 202, 234, 235, 240, 240, 6, 
+        1, 207, 208, 202, 202, 202, 238, 202, 
+        202, 210, 202, 234, 235, 236, 240, 6, 
+        1, 207, 208, 202, 202, 32, 238, 202, 
+        202, 210, 202, 232, 202, 275, 202, 260, 
+        260, 6, 1, 207, 208, 202, 202, 202, 
+        215, 202, 232, 202, 232, 202, 202, 202, 
+        251, 251, 202, 1, 207, 208, 202, 202, 
+        202, 215, 202, 232, 202, 232, 202, 202, 
+        202, 251, 276, 202, 1, 207, 208, 202, 
+        202, 202, 215, 202, 232, 202, 232, 202, 
+        275, 202, 251, 251, 202, 1, 207, 208, 
+        202, 202, 202, 215, 202, 232, 202, 232, 
+        3, 202, 202, 19, 233, 202, 1, 207, 
+        208, 202, 202, 202, 215, 202, 232, 202, 
+        225, 226, 231, 231, 6, 1, 207, 208, 
+        202, 202, 202, 229, 202, 202, 210, 202, 
+        225, 226, 227, 231, 6, 1, 207, 208, 
+        202, 202, 34, 229, 202, 202, 210, 202, 
+        223, 202, 277, 202, 260, 260, 6, 1, 
+        207, 208, 202, 202, 202, 215, 202, 223, 
+        202, 223, 202, 202, 202, 251, 251, 202, 
+        1, 207, 208, 202, 202, 202, 215, 202, 
+        223, 202, 223, 202, 202, 202, 251, 278, 
+        202, 1, 207, 208, 202, 202, 202, 215, 
+        202, 223, 202, 223, 202, 277, 202, 251, 
+        251, 202, 1, 207, 208, 202, 202, 202, 
+        215, 202, 223, 202, 223, 3, 202, 202, 
+        19, 224, 202, 1, 207, 208, 202, 202, 
+        202, 215, 202, 223, 202, 216, 217, 222, 
+        222, 6, 1, 207, 208, 202, 202, 202, 
+        220, 202, 202, 210, 202, 216, 217, 218, 
+        222, 6, 1, 207, 208, 202, 202, 36, 
+        220, 202, 202, 210, 202, 213, 202, 279, 
+        202, 260, 260, 6, 1, 207, 208, 202, 
+        202, 202, 215, 202, 213, 202, 213, 202, 
+        202, 202, 251, 251, 202, 1, 207, 208, 
+        202, 202, 202, 215, 202, 213, 202, 213, 
+        202, 202, 202, 251, 280, 202, 1, 207, 
+        208, 202, 202, 202, 215, 202, 213, 202, 
+        213, 202, 279, 202, 251, 251, 202, 1, 
+        207, 208, 202, 202, 202, 215, 202, 213, 
+        202, 213, 3, 202, 202, 19, 214, 202, 
+        1, 207, 208, 202, 202, 202, 215, 202, 
+        213, 202, 203, 204, 212, 212, 6, 1, 
+        207, 208, 202, 202, 202, 209, 202, 202, 
+        210, 202, 203, 204, 205, 212, 6, 1, 
+        207, 208, 202, 202, 38, 209, 202, 202, 
+        210, 202, 282, 283, 284, 285, 45, 40, 
+        286, 287, 281, 281, 77, 288, 281, 281, 
+        289, 281, 290, 283, 291, 285, 45, 40, 
+        286, 287, 281, 281, 281, 288, 281, 281, 
+        289, 281, 283, 291, 285, 45, 40, 286, 
+        287, 281, 281, 281, 288, 281, 281, 289, 
+        281, 292, 281, 281, 281, 58, 293, 281, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        292, 281, 295, 296, 297, 298, 45, 40, 
+        286, 287, 281, 281, 75, 299, 281, 281, 
+        289, 281, 300, 296, 301, 301, 45, 40, 
+        286, 287, 281, 281, 281, 299, 281, 281, 
+        289, 281, 296, 301, 301, 45, 40, 286, 
+        287, 281, 281, 281, 299, 281, 281, 289, 
+        281, 302, 281, 281, 281, 58, 303, 281, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        302, 281, 304, 305, 306, 307, 45, 40, 
+        286, 287, 281, 281, 73, 308, 281, 281, 
+        289, 281, 309, 305, 310, 310, 45, 40, 
+        286, 287, 281, 281, 281, 308, 281, 281, 
+        289, 281, 305, 310, 310, 45, 40, 286, 
+        287, 281, 281, 281, 308, 281, 281, 289, 
+        281, 311, 281, 281, 281, 58, 312, 281, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        311, 281, 313, 314, 315, 316, 45, 40, 
+        286, 287, 281, 281, 71, 317, 281, 281, 
+        289, 281, 318, 314, 319, 319, 45, 40, 
+        286, 287, 281, 281, 281, 317, 281, 281, 
+        289, 281, 314, 319, 319, 45, 40, 286, 
+        287, 281, 281, 281, 317, 281, 281, 289, 
+        281, 320, 281, 281, 281, 58, 321, 281, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        320, 281, 322, 323, 324, 325, 45, 40, 
+        286, 287, 281, 281, 69, 326, 281, 281, 
+        289, 281, 327, 323, 328, 328, 45, 40, 
+        286, 287, 281, 281, 281, 326, 281, 281, 
+        289, 281, 323, 328, 328, 45, 40, 286, 
+        287, 281, 281, 281, 326, 281, 281, 289, 
+        281, 58, 329, 281, 40, 286, 287, 281, 
+        281, 281, 294, 281, 330, 330, 281, 40, 
+        286, 287, 281, 281, 281, 294, 281, 331, 
+        281, 281, 332, 286, 287, 281, 286, 287, 
+        281, 333, 281, 286, 334, 281, 286, 335, 
+        281, 286, 281, 331, 281, 281, 281, 286, 
+        287, 281, 336, 281, 337, 338, 281, 40, 
+        286, 287, 281, 281, 43, 281, 42, 281, 
+        330, 330, 281, 40, 286, 287, 281, 330, 
+        330, 281, 40, 286, 287, 281, 336, 281, 
+        330, 330, 281, 40, 286, 287, 281, 336, 
+        281, 337, 330, 281, 40, 286, 287, 281, 
+        281, 43, 281, 58, 281, 339, 339, 45, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        340, 67, 341, 342, 48, 40, 286, 287, 
+        281, 281, 281, 294, 281, 67, 341, 342, 
+        48, 40, 286, 287, 281, 281, 281, 294, 
+        281, 341, 341, 48, 40, 286, 287, 281, 
+        281, 281, 294, 281, 343, 64, 344, 345, 
+        51, 40, 286, 287, 281, 281, 281, 294, 
+        281, 64, 344, 345, 51, 40, 286, 287, 
+        281, 281, 281, 294, 281, 344, 344, 51, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        346, 61, 347, 348, 54, 40, 286, 287, 
+        281, 281, 281, 294, 281, 61, 347, 348, 
+        54, 40, 286, 287, 281, 281, 281, 294, 
+        281, 347, 347, 54, 40, 286, 287, 281, 
+        281, 281, 294, 281, 349, 58, 330, 350, 
+        281, 40, 286, 287, 281, 281, 281, 294, 
+        281, 58, 330, 350, 281, 40, 286, 287, 
+        281, 281, 281, 294, 281, 330, 351, 281, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        58, 281, 330, 330, 281, 40, 286, 287, 
+        281, 281, 281, 294, 281, 41, 42, 281, 
+        281, 58, 329, 281, 40, 286, 287, 281, 
+        281, 281, 294, 281, 41, 281, 323, 328, 
+        328, 45, 40, 286, 287, 281, 281, 281, 
+        326, 281, 322, 323, 328, 328, 45, 40, 
+        286, 287, 281, 281, 281, 326, 281, 281, 
+        289, 281, 322, 323, 324, 328, 45, 40, 
+        286, 287, 281, 281, 69, 326, 281, 281, 
+        289, 281, 320, 281, 352, 281, 339, 339, 
+        45, 40, 286, 287, 281, 281, 281, 294, 
+        281, 320, 281, 320, 281, 281, 281, 330, 
+        330, 281, 40, 286, 287, 281, 281, 281, 
+        294, 281, 320, 281, 320, 281, 281, 281, 
+        330, 353, 281, 40, 286, 287, 281, 281, 
+        281, 294, 281, 320, 281, 320, 281, 352, 
+        281, 330, 330, 281, 40, 286, 287, 281, 
+        281, 281, 294, 281, 320, 281, 320, 42, 
+        281, 281, 58, 321, 281, 40, 286, 287, 
+        281, 281, 281, 294, 281, 320, 281, 313, 
+        314, 319, 319, 45, 40, 286, 287, 281, 
+        281, 281, 317, 281, 281, 289, 281, 313, 
+        314, 315, 319, 45, 40, 286, 287, 281, 
+        281, 71, 317, 281, 281, 289, 281, 311, 
+        281, 354, 281, 339, 339, 45, 40, 286, 
+        287, 281, 281, 281, 294, 281, 311, 281, 
+        311, 281, 281, 281, 330, 330, 281, 40, 
+        286, 287, 281, 281, 281, 294, 281, 311, 
+        281, 311, 281, 281, 281, 330, 355, 281, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        311, 281, 311, 281, 354, 281, 330, 330, 
+        281, 40, 286, 287, 281, 281, 281, 294, 
+        281, 311, 281, 311, 42, 281, 281, 58, 
+        312, 281, 40, 286, 287, 281, 281, 281, 
+        294, 281, 311, 281, 304, 305, 310, 310, 
+        45, 40, 286, 287, 281, 281, 281, 308, 
+        281, 281, 289, 281, 304, 305, 306, 310, 
+        45, 40, 286, 287, 281, 281, 73, 308, 
+        281, 281, 289, 281, 302, 281, 356, 281, 
+        339, 339, 45, 40, 286, 287, 281, 281, 
+        281, 294, 281, 302, 281, 302, 281, 281, 
+        281, 330, 330, 281, 40, 286, 287, 281, 
+        281, 281, 294, 281, 302, 281, 302, 281, 
+        281, 281, 330, 357, 281, 40, 286, 287, 
+        281, 281, 281, 294, 281, 302, 281, 302, 
+        281, 356, 281, 330, 330, 281, 40, 286, 
+        287, 281, 281, 281, 294, 281, 302, 281, 
+        302, 42, 281, 281, 58, 303, 281, 40, 
+        286, 287, 281, 281, 281, 294, 281, 302, 
+        281, 295, 296, 301, 301, 45, 40, 286, 
+        287, 281, 281, 281, 299, 281, 281, 289, 
+        281, 295, 296, 297, 301, 45, 40, 286, 
+        287, 281, 281, 75, 299, 281, 281, 289, 
+        281, 292, 281, 358, 281, 339, 339, 45, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        292, 281, 292, 281, 281, 281, 330, 330, 
+        281, 40, 286, 287, 281, 281, 281, 294, 
+        281, 292, 281, 292, 281, 281, 281, 330, 
+        359, 281, 40, 286, 287, 281, 281, 281, 
+        294, 281, 292, 281, 292, 281, 358, 281, 
+        330, 330, 281, 40, 286, 287, 281, 281, 
+        281, 294, 281, 292, 281, 76, 44, 44, 
+        45, 40, 281, 281, 281, 281, 281, 76, 
+        281, 292, 42, 281, 281, 58, 293, 281, 
+        40, 286, 287, 281, 281, 281, 294, 281, 
+        292, 281, 282, 283, 291, 285, 45, 40, 
+        286, 287, 281, 281, 281, 288, 281, 281, 
+        289, 281, 361, 191, 362, 362, 84, 79, 
+        194, 195, 360, 360, 360, 197, 360, 360, 
+        200, 360, 191, 362, 362, 84, 79, 194, 
+        195, 360, 360, 360, 197, 360, 360, 200, 
+        360, 363, 360, 360, 360, 98, 364, 360, 
+        79, 194, 195, 360, 360, 360, 365, 360, 
+        363, 360, 366, 367, 368, 369, 84, 79, 
+        194, 195, 360, 360, 115, 370, 360, 360, 
+        200, 360, 371, 367, 372, 372, 84, 79, 
+        194, 195, 360, 360, 360, 370, 360, 360, 
+        200, 360, 367, 372, 372, 84, 79, 194, 
+        195, 360, 360, 360, 370, 360, 360, 200, 
+        360, 373, 360, 360, 360, 98, 374, 360, 
+        79, 194, 195, 360, 360, 360, 365, 360, 
+        373, 360, 375, 376, 377, 378, 84, 79, 
+        194, 195, 360, 360, 113, 379, 360, 360, 
+        200, 360, 380, 376, 381, 381, 84, 79, 
+        194, 195, 360, 360, 360, 379, 360, 360, 
+        200, 360, 376, 381, 381, 84, 79, 194, 
+        195, 360, 360, 360, 379, 360, 360, 200, 
+        360, 382, 360, 360, 360, 98, 383, 360, 
+        79, 194, 195, 360, 360, 360, 365, 360, 
+        382, 360, 384, 385, 386, 387, 84, 79, 
+        194, 195, 360, 360, 111, 388, 360, 360, 
+        200, 360, 389, 385, 390, 390, 84, 79, 
+        194, 195, 360, 360, 360, 388, 360, 360, 
+        200, 360, 385, 390, 390, 84, 79, 194, 
+        195, 360, 360, 360, 388, 360, 360, 200, 
+        360, 391, 360, 360, 360, 98, 392, 360, 
+        79, 194, 195, 360, 360, 360, 365, 360, 
+        391, 360, 393, 394, 395, 396, 84, 79, 
+        194, 195, 360, 360, 109, 397, 360, 360, 
+        200, 360, 398, 394, 399, 399, 84, 79, 
+        194, 195, 360, 360, 360, 397, 360, 360, 
+        200, 360, 394, 399, 399, 84, 79, 194, 
+        195, 360, 360, 360, 397, 360, 360, 200, 
+        360, 98, 400, 360, 79, 194, 195, 360, 
+        360, 360, 365, 360, 401, 401, 360, 79, 
+        194, 195, 360, 360, 360, 365, 360, 402, 
+        360, 360, 403, 194, 195, 360, 194, 195, 
+        360, 404, 360, 194, 405, 360, 194, 406, 
+        360, 194, 360, 402, 360, 360, 360, 194, 
+        195, 360, 407, 360, 408, 409, 360, 79, 
+        194, 195, 360, 360, 82, 360, 81, 360, 
+        401, 401, 360, 79, 194, 195, 360, 401, 
+        401, 360, 79, 194, 195, 360, 407, 360, 
+        401, 401, 360, 79, 194, 195, 360, 407, 
+        360, 408, 401, 360, 79, 194, 195, 360, 
+        360, 82, 360, 98, 360, 410, 410, 84, 
+        79, 194, 195, 360, 360, 360, 365, 360, 
+        411, 107, 412, 413, 88, 79, 194, 195, 
+        360, 360, 360, 365, 360, 107, 412, 413, 
+        88, 79, 194, 195, 360, 360, 360, 365, 
+        360, 412, 412, 88, 79, 194, 195, 360, 
+        360, 360, 365, 360, 414, 104, 415, 416, 
+        91, 79, 194, 195, 360, 360, 360, 365, 
+        360, 104, 415, 416, 91, 79, 194, 195, 
+        360, 360, 360, 365, 360, 415, 415, 91, 
+        79, 194, 195, 360, 360, 360, 365, 360, 
+        417, 101, 418, 419, 94, 79, 194, 195, 
+        360, 360, 360, 365, 360, 101, 418, 419, 
+        94, 79, 194, 195, 360, 360, 360, 365, 
+        360, 418, 418, 94, 79, 194, 195, 360, 
+        360, 360, 365, 360, 420, 98, 401, 421, 
+        360, 79, 194, 195, 360, 360, 360, 365, 
+        360, 98, 401, 421, 360, 79, 194, 195, 
+        360, 360, 360, 365, 360, 401, 422, 360, 
+        79, 194, 195, 360, 360, 360, 365, 360, 
+        98, 360, 401, 401, 360, 79, 194, 195, 
+        360, 360, 360, 365, 360, 80, 81, 360, 
+        360, 98, 400, 360, 79, 194, 195, 360, 
+        360, 360, 365, 360, 80, 360, 394, 399, 
+        399, 84, 79, 194, 195, 360, 360, 360, 
+        397, 360, 393, 394, 399, 399, 84, 79, 
+        194, 195, 360, 360, 360, 397, 360, 360, 
+        200, 360, 393, 394, 395, 399, 84, 79, 
+        194, 195, 360, 360, 109, 397, 360, 360, 
+        200, 360, 391, 360, 423, 360, 410, 410, 
+        84, 79, 194, 195, 360, 360, 360, 365, 
+        360, 391, 360, 391, 360, 360, 360, 401, 
+        401, 360, 79, 194, 195, 360, 360, 360, 
+        365, 360, 391, 360, 391, 360, 360, 360, 
+        401, 424, 360, 79, 194, 195, 360, 360, 
+        360, 365, 360, 391, 360, 391, 360, 423, 
+        360, 401, 401, 360, 79, 194, 195, 360, 
+        360, 360, 365, 360, 391, 360, 391, 81, 
+        360, 360, 98, 392, 360, 79, 194, 195, 
+        360, 360, 360, 365, 360, 391, 360, 384, 
+        385, 390, 390, 84, 79, 194, 195, 360, 
+        360, 360, 388, 360, 360, 200, 360, 384, 
+        385, 386, 390, 84, 79, 194, 195, 360, 
+        360, 111, 388, 360, 360, 200, 360, 382, 
+        360, 425, 360, 410, 410, 84, 79, 194, 
+        195, 360, 360, 360, 365, 360, 382, 360, 
+        382, 360, 360, 360, 401, 401, 360, 79, 
+        194, 195, 360, 360, 360, 365, 360, 382, 
+        360, 382, 360, 360, 360, 401, 426, 360, 
+        79, 194, 195, 360, 360, 360, 365, 360, 
+        382, 360, 382, 360, 425, 360, 401, 401, 
+        360, 79, 194, 195, 360, 360, 360, 365, 
+        360, 382, 360, 382, 81, 360, 360, 98, 
+        383, 360, 79, 194, 195, 360, 360, 360, 
+        365, 360, 382, 360, 375, 376, 381, 381, 
+        84, 79, 194, 195, 360, 360, 360, 379, 
+        360, 360, 200, 360, 375, 376, 377, 381, 
+        84, 79, 194, 195, 360, 360, 113, 379, 
+        360, 360, 200, 360, 373, 360, 427, 360, 
+        410, 410, 84, 79, 194, 195, 360, 360, 
+        360, 365, 360, 373, 360, 373, 360, 360, 
+        360, 401, 401, 360, 79, 194, 195, 360, 
+        360, 360, 365, 360, 373, 360, 373, 360, 
+        360, 360, 401, 428, 360, 79, 194, 195, 
+        360, 360, 360, 365, 360, 373, 360, 373, 
+        360, 427, 360, 401, 401, 360, 79, 194, 
+        195, 360, 360, 360, 365, 360, 373, 360, 
+        373, 81, 360, 360, 98, 374, 360, 79, 
+        194, 195, 360, 360, 360, 365, 360, 373, 
+        360, 366, 367, 372, 372, 84, 79, 194, 
+        195, 360, 360, 360, 370, 360, 360, 200, 
+        360, 366, 367, 368, 372, 84, 79, 194, 
+        195, 360, 360, 115, 370, 360, 360, 200, 
+        360, 363, 360, 429, 360, 410, 410, 84, 
+        79, 194, 195, 360, 360, 360, 365, 360, 
+        363, 360, 363, 360, 360, 360, 401, 401, 
+        360, 79, 194, 195, 360, 360, 360, 365, 
+        360, 363, 360, 363, 360, 360, 360, 401, 
+        430, 360, 79, 194, 195, 360, 360, 360, 
+        365, 360, 363, 360, 363, 360, 429, 360, 
+        401, 401, 360, 79, 194, 195, 360, 360, 
+        360, 365, 360, 363, 360, 363, 81, 360, 
+        360, 98, 364, 360, 79, 194, 195, 360, 
+        360, 360, 365, 360, 363, 360, 116, 83, 
+        83, 84, 79, 431, 431, 431, 431, 156, 
+        116, 431, 190, 191, 362, 362, 84, 79, 
+        194, 195, 360, 360, 360, 197, 360, 360, 
+        200, 360, 116, 83, 83, 84, 79, 431, 
+        431, 431, 431, 431, 116, 431, 433, 434, 
+        435, 436, 123, 118, 437, 438, 432, 432, 
+        155, 439, 432, 432, 440, 432, 441, 434, 
+        436, 436, 123, 118, 437, 438, 432, 432, 
+        432, 439, 432, 432, 440, 432, 434, 436, 
+        436, 123, 118, 437, 438, 432, 432, 432, 
+        439, 432, 432, 440, 432, 442, 432, 432, 
+        432, 136, 443, 432, 118, 437, 438, 432, 
+        432, 432, 444, 432, 442, 432, 445, 446, 
+        447, 448, 123, 118, 437, 438, 432, 432, 
+        153, 449, 432, 432, 440, 432, 450, 446, 
+        451, 451, 123, 118, 437, 438, 432, 432, 
+        432, 449, 432, 432, 440, 432, 446, 451, 
+        451, 123, 118, 437, 438, 432, 432, 432, 
+        449, 432, 432, 440, 432, 452, 432, 432, 
+        432, 136, 453, 432, 118, 437, 438, 432, 
+        432, 432, 444, 432, 452, 432, 454, 455, 
+        456, 457, 123, 118, 437, 438, 432, 432, 
+        151, 458, 432, 432, 440, 432, 459, 455, 
+        460, 460, 123, 118, 437, 438, 432, 432, 
+        432, 458, 432, 432, 440, 432, 455, 460, 
+        460, 123, 118, 437, 438, 432, 432, 432, 
+        458, 432, 432, 440, 432, 461, 432, 432, 
+        432, 136, 462, 432, 118, 437, 438, 432, 
+        432, 432, 444, 432, 461, 432, 463, 464, 
+        465, 466, 123, 118, 437, 438, 432, 432, 
+        149, 467, 432, 432, 440, 432, 468, 464, 
+        469, 469, 123, 118, 437, 438, 432, 432, 
+        432, 467, 432, 432, 440, 432, 464, 469, 
+        469, 123, 118, 437, 438, 432, 432, 432, 
+        467, 432, 432, 440, 432, 470, 432, 432, 
+        432, 136, 471, 432, 118, 437, 438, 432, 
+        432, 432, 444, 432, 470, 432, 472, 473, 
+        474, 475, 123, 118, 437, 438, 432, 432, 
+        147, 476, 432, 432, 440, 432, 477, 473, 
+        478, 478, 123, 118, 437, 438, 432, 432, 
+        432, 476, 432, 432, 440, 432, 473, 478, 
+        478, 123, 118, 437, 438, 432, 432, 432, 
+        476, 432, 432, 440, 432, 136, 479, 432, 
+        118, 437, 438, 432, 432, 432, 444, 432, 
+        480, 480, 432, 118, 437, 438, 432, 432, 
+        432, 444, 432, 481, 432, 432, 482, 437, 
+        438, 432, 437, 438, 432, 483, 432, 437, 
+        484, 432, 437, 485, 432, 437, 432, 481, 
+        432, 432, 432, 437, 438, 432, 486, 432, 
+        487, 488, 432, 118, 437, 438, 432, 432, 
+        121, 432, 120, 432, 480, 480, 432, 118, 
+        437, 438, 432, 480, 480, 432, 118, 437, 
+        438, 432, 486, 432, 480, 480, 432, 118, 
+        437, 438, 432, 486, 432, 487, 480, 432, 
+        118, 437, 438, 432, 432, 121, 432, 136, 
+        432, 489, 489, 123, 118, 437, 438, 432, 
+        432, 432, 444, 432, 490, 145, 491, 492, 
+        126, 118, 437, 438, 432, 432, 432, 444, 
+        432, 145, 491, 492, 126, 118, 437, 438, 
+        432, 432, 432, 444, 432, 491, 491, 126, 
+        118, 437, 438, 432, 432, 432, 444, 432, 
+        493, 142, 494, 495, 129, 118, 437, 438, 
+        432, 432, 432, 444, 432, 142, 494, 495, 
+        129, 118, 437, 438, 432, 432, 432, 444, 
+        432, 494, 494, 129, 118, 437, 438, 432, 
+        432, 432, 444, 432, 496, 139, 497, 498, 
+        132, 118, 437, 438, 432, 432, 432, 444, 
+        432, 139, 497, 498, 132, 118, 437, 438, 
+        432, 432, 432, 444, 432, 497, 497, 132, 
+        118, 437, 438, 432, 432, 432, 444, 432, 
+        499, 136, 480, 500, 432, 118, 437, 438, 
+        432, 432, 432, 444, 432, 136, 480, 500, 
+        432, 118, 437, 438, 432, 432, 432, 444, 
+        432, 480, 501, 432, 118, 437, 438, 432, 
+        432, 432, 444, 432, 136, 432, 480, 480, 
+        432, 118, 437, 438, 432, 432, 432, 444, 
+        432, 119, 120, 432, 432, 136, 479, 432, 
+        118, 437, 438, 432, 432, 432, 444, 432, 
+        119, 432, 473, 478, 478, 123, 118, 437, 
+        438, 432, 432, 432, 476, 432, 472, 473, 
+        478, 478, 123, 118, 437, 438, 432, 432, 
+        432, 476, 432, 432, 440, 432, 472, 473, 
+        474, 478, 123, 118, 437, 438, 432, 432, 
+        147, 476, 432, 432, 440, 432, 470, 432, 
+        502, 432, 489, 489, 123, 118, 437, 438, 
+        432, 432, 432, 444, 432, 470, 432, 470, 
+        432, 432, 432, 480, 480, 432, 118, 437, 
+        438, 432, 432, 432, 444, 432, 470, 432, 
+        470, 432, 432, 432, 480, 503, 432, 118, 
+        437, 438, 432, 432, 432, 444, 432, 470, 
+        432, 470, 432, 502, 432, 480, 480, 432, 
+        118, 437, 438, 432, 432, 432, 444, 432, 
+        470, 432, 470, 120, 432, 432, 136, 471, 
+        432, 118, 437, 438, 432, 432, 432, 444, 
+        432, 470, 432, 463, 464, 469, 469, 123, 
+        118, 437, 438, 432, 432, 432, 467, 432, 
+        432, 440, 432, 463, 464, 465, 469, 123, 
+        118, 437, 438, 432, 432, 149, 467, 432, 
+        432, 440, 432, 461, 432, 504, 432, 489, 
+        489, 123, 118, 437, 438, 432, 432, 432, 
+        444, 432, 461, 432, 461, 432, 432, 432, 
+        480, 480, 432, 118, 437, 438, 432, 432, 
+        432, 444, 432, 461, 432, 461, 432, 432, 
+        432, 480, 505, 432, 118, 437, 438, 432, 
+        432, 432, 444, 432, 461, 432, 461, 432, 
+        504, 432, 480, 480, 432, 118, 437, 438, 
+        432, 432, 432, 444, 432, 461, 432, 461, 
+        120, 432, 432, 136, 462, 432, 118, 437, 
+        438, 432, 432, 432, 444, 432, 461, 432, 
+        454, 455, 460, 460, 123, 118, 437, 438, 
+        432, 432, 432, 458, 432, 432, 440, 432, 
+        454, 455, 456, 460, 123, 118, 437, 438, 
+        432, 432, 151, 458, 432, 432, 440, 432, 
+        452, 432, 506, 432, 489, 489, 123, 118, 
+        437, 438, 432, 432, 432, 444, 432, 452, 
+        432, 452, 432, 432, 432, 480, 480, 432, 
+        118, 437, 438, 432, 432, 432, 444, 432, 
+        452, 432, 452, 432, 432, 432, 480, 507, 
+        432, 118, 437, 438, 432, 432, 432, 444, 
+        432, 452, 432, 452, 432, 506, 432, 480, 
+        480, 432, 118, 437, 438, 432, 432, 432, 
+        444, 432, 452, 432, 452, 120, 432, 432, 
+        136, 453, 432, 118, 437, 438, 432, 432, 
+        432, 444, 432, 452, 432, 445, 446, 451, 
+        451, 123, 118, 437, 438, 432, 432, 432, 
+        449, 432, 432, 440, 432, 445, 446, 447, 
+        451, 123, 118, 437, 438, 432, 432, 153, 
+        449, 432, 432, 440, 432, 442, 432, 508, 
+        432, 489, 489, 123, 118, 437, 438, 432, 
+        432, 432, 444, 432, 442, 432, 442, 432, 
+        432, 432, 480, 480, 432, 118, 437, 438, 
+        432, 432, 432, 444, 432, 442, 432, 442, 
+        432, 432, 432, 480, 509, 432, 118, 437, 
+        438, 432, 432, 432, 444, 432, 442, 432, 
+        442, 432, 508, 432, 480, 480, 432, 118, 
+        437, 438, 432, 432, 432, 444, 432, 442, 
+        432, 442, 120, 432, 432, 136, 443, 432, 
+        118, 437, 438, 432, 432, 432, 444, 432, 
+        442, 432, 433, 434, 436, 436, 123, 118, 
+        437, 438, 432, 432, 432, 439, 432, 432, 
+        440, 432, 188, 189, 190, 191, 510, 362, 
+        84, 79, 194, 195, 196, 196, 156, 197, 
+        360, 188, 200, 360, 203, 511, 205, 206, 
+        6, 1, 207, 208, 202, 202, 38, 209, 
+        202, 202, 210, 202, 213, 189, 190, 191, 
+        512, 513, 84, 157, 514, 515, 202, 196, 
+        156, 516, 202, 213, 200, 202, 116, 517, 
+        517, 84, 157, 207, 208, 202, 202, 156, 
+        518, 202, 519, 202, 202, 520, 514, 515, 
+        202, 514, 515, 202, 254, 202, 514, 521, 
+        202, 514, 522, 202, 514, 202, 519, 202, 
+        202, 202, 514, 515, 202, 523, 3, 360, 
+        360, 401, 430, 360, 79, 194, 195, 360, 
+        360, 360, 365, 360, 523, 360, 524, 367, 
+        525, 526, 84, 157, 514, 515, 202, 202, 
+        158, 370, 202, 202, 200, 202, 527, 367, 
+        528, 528, 84, 157, 514, 515, 202, 202, 
+        202, 370, 202, 202, 200, 202, 367, 528, 
+        528, 84, 157, 514, 515, 202, 202, 202, 
+        370, 202, 202, 200, 202, 524, 367, 528, 
+        528, 84, 157, 514, 515, 202, 202, 202, 
+        370, 202, 202, 200, 202, 524, 367, 525, 
+        528, 84, 157, 514, 515, 202, 202, 158, 
+        370, 202, 202, 200, 202, 213, 202, 279, 
+        116, 529, 529, 160, 157, 207, 208, 202, 
+        202, 202, 518, 202, 213, 202, 530, 184, 
+        531, 532, 162, 157, 514, 515, 202, 202, 
+        202, 533, 202, 184, 531, 532, 162, 157, 
+        514, 515, 202, 202, 202, 533, 202, 531, 
+        531, 162, 157, 514, 515, 202, 202, 202, 
+        533, 202, 534, 181, 535, 536, 165, 157, 
+        514, 515, 202, 202, 202, 533, 202, 181, 
+        535, 536, 165, 157, 514, 515, 202, 202, 
+        202, 533, 202, 535, 535, 165, 157, 514, 
+        515, 202, 202, 202, 533, 202, 537, 178, 
+        538, 539, 168, 157, 514, 515, 202, 202, 
+        202, 533, 202, 178, 538, 539, 168, 157, 
+        514, 515, 202, 202, 202, 533, 202, 538, 
+        538, 168, 157, 514, 515, 202, 202, 202, 
+        533, 202, 540, 175, 541, 542, 202, 157, 
+        514, 515, 202, 202, 202, 533, 202, 175, 
+        541, 542, 202, 157, 514, 515, 202, 202, 
+        202, 533, 202, 541, 541, 202, 157, 514, 
+        515, 202, 202, 202, 533, 202, 543, 202, 
+        544, 545, 202, 157, 514, 515, 202, 202, 
+        172, 202, 171, 202, 541, 541, 202, 157, 
+        514, 515, 202, 541, 541, 202, 157, 514, 
+        515, 202, 543, 202, 541, 541, 202, 157, 
+        514, 515, 202, 543, 202, 544, 541, 202, 
+        157, 514, 515, 202, 202, 172, 202, 523, 
+        171, 360, 360, 98, 364, 360, 79, 194, 
+        195, 360, 360, 360, 365, 360, 523, 360, 
+        547, 546, 548, 548, 546, 186, 549, 550, 
+        546, 548, 548, 546, 186, 549, 550, 546, 
+        551, 546, 546, 552, 549, 550, 546, 549, 
+        550, 546, 553, 546, 549, 554, 546, 549, 
+        555, 546, 549, 546, 551, 546, 546, 546, 
         549, 550, 546, 0
 };
 
 static const short _indic_syllable_machine_trans_targs[] = {
-        178, 200, 207, 209, 210, 4, 213, 5,
-        7, 216, 8, 10, 219, 11, 13, 222,
-        14, 16, 17, 199, 19, 20, 221, 22,
-        23, 218, 25, 26, 215, 224, 228, 232,
-        235, 239, 242, 246, 249, 253, 256, 178,
-        279, 286, 288, 289, 41, 292, 42, 44,
-        295, 45, 47, 298, 48, 50, 301, 51,
-        53, 54, 278, 56, 57, 300, 59, 60,
-        297, 62, 63, 294, 303, 307, 311, 314,
-        318, 321, 325, 328, 332, 336, 178, 357,
-        364, 366, 367, 78, 370, 178, 79, 81,
-        373, 82, 84, 376, 85, 87, 379, 88,
-        90, 91, 356, 93, 94, 378, 96, 97,
-        375, 99, 100, 372, 381, 385, 389, 392,
-        396, 399, 403, 406, 410, 178, 437, 444,
-        446, 447, 114, 450, 115, 117, 453, 118,
-        120, 456, 121, 123, 459, 124, 126, 127,
-        436, 129, 130, 458, 132, 133, 455, 135,
-        136, 452, 461, 465, 469, 472, 476, 479,
-        483, 486, 490, 493, 414, 498, 509, 152,
-        512, 154, 515, 155, 157, 518, 158, 160,
-        521, 161, 524, 526, 527, 166, 167, 523,
-        169, 170, 520, 172, 173, 517, 175, 176,
-        514, 178, 532, 178, 179, 258, 337, 339,
-        413, 415, 359, 360, 416, 412, 494, 495,
-        384, 530, 178, 180, 182, 36, 257, 202,
-        203, 255, 227, 181, 35, 183, 251, 1,
-        184, 186, 34, 250, 248, 185, 33, 187,
-        244, 188, 190, 32, 243, 241, 189, 31,
-        191, 237, 192, 194, 30, 236, 234, 193,
-        29, 195, 230, 196, 198, 28, 229, 226,
-        197, 27, 212, 0, 201, 206, 178, 204,
-        205, 208, 2, 211, 3, 214, 6, 24,
-        217, 9, 21, 220, 12, 18, 223, 15,
-        225, 231, 233, 238, 240, 245, 247, 252,
-        254, 178, 259, 261, 73, 334, 281, 282,
-        335, 306, 260, 72, 262, 330, 38, 263,
-        265, 71, 329, 327, 264, 70, 266, 323,
-        267, 269, 69, 322, 320, 268, 68, 270,
-        316, 271, 273, 67, 315, 313, 272, 66,
-        274, 309, 275, 277, 65, 308, 305, 276,
-        64, 291, 37, 280, 285, 178, 283, 284,
-        287, 39, 290, 40, 293, 43, 61, 296,
-        46, 58, 299, 49, 55, 302, 52, 304,
-        310, 312, 317, 319, 324, 326, 331, 333,
-        178, 338, 109, 340, 408, 75, 341, 343,
-        108, 407, 405, 342, 107, 344, 401, 345,
-        347, 106, 400, 398, 346, 105, 348, 394,
-        349, 351, 104, 393, 391, 350, 103, 352,
-        387, 353, 355, 102, 386, 383, 354, 101,
-        369, 74, 358, 363, 178, 361, 362, 365,
-        76, 368, 77, 371, 80, 98, 374, 83,
-        95, 377, 86, 92, 380, 89, 382, 388,
-        390, 395, 397, 402, 404, 409, 411, 178,
-        178, 417, 419, 146, 145, 439, 440, 492,
-        464, 418, 420, 488, 111, 421, 423, 144,
-        487, 485, 422, 143, 424, 481, 425, 427,
-        142, 480, 478, 426, 141, 428, 474, 429,
-        431, 140, 473, 471, 430, 139, 432, 467,
-        433, 435, 138, 466, 463, 434, 137, 449,
-        110, 438, 443, 178, 441, 442, 445, 112,
-        448, 113, 451, 116, 134, 454, 119, 131,
-        457, 122, 128, 460, 125, 462, 468, 470,
-        475, 477, 482, 484, 489, 491, 147, 496,
-        497, 511, 500, 501, 529, 148, 505, 499,
-        504, 502, 503, 506, 507, 150, 510, 508,
-        149, 151, 513, 153, 174, 163, 516, 156,
-        171, 519, 159, 168, 522, 162, 165, 525,
-        164, 528, 178, 531, 177, 534, 535, 533,
+        178, 200, 207, 209, 210, 4, 213, 5, 
+        7, 216, 8, 10, 219, 11, 13, 222, 
+        14, 16, 17, 199, 19, 20, 221, 22, 
+        23, 218, 25, 26, 215, 224, 228, 232, 
+        235, 239, 242, 246, 249, 253, 256, 178, 
+        279, 286, 288, 289, 41, 292, 42, 44, 
+        295, 45, 47, 298, 48, 50, 301, 51, 
+        53, 54, 278, 56, 57, 300, 59, 60, 
+        297, 62, 63, 294, 303, 307, 311, 314, 
+        318, 321, 325, 328, 332, 336, 178, 357, 
+        364, 366, 367, 78, 370, 178, 79, 81, 
+        373, 82, 84, 376, 85, 87, 379, 88, 
+        90, 91, 356, 93, 94, 378, 96, 97, 
+        375, 99, 100, 372, 381, 385, 389, 392, 
+        396, 399, 403, 406, 410, 178, 437, 444, 
+        446, 447, 114, 450, 115, 117, 453, 118, 
+        120, 456, 121, 123, 459, 124, 126, 127, 
+        436, 129, 130, 458, 132, 133, 455, 135, 
+        136, 452, 461, 465, 469, 472, 476, 479, 
+        483, 486, 490, 493, 414, 498, 509, 152, 
+        512, 154, 515, 155, 157, 518, 158, 160, 
+        521, 161, 524, 526, 527, 166, 167, 523, 
+        169, 170, 520, 172, 173, 517, 175, 176, 
+        514, 178, 532, 178, 179, 258, 337, 339, 
+        413, 415, 359, 360, 416, 412, 494, 495, 
+        384, 530, 178, 180, 182, 36, 257, 202, 
+        203, 255, 227, 181, 35, 183, 251, 1, 
+        184, 186, 34, 250, 248, 185, 33, 187, 
+        244, 188, 190, 32, 243, 241, 189, 31, 
+        191, 237, 192, 194, 30, 236, 234, 193, 
+        29, 195, 230, 196, 198, 28, 229, 226, 
+        197, 27, 212, 0, 201, 206, 178, 204, 
+        205, 208, 2, 211, 3, 214, 6, 24, 
+        217, 9, 21, 220, 12, 18, 223, 15, 
+        225, 231, 233, 238, 240, 245, 247, 252, 
+        254, 178, 259, 261, 73, 334, 281, 282, 
+        335, 306, 260, 72, 262, 330, 38, 263, 
+        265, 71, 329, 327, 264, 70, 266, 323, 
+        267, 269, 69, 322, 320, 268, 68, 270, 
+        316, 271, 273, 67, 315, 313, 272, 66, 
+        274, 309, 275, 277, 65, 308, 305, 276, 
+        64, 291, 37, 280, 285, 178, 283, 284, 
+        287, 39, 290, 40, 293, 43, 61, 296, 
+        46, 58, 299, 49, 55, 302, 52, 304, 
+        310, 312, 317, 319, 324, 326, 331, 333, 
+        178, 338, 109, 340, 408, 75, 341, 343, 
+        108, 407, 405, 342, 107, 344, 401, 345, 
+        347, 106, 400, 398, 346, 105, 348, 394, 
+        349, 351, 104, 393, 391, 350, 103, 352, 
+        387, 353, 355, 102, 386, 383, 354, 101, 
+        369, 74, 358, 363, 178, 361, 362, 365, 
+        76, 368, 77, 371, 80, 98, 374, 83, 
+        95, 377, 86, 92, 380, 89, 382, 388, 
+        390, 395, 397, 402, 404, 409, 411, 178, 
+        178, 417, 419, 146, 145, 439, 440, 492, 
+        464, 418, 420, 488, 111, 421, 423, 144, 
+        487, 485, 422, 143, 424, 481, 425, 427, 
+        142, 480, 478, 426, 141, 428, 474, 429, 
+        431, 140, 473, 471, 430, 139, 432, 467, 
+        433, 435, 138, 466, 463, 434, 137, 449, 
+        110, 438, 443, 178, 441, 442, 445, 112, 
+        448, 113, 451, 116, 134, 454, 119, 131, 
+        457, 122, 128, 460, 125, 462, 468, 470, 
+        475, 477, 482, 484, 489, 491, 147, 496, 
+        497, 511, 500, 501, 529, 148, 505, 499, 
+        504, 502, 503, 506, 507, 150, 510, 508, 
+        149, 151, 513, 153, 174, 163, 516, 156, 
+        171, 519, 159, 168, 522, 162, 165, 525, 
+        164, 528, 178, 531, 177, 534, 535, 533, 
         538, 178, 536, 537
 };
 
 static const char _indic_syllable_machine_trans_actions[] = {
-        1, 0, 2, 2, 2, 0, 2, 0,
-        0, 2, 0, 0, 2, 0, 0, 2,
-        0, 0, 0, 2, 0, 0, 2, 0,
-        0, 2, 0, 0, 2, 2, 2, 2,
-        2, 2, 2, 2, 2, 2, 2, 3,
-        0, 2, 2, 2, 0, 2, 0, 0,
-        2, 0, 0, 2, 0, 0, 2, 0,
-        0, 0, 2, 0, 0, 2, 0, 0,
-        2, 0, 0, 2, 2, 2, 2, 2,
-        2, 2, 2, 2, 2, 2, 4, 0,
-        2, 2, 2, 0, 2, 5, 0, 0,
-        2, 0, 0, 2, 0, 0, 2, 0,
-        0, 0, 2, 0, 0, 2, 0, 0,
-        2, 0, 0, 2, 2, 6, 2, 6,
-        2, 6, 2, 6, 2, 7, 0, 2,
-        2, 2, 0, 2, 0, 0, 2, 0,
-        0, 2, 0, 0, 2, 0, 0, 0,
-        2, 0, 0, 2, 0, 0, 2, 0,
-        0, 2, 2, 2, 2, 2, 2, 2,
-        2, 2, 2, 2, 6, 0, 8, 0,
-        2, 0, 2, 0, 0, 2, 0, 0,
-        2, 0, 2, 2, 2, 0, 0, 2,
-        0, 0, 2, 0, 0, 2, 0, 0,
-        2, 9, 0, 12, 2, 2, 6, 2,
-        13, 13, 0, 0, 2, 2, 6, 2,
-        6, 2, 14, 2, 2, 0, 2, 0,
-        0, 2, 2, 2, 0, 2, 2, 0,
-        2, 2, 0, 2, 2, 2, 0, 2,
-        2, 2, 2, 0, 2, 2, 2, 0,
-        2, 2, 2, 2, 0, 2, 2, 2,
-        0, 2, 2, 2, 2, 0, 2, 2,
-        2, 0, 2, 0, 0, 0, 15, 0,
-        0, 2, 0, 2, 0, 2, 0, 0,
-        2, 0, 0, 2, 0, 0, 2, 0,
-        2, 2, 2, 2, 2, 2, 2, 2,
-        2, 16, 2, 2, 0, 2, 0, 0,
-        2, 2, 2, 0, 2, 2, 0, 2,
-        2, 0, 2, 2, 2, 0, 2, 2,
-        2, 2, 0, 2, 2, 2, 0, 2,
-        2, 2, 2, 0, 2, 2, 2, 0,
-        2, 2, 2, 2, 0, 2, 2, 2,
-        0, 2, 0, 0, 0, 17, 0, 0,
-        2, 0, 2, 0, 2, 0, 0, 2,
-        0, 0, 2, 0, 0, 2, 0, 2,
-        2, 2, 2, 2, 2, 2, 2, 2,
-        18, 6, 0, 6, 6, 0, 6, 2,
-        0, 6, 2, 6, 0, 6, 6, 6,
-        2, 0, 6, 2, 6, 0, 6, 6,
-        6, 2, 0, 6, 2, 6, 0, 6,
-        6, 6, 2, 0, 6, 2, 6, 0,
-        6, 0, 0, 0, 19, 0, 0, 2,
-        0, 2, 0, 2, 0, 0, 2, 0,
-        0, 2, 0, 0, 2, 0, 2, 2,
-        2, 2, 2, 2, 2, 2, 2, 20,
-        21, 2, 2, 0, 0, 0, 0, 2,
-        2, 2, 2, 2, 0, 2, 2, 0,
-        2, 2, 2, 0, 2, 2, 2, 2,
-        0, 2, 2, 2, 0, 2, 2, 2,
-        2, 0, 2, 2, 2, 0, 2, 2,
-        2, 2, 0, 2, 2, 2, 0, 2,
-        0, 0, 0, 22, 0, 0, 2, 0,
-        2, 0, 2, 0, 0, 2, 0, 0,
-        2, 0, 0, 2, 0, 2, 2, 2,
-        2, 2, 2, 2, 2, 2, 0, 0,
-        8, 2, 0, 0, 2, 0, 2, 0,
-        0, 0, 0, 8, 8, 0, 8, 8,
-        0, 0, 2, 0, 0, 0, 2, 0,
-        0, 2, 0, 0, 2, 0, 0, 2,
-        0, 2, 23, 2, 0, 0, 0, 0,
+        1, 0, 2, 2, 2, 0, 2, 0, 
+        0, 2, 0, 0, 2, 0, 0, 2, 
+        0, 0, 0, 2, 0, 0, 2, 0, 
+        0, 2, 0, 0, 2, 2, 2, 2, 
+        2, 2, 2, 2, 2, 2, 2, 3, 
+        0, 2, 2, 2, 0, 2, 0, 0, 
+        2, 0, 0, 2, 0, 0, 2, 0, 
+        0, 0, 2, 0, 0, 2, 0, 0, 
+        2, 0, 0, 2, 2, 2, 2, 2, 
+        2, 2, 2, 2, 2, 2, 4, 0, 
+        2, 2, 2, 0, 2, 5, 0, 0, 
+        2, 0, 0, 2, 0, 0, 2, 0, 
+        0, 0, 2, 0, 0, 2, 0, 0, 
+        2, 0, 0, 2, 2, 6, 2, 6, 
+        2, 6, 2, 6, 2, 7, 0, 2, 
+        2, 2, 0, 2, 0, 0, 2, 0, 
+        0, 2, 0, 0, 2, 0, 0, 0, 
+        2, 0, 0, 2, 0, 0, 2, 0, 
+        0, 2, 2, 2, 2, 2, 2, 2, 
+        2, 2, 2, 2, 6, 0, 8, 0, 
+        2, 0, 2, 0, 0, 2, 0, 0, 
+        2, 0, 2, 2, 2, 0, 0, 2, 
+        0, 0, 2, 0, 0, 2, 0, 0, 
+        2, 9, 0, 12, 2, 2, 6, 2, 
+        13, 13, 0, 0, 2, 2, 6, 2, 
+        6, 2, 14, 2, 2, 0, 2, 0, 
+        0, 2, 2, 2, 0, 2, 2, 0, 
+        2, 2, 0, 2, 2, 2, 0, 2, 
+        2, 2, 2, 0, 2, 2, 2, 0, 
+        2, 2, 2, 2, 0, 2, 2, 2, 
+        0, 2, 2, 2, 2, 0, 2, 2, 
+        2, 0, 2, 0, 0, 0, 15, 0, 
+        0, 2, 0, 2, 0, 2, 0, 0, 
+        2, 0, 0, 2, 0, 0, 2, 0, 
+        2, 2, 2, 2, 2, 2, 2, 2, 
+        2, 16, 2, 2, 0, 2, 0, 0, 
+        2, 2, 2, 0, 2, 2, 0, 2, 
+        2, 0, 2, 2, 2, 0, 2, 2, 
+        2, 2, 0, 2, 2, 2, 0, 2, 
+        2, 2, 2, 0, 2, 2, 2, 0, 
+        2, 2, 2, 2, 0, 2, 2, 2, 
+        0, 2, 0, 0, 0, 17, 0, 0, 
+        2, 0, 2, 0, 2, 0, 0, 2, 
+        0, 0, 2, 0, 0, 2, 0, 2, 
+        2, 2, 2, 2, 2, 2, 2, 2, 
+        18, 6, 0, 6, 6, 0, 6, 2, 
+        0, 6, 2, 6, 0, 6, 6, 6, 
+        2, 0, 6, 2, 6, 0, 6, 6, 
+        6, 2, 0, 6, 2, 6, 0, 6, 
+        6, 6, 2, 0, 6, 2, 6, 0, 
+        6, 0, 0, 0, 19, 0, 0, 2, 
+        0, 2, 0, 2, 0, 0, 2, 0, 
+        0, 2, 0, 0, 2, 0, 2, 2, 
+        2, 2, 2, 2, 2, 2, 2, 20, 
+        21, 2, 2, 0, 0, 0, 0, 2, 
+        2, 2, 2, 2, 0, 2, 2, 0, 
+        2, 2, 2, 0, 2, 2, 2, 2, 
+        0, 2, 2, 2, 0, 2, 2, 2, 
+        2, 0, 2, 2, 2, 0, 2, 2, 
+        2, 2, 0, 2, 2, 2, 0, 2, 
+        0, 0, 0, 22, 0, 0, 2, 0, 
+        2, 0, 2, 0, 0, 2, 0, 0, 
+        2, 0, 0, 2, 0, 2, 2, 2, 
+        2, 2, 2, 2, 2, 2, 0, 0, 
+        8, 2, 0, 0, 2, 0, 2, 0, 
+        0, 0, 0, 8, 8, 0, 8, 8, 
+        0, 0, 2, 0, 0, 0, 2, 0, 
+        0, 2, 0, 0, 2, 0, 0, 2, 
+        0, 2, 23, 2, 0, 0, 0, 0, 
         0, 24, 0, 0
 };
 
 static const char _indic_syllable_machine_to_state_actions[] = {
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 10, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 10, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
         0, 0, 0
 };
 
 static const char _indic_syllable_machine_from_state_actions[] = {
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 11, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 11, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
         0, 0, 0
 };
 
 static const short _indic_syllable_machine_eof_trans[] = {
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 40, 40, 40,
-        40, 40, 40, 40, 40, 40, 40, 40,
-        40, 40, 40, 40, 40, 40, 40, 40,
-        40, 40, 40, 40, 40, 40, 40, 40,
-        40, 40, 40, 40, 40, 40, 40, 40,
-        40, 40, 79, 79, 79, 79, 86, 86,
-        79, 79, 79, 79, 79, 79, 79, 79,
-        79, 79, 79, 79, 79, 79, 79, 79,
-        79, 79, 79, 79, 79, 79, 79, 79,
-        79, 79, 79, 79, 79, 79, 118, 118,
-        118, 118, 118, 118, 118, 118, 118, 118,
-        118, 118, 118, 118, 118, 118, 118, 118,
-        118, 118, 118, 118, 118, 118, 118, 118,
-        118, 118, 118, 118, 118, 118, 118, 118,
-        118, 118, 118, 79, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1,
-        1, 186, 0, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 282, 282, 282, 282, 282, 282,
-        282, 282, 282, 282, 282, 282, 282, 282,
-        282, 282, 282, 282, 282, 282, 282, 282,
-        282, 282, 282, 282, 282, 282, 282, 282,
-        282, 282, 282, 282, 282, 282, 282, 282,
-        282, 282, 282, 282, 282, 282, 282, 282,
-        282, 282, 282, 282, 282, 282, 282, 282,
-        282, 282, 282, 282, 282, 282, 282, 282,
-        282, 282, 282, 282, 282, 282, 282, 282,
-        282, 282, 282, 282, 282, 282, 282, 282,
-        282, 361, 361, 361, 361, 361, 361, 361,
-        361, 361, 361, 361, 361, 361, 361, 361,
-        361, 361, 361, 361, 361, 361, 361, 361,
-        361, 361, 361, 361, 361, 361, 361, 361,
-        361, 361, 361, 361, 361, 361, 361, 361,
-        361, 361, 361, 361, 361, 361, 361, 361,
-        361, 361, 361, 361, 361, 361, 361, 361,
-        361, 361, 361, 361, 361, 361, 361, 361,
-        361, 361, 361, 361, 361, 361, 361, 361,
-        361, 361, 361, 361, 361, 432, 361, 432,
-        433, 433, 433, 433, 433, 433, 433, 433,
-        433, 433, 433, 433, 433, 433, 433, 433,
-        433, 433, 433, 433, 433, 433, 433, 433,
-        433, 433, 433, 433, 433, 433, 433, 433,
-        433, 433, 433, 433, 433, 433, 433, 433,
-        433, 433, 433, 433, 433, 433, 433, 433,
-        433, 433, 433, 433, 433, 433, 433, 433,
-        433, 433, 433, 433, 433, 433, 433, 433,
-        433, 433, 433, 433, 433, 433, 433, 433,
-        433, 433, 433, 433, 433, 433, 361, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 361, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 203, 203, 203, 203, 203, 203, 203,
-        203, 361, 547, 547, 547, 547, 547, 547,
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 40, 40, 40, 
+        40, 40, 40, 40, 40, 40, 40, 40, 
+        40, 40, 40, 40, 40, 40, 40, 40, 
+        40, 40, 40, 40, 40, 40, 40, 40, 
+        40, 40, 40, 40, 40, 40, 40, 40, 
+        40, 40, 79, 79, 79, 79, 86, 86, 
+        79, 79, 79, 79, 79, 79, 79, 79, 
+        79, 79, 79, 79, 79, 79, 79, 79, 
+        79, 79, 79, 79, 79, 79, 79, 79, 
+        79, 79, 79, 79, 79, 79, 118, 118, 
+        118, 118, 118, 118, 118, 118, 118, 118, 
+        118, 118, 118, 118, 118, 118, 118, 118, 
+        118, 118, 118, 118, 118, 118, 118, 118, 
+        118, 118, 118, 118, 118, 118, 118, 118, 
+        118, 118, 118, 79, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 1, 1, 1, 1, 1, 1, 1, 
+        1, 186, 0, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 282, 282, 282, 282, 282, 282, 
+        282, 282, 282, 282, 282, 282, 282, 282, 
+        282, 282, 282, 282, 282, 282, 282, 282, 
+        282, 282, 282, 282, 282, 282, 282, 282, 
+        282, 282, 282, 282, 282, 282, 282, 282, 
+        282, 282, 282, 282, 282, 282, 282, 282, 
+        282, 282, 282, 282, 282, 282, 282, 282, 
+        282, 282, 282, 282, 282, 282, 282, 282, 
+        282, 282, 282, 282, 282, 282, 282, 282, 
+        282, 282, 282, 282, 282, 282, 282, 282, 
+        282, 361, 361, 361, 361, 361, 361, 361, 
+        361, 361, 361, 361, 361, 361, 361, 361, 
+        361, 361, 361, 361, 361, 361, 361, 361, 
+        361, 361, 361, 361, 361, 361, 361, 361, 
+        361, 361, 361, 361, 361, 361, 361, 361, 
+        361, 361, 361, 361, 361, 361, 361, 361, 
+        361, 361, 361, 361, 361, 361, 361, 361, 
+        361, 361, 361, 361, 361, 361, 361, 361, 
+        361, 361, 361, 361, 361, 361, 361, 361, 
+        361, 361, 361, 361, 361, 432, 361, 432, 
+        433, 433, 433, 433, 433, 433, 433, 433, 
+        433, 433, 433, 433, 433, 433, 433, 433, 
+        433, 433, 433, 433, 433, 433, 433, 433, 
+        433, 433, 433, 433, 433, 433, 433, 433, 
+        433, 433, 433, 433, 433, 433, 433, 433, 
+        433, 433, 433, 433, 433, 433, 433, 433, 
+        433, 433, 433, 433, 433, 433, 433, 433, 
+        433, 433, 433, 433, 433, 433, 433, 433, 
+        433, 433, 433, 433, 433, 433, 433, 433, 
+        433, 433, 433, 433, 433, 433, 361, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 361, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 203, 203, 203, 203, 203, 203, 203, 
+        203, 361, 547, 547, 547, 547, 547, 547, 
         547, 547, 547
 };
 
@@ -1377,7 +1377,7 @@
   unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED;
   int cs;
   hb_glyph_info_t *info = buffer->info;
-
+  
 #line 1382 "hb-ot-shape-complex-indic-machine.hh"
         {
         cs = indic_syllable_machine_start;
@@ -1394,7 +1394,7 @@
 
   unsigned int last = 0;
   unsigned int syllable_serial = 1;
-
+  
 #line 1399 "hb-ot-shape-complex-indic-machine.hh"
         {
         int _slen;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -1713,33 +1713,28 @@
   switch (ab)
   {
     /* Don't decompose these. */
-    case 0x0931u  : return false;
-    case 0x0B94u  : return false;
+    case 0x0931u  : return false; /* DEVANAGARI LETTER RRA */
+    case 0x0B94u  : return false; /* TAMIL LETTER AU */
 
 
     /*
      * Decompose split matras that don't have Unicode decompositions.
      */
 
-    case 0x0F77u  : *a = 0x0FB2u; *b= 0x0F81u; return true;
-    case 0x0F79u  : *a = 0x0FB3u; *b= 0x0F81u; return true;
+    /* Khmer */
     case 0x17BEu  : *a = 0x17C1u; *b= 0x17BEu; return true;
     case 0x17BFu  : *a = 0x17C1u; *b= 0x17BFu; return true;
     case 0x17C0u  : *a = 0x17C1u; *b= 0x17C0u; return true;
     case 0x17C4u  : *a = 0x17C1u; *b= 0x17C4u; return true;
     case 0x17C5u  : *a = 0x17C1u; *b= 0x17C5u; return true;
-    case 0x1925u  : *a = 0x1920u; *b= 0x1923u; return true;
-    case 0x1926u  : *a = 0x1920u; *b= 0x1924u; return true;
-    case 0x1B3Cu  : *a = 0x1B42u; *b= 0x1B3Cu; return true;
-    case 0x1112Eu  : *a = 0x11127u; *b= 0x11131u; return true;
-    case 0x1112Fu  : *a = 0x11127u; *b= 0x11132u; return true;
+
 #if 0
+    /* Gujarati */
     /* This one has no decomposition in Unicode, but needs no decomposition either. */
     /* case 0x0AC9u  : return false; */
+
+    /* Oriya */
     case 0x0B57u  : *a = no decomp, -> RIGHT; return true;
-    case 0x1C29u  : *a = no decomp, -> LEFT; return true;
-    case 0xA9C0u  : *a = no decomp, -> RIGHT; return true;
-    case 0x111BuF  : *a = no decomp, -> ABOVE; return true;
 #endif
   }
 
@@ -1819,6 +1814,7 @@
   decompose_indic,
   compose_indic,
   setup_masks_indic,
+  NULL, /* disable_otl */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
   false, /* fallback_position */
 };
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar-machine.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar-machine.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -34,223 +34,223 @@
 
 #line 36 "../../src/hb-ot-shape-complex-myanmar-machine.hh.tmp"
 static const unsigned char _myanmar_syllable_machine_trans_keys[] = {
-        1u, 31u, 3u, 30u, 5u, 29u, 5u, 8u, 5u, 29u, 3u, 25u, 5u, 25u, 5u, 25u,
-        3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 1u, 16u, 3u, 29u, 3u, 29u, 3u, 29u,
-        3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 5u, 29u, 5u, 8u,
-        5u, 29u, 3u, 25u, 5u, 25u, 5u, 25u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u,
-        3u, 30u, 3u, 29u, 1u, 30u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u,
+        1u, 31u, 3u, 30u, 5u, 29u, 5u, 8u, 5u, 29u, 3u, 25u, 5u, 25u, 5u, 25u, 
+        3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 1u, 16u, 3u, 29u, 3u, 29u, 3u, 29u, 
+        3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 5u, 29u, 5u, 8u, 
+        5u, 29u, 3u, 25u, 5u, 25u, 5u, 25u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 
+        3u, 30u, 3u, 29u, 1u, 30u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 
         3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 8u, 8u, 0
 };
 
 static const char _myanmar_syllable_machine_key_spans[] = {
-        31, 28, 25, 4, 25, 23, 21, 21,
-        27, 27, 27, 27, 16, 27, 27, 27,
-        27, 27, 27, 27, 27, 27, 25, 4,
-        25, 23, 21, 21, 27, 27, 27, 27,
-        28, 27, 30, 27, 27, 27, 27, 27,
+        31, 28, 25, 4, 25, 23, 21, 21, 
+        27, 27, 27, 27, 16, 27, 27, 27, 
+        27, 27, 27, 27, 27, 27, 25, 4, 
+        25, 23, 21, 21, 27, 27, 27, 27, 
+        28, 27, 30, 27, 27, 27, 27, 27, 
         27, 27, 27, 27, 1
 };
 
 static const short _myanmar_syllable_machine_index_offsets[] = {
-        0, 32, 61, 87, 92, 118, 142, 164,
-        186, 214, 242, 270, 298, 315, 343, 371,
-        399, 427, 455, 483, 511, 539, 567, 593,
-        598, 624, 648, 670, 692, 720, 748, 776,
-        804, 833, 861, 892, 920, 948, 976, 1004,
+        0, 32, 61, 87, 92, 118, 142, 164, 
+        186, 214, 242, 270, 298, 315, 343, 371, 
+        399, 427, 455, 483, 511, 539, 567, 593, 
+        598, 624, 648, 670, 692, 720, 748, 776, 
+        804, 833, 861, 892, 920, 948, 976, 1004, 
         1032, 1060, 1088, 1116, 1144
 };
 
 static const char _myanmar_syllable_machine_indicies[] = {
-        1, 1, 2, 3, 4, 4, 0, 5,
-        0, 6, 1, 0, 0, 0, 0, 7,
-        0, 8, 1, 0, 9, 10, 11, 12,
-        13, 14, 15, 16, 17, 18, 19, 0,
-        21, 22, 23, 23, 20, 24, 20, 25,
-        20, 20, 20, 20, 20, 20, 20, 26,
-        20, 20, 27, 28, 29, 30, 31, 32,
-        33, 34, 35, 36, 20, 23, 23, 20,
-        24, 20, 20, 20, 20, 20, 20, 20,
-        20, 20, 37, 20, 20, 20, 20, 20,
-        20, 31, 20, 20, 20, 35, 20, 23,
-        23, 20, 24, 20, 23, 23, 20, 24,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        31, 20, 20, 20, 35, 20, 38, 20,
-        23, 23, 20, 24, 20, 31, 20, 20,
-        20, 20, 20, 20, 20, 39, 20, 20,
-        20, 20, 20, 20, 31, 20, 23, 23,
-        20, 24, 20, 20, 20, 20, 20, 20,
-        20, 20, 20, 39, 20, 20, 20, 20,
-        20, 20, 31, 20, 23, 23, 20, 24,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        31, 20, 21, 20, 23, 23, 20, 24,
-        20, 25, 20, 20, 20, 20, 20, 20,
-        20, 40, 20, 20, 40, 20, 20, 20,
-        31, 41, 20, 20, 35, 20, 21, 20,
-        23, 23, 20, 24, 20, 25, 20, 20,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        20, 20, 20, 20, 31, 20, 20, 20,
-        35, 20, 21, 20, 23, 23, 20, 24,
-        20, 25, 20, 20, 20, 20, 20, 20,
-        20, 40, 20, 20, 20, 20, 20, 20,
-        31, 41, 20, 20, 35, 20, 21, 20,
-        23, 23, 20, 24, 20, 25, 20, 20,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        20, 20, 20, 20, 31, 41, 20, 20,
-        35, 20, 1, 1, 20, 20, 20, 20,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        20, 1, 20, 21, 20, 23, 23, 20,
-        24, 20, 25, 20, 20, 20, 20, 20,
-        20, 20, 26, 20, 20, 27, 28, 29,
-        30, 31, 32, 33, 34, 35, 20, 21,
-        20, 23, 23, 20, 24, 20, 25, 20,
-        20, 20, 20, 20, 20, 20, 34, 20,
-        20, 20, 20, 20, 20, 31, 32, 33,
-        34, 35, 20, 21, 20, 23, 23, 20,
-        24, 20, 25, 20, 20, 20, 20, 20,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        20, 31, 32, 33, 34, 35, 20, 21,
-        20, 23, 23, 20, 24, 20, 25, 20,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        20, 20, 20, 20, 20, 31, 32, 33,
-        20, 35, 20, 21, 20, 23, 23, 20,
-        24, 20, 25, 20, 20, 20, 20, 20,
-        20, 20, 20, 20, 20, 20, 20, 20,
-        20, 31, 20, 33, 20, 35, 20, 21,
-        20, 23, 23, 20, 24, 20, 25, 20,
-        20, 20, 20, 20, 20, 20, 34, 20,
-        20, 27, 20, 29, 20, 31, 32, 33,
-        34, 35, 20, 21, 20, 23, 23, 20,
-        24, 20, 25, 20, 20, 20, 20, 20,
-        20, 20, 34, 20, 20, 27, 20, 20,
-        20, 31, 32, 33, 34, 35, 20, 21,
-        20, 23, 23, 20, 24, 20, 25, 20,
-        20, 20, 20, 20, 20, 20, 34, 20,
-        20, 27, 28, 29, 20, 31, 32, 33,
-        34, 35, 20, 21, 22, 23, 23, 20,
-        24, 20, 25, 20, 20, 20, 20, 20,
-        20, 20, 26, 20, 20, 27, 28, 29,
-        30, 31, 32, 33, 34, 35, 20, 3,
-        3, 42, 5, 42, 42, 42, 42, 42,
-        42, 42, 42, 42, 43, 42, 42, 42,
-        42, 42, 42, 13, 42, 42, 42, 17,
-        42, 3, 3, 42, 5, 42, 3, 3,
-        42, 5, 42, 42, 42, 42, 42, 42,
-        42, 42, 42, 42, 42, 42, 42, 42,
-        42, 42, 13, 42, 42, 42, 17, 42,
-        44, 42, 3, 3, 42, 5, 42, 13,
-        42, 42, 42, 42, 42, 42, 42, 45,
-        42, 42, 42, 42, 42, 42, 13, 42,
-        3, 3, 42, 5, 42, 42, 42, 42,
-        42, 42, 42, 42, 42, 45, 42, 42,
-        42, 42, 42, 42, 13, 42, 3, 3,
-        42, 5, 42, 42, 42, 42, 42, 42,
-        42, 42, 42, 42, 42, 42, 42, 42,
-        42, 42, 13, 42, 2, 42, 3, 3,
-        42, 5, 42, 6, 42, 42, 42, 42,
-        42, 42, 42, 46, 42, 42, 46, 42,
-        42, 42, 13, 47, 42, 42, 17, 42,
-        2, 42, 3, 3, 42, 5, 42, 6,
-        42, 42, 42, 42, 42, 42, 42, 42,
-        42, 42, 42, 42, 42, 42, 13, 42,
-        42, 42, 17, 42, 2, 42, 3, 3,
-        42, 5, 42, 6, 42, 42, 42, 42,
-        42, 42, 42, 46, 42, 42, 42, 42,
-        42, 42, 13, 47, 42, 42, 17, 42,
-        2, 42, 3, 3, 42, 5, 42, 6,
-        42, 42, 42, 42, 42, 42, 42, 42,
-        42, 42, 42, 42, 42, 42, 13, 47,
-        42, 42, 17, 42, 21, 22, 23, 23,
-        20, 24, 20, 25, 20, 20, 20, 20,
-        20, 20, 20, 48, 20, 20, 27, 28,
-        29, 30, 31, 32, 33, 34, 35, 36,
-        20, 21, 49, 23, 23, 20, 24, 20,
-        25, 20, 20, 20, 20, 20, 20, 20,
-        26, 20, 20, 27, 28, 29, 30, 31,
-        32, 33, 34, 35, 20, 1, 1, 2,
-        3, 3, 3, 42, 5, 42, 6, 1,
-        42, 42, 42, 42, 1, 42, 8, 1,
-        42, 9, 10, 11, 12, 13, 14, 15,
-        16, 17, 18, 42, 2, 42, 3, 3,
-        42, 5, 42, 6, 42, 42, 42, 42,
-        42, 42, 42, 8, 42, 42, 9, 10,
-        11, 12, 13, 14, 15, 16, 17, 42,
-        2, 42, 3, 3, 42, 5, 42, 6,
-        42, 42, 42, 42, 42, 42, 42, 16,
-        42, 42, 42, 42, 42, 42, 13, 14,
-        15, 16, 17, 42, 2, 42, 3, 3,
-        42, 5, 42, 6, 42, 42, 42, 42,
-        42, 42, 42, 42, 42, 42, 42, 42,
-        42, 42, 13, 14, 15, 16, 17, 42,
-        2, 42, 3, 3, 42, 5, 42, 6,
-        42, 42, 42, 42, 42, 42, 42, 42,
-        42, 42, 42, 42, 42, 42, 13, 14,
-        15, 42, 17, 42, 2, 42, 3, 3,
-        42, 5, 42, 6, 42, 42, 42, 42,
-        42, 42, 42, 42, 42, 42, 42, 42,
-        42, 42, 13, 42, 15, 42, 17, 42,
-        2, 42, 3, 3, 42, 5, 42, 6,
-        42, 42, 42, 42, 42, 42, 42, 16,
-        42, 42, 9, 42, 11, 42, 13, 14,
-        15, 16, 17, 42, 2, 42, 3, 3,
-        42, 5, 42, 6, 42, 42, 42, 42,
-        42, 42, 42, 16, 42, 42, 9, 42,
-        42, 42, 13, 14, 15, 16, 17, 42,
-        2, 42, 3, 3, 42, 5, 42, 6,
-        42, 42, 42, 42, 42, 42, 42, 16,
-        42, 42, 9, 10, 11, 42, 13, 14,
-        15, 16, 17, 42, 2, 3, 3, 3,
-        42, 5, 42, 6, 42, 42, 42, 42,
-        42, 42, 42, 8, 42, 42, 9, 10,
-        11, 12, 13, 14, 15, 16, 17, 42,
+        1, 1, 2, 3, 4, 4, 0, 5, 
+        0, 6, 1, 0, 0, 0, 0, 7, 
+        0, 8, 1, 0, 9, 10, 11, 12, 
+        13, 14, 15, 16, 17, 18, 19, 0, 
+        21, 22, 23, 23, 20, 24, 20, 25, 
+        20, 20, 20, 20, 20, 20, 20, 26, 
+        20, 20, 27, 28, 29, 30, 31, 32, 
+        33, 34, 35, 36, 20, 23, 23, 20, 
+        24, 20, 20, 20, 20, 20, 20, 20, 
+        20, 20, 37, 20, 20, 20, 20, 20, 
+        20, 31, 20, 20, 20, 35, 20, 23, 
+        23, 20, 24, 20, 23, 23, 20, 24, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        31, 20, 20, 20, 35, 20, 38, 20, 
+        23, 23, 20, 24, 20, 31, 20, 20, 
+        20, 20, 20, 20, 20, 39, 20, 20, 
+        20, 20, 20, 20, 31, 20, 23, 23, 
+        20, 24, 20, 20, 20, 20, 20, 20, 
+        20, 20, 20, 39, 20, 20, 20, 20, 
+        20, 20, 31, 20, 23, 23, 20, 24, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        31, 20, 21, 20, 23, 23, 20, 24, 
+        20, 25, 20, 20, 20, 20, 20, 20, 
+        20, 40, 20, 20, 40, 20, 20, 20, 
+        31, 41, 20, 20, 35, 20, 21, 20, 
+        23, 23, 20, 24, 20, 25, 20, 20, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        20, 20, 20, 20, 31, 20, 20, 20, 
+        35, 20, 21, 20, 23, 23, 20, 24, 
+        20, 25, 20, 20, 20, 20, 20, 20, 
+        20, 40, 20, 20, 20, 20, 20, 20, 
+        31, 41, 20, 20, 35, 20, 21, 20, 
+        23, 23, 20, 24, 20, 25, 20, 20, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        20, 20, 20, 20, 31, 41, 20, 20, 
+        35, 20, 1, 1, 20, 20, 20, 20, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        20, 1, 20, 21, 20, 23, 23, 20, 
+        24, 20, 25, 20, 20, 20, 20, 20, 
+        20, 20, 26, 20, 20, 27, 28, 29, 
+        30, 31, 32, 33, 34, 35, 20, 21, 
+        20, 23, 23, 20, 24, 20, 25, 20, 
+        20, 20, 20, 20, 20, 20, 34, 20, 
+        20, 20, 20, 20, 20, 31, 32, 33, 
+        34, 35, 20, 21, 20, 23, 23, 20, 
+        24, 20, 25, 20, 20, 20, 20, 20, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        20, 31, 32, 33, 34, 35, 20, 21, 
+        20, 23, 23, 20, 24, 20, 25, 20, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        20, 20, 20, 20, 20, 31, 32, 33, 
+        20, 35, 20, 21, 20, 23, 23, 20, 
+        24, 20, 25, 20, 20, 20, 20, 20, 
+        20, 20, 20, 20, 20, 20, 20, 20, 
+        20, 31, 20, 33, 20, 35, 20, 21, 
+        20, 23, 23, 20, 24, 20, 25, 20, 
+        20, 20, 20, 20, 20, 20, 34, 20, 
+        20, 27, 20, 29, 20, 31, 32, 33, 
+        34, 35, 20, 21, 20, 23, 23, 20, 
+        24, 20, 25, 20, 20, 20, 20, 20, 
+        20, 20, 34, 20, 20, 27, 20, 20, 
+        20, 31, 32, 33, 34, 35, 20, 21, 
+        20, 23, 23, 20, 24, 20, 25, 20, 
+        20, 20, 20, 20, 20, 20, 34, 20, 
+        20, 27, 28, 29, 20, 31, 32, 33, 
+        34, 35, 20, 21, 22, 23, 23, 20, 
+        24, 20, 25, 20, 20, 20, 20, 20, 
+        20, 20, 26, 20, 20, 27, 28, 29, 
+        30, 31, 32, 33, 34, 35, 20, 3, 
+        3, 42, 5, 42, 42, 42, 42, 42, 
+        42, 42, 42, 42, 43, 42, 42, 42, 
+        42, 42, 42, 13, 42, 42, 42, 17, 
+        42, 3, 3, 42, 5, 42, 3, 3, 
+        42, 5, 42, 42, 42, 42, 42, 42, 
+        42, 42, 42, 42, 42, 42, 42, 42, 
+        42, 42, 13, 42, 42, 42, 17, 42, 
+        44, 42, 3, 3, 42, 5, 42, 13, 
+        42, 42, 42, 42, 42, 42, 42, 45, 
+        42, 42, 42, 42, 42, 42, 13, 42, 
+        3, 3, 42, 5, 42, 42, 42, 42, 
+        42, 42, 42, 42, 42, 45, 42, 42, 
+        42, 42, 42, 42, 13, 42, 3, 3, 
+        42, 5, 42, 42, 42, 42, 42, 42, 
+        42, 42, 42, 42, 42, 42, 42, 42, 
+        42, 42, 13, 42, 2, 42, 3, 3, 
+        42, 5, 42, 6, 42, 42, 42, 42, 
+        42, 42, 42, 46, 42, 42, 46, 42, 
+        42, 42, 13, 47, 42, 42, 17, 42, 
+        2, 42, 3, 3, 42, 5, 42, 6, 
+        42, 42, 42, 42, 42, 42, 42, 42, 
+        42, 42, 42, 42, 42, 42, 13, 42, 
+        42, 42, 17, 42, 2, 42, 3, 3, 
+        42, 5, 42, 6, 42, 42, 42, 42, 
+        42, 42, 42, 46, 42, 42, 42, 42, 
+        42, 42, 13, 47, 42, 42, 17, 42, 
+        2, 42, 3, 3, 42, 5, 42, 6, 
+        42, 42, 42, 42, 42, 42, 42, 42, 
+        42, 42, 42, 42, 42, 42, 13, 47, 
+        42, 42, 17, 42, 21, 22, 23, 23, 
+        20, 24, 20, 25, 20, 20, 20, 20, 
+        20, 20, 20, 48, 20, 20, 27, 28, 
+        29, 30, 31, 32, 33, 34, 35, 36, 
+        20, 21, 49, 23, 23, 20, 24, 20, 
+        25, 20, 20, 20, 20, 20, 20, 20, 
+        26, 20, 20, 27, 28, 29, 30, 31, 
+        32, 33, 34, 35, 20, 1, 1, 2, 
+        3, 3, 3, 42, 5, 42, 6, 1, 
+        42, 42, 42, 42, 1, 42, 8, 1, 
+        42, 9, 10, 11, 12, 13, 14, 15, 
+        16, 17, 18, 42, 2, 42, 3, 3, 
+        42, 5, 42, 6, 42, 42, 42, 42, 
+        42, 42, 42, 8, 42, 42, 9, 10, 
+        11, 12, 13, 14, 15, 16, 17, 42, 
+        2, 42, 3, 3, 42, 5, 42, 6, 
+        42, 42, 42, 42, 42, 42, 42, 16, 
+        42, 42, 42, 42, 42, 42, 13, 14, 
+        15, 16, 17, 42, 2, 42, 3, 3, 
+        42, 5, 42, 6, 42, 42, 42, 42, 
+        42, 42, 42, 42, 42, 42, 42, 42, 
+        42, 42, 13, 14, 15, 16, 17, 42, 
+        2, 42, 3, 3, 42, 5, 42, 6, 
+        42, 42, 42, 42, 42, 42, 42, 42, 
+        42, 42, 42, 42, 42, 42, 13, 14, 
+        15, 42, 17, 42, 2, 42, 3, 3, 
+        42, 5, 42, 6, 42, 42, 42, 42, 
+        42, 42, 42, 42, 42, 42, 42, 42, 
+        42, 42, 13, 42, 15, 42, 17, 42, 
+        2, 42, 3, 3, 42, 5, 42, 6, 
+        42, 42, 42, 42, 42, 42, 42, 16, 
+        42, 42, 9, 42, 11, 42, 13, 14, 
+        15, 16, 17, 42, 2, 42, 3, 3, 
+        42, 5, 42, 6, 42, 42, 42, 42, 
+        42, 42, 42, 16, 42, 42, 9, 42, 
+        42, 42, 13, 14, 15, 16, 17, 42, 
+        2, 42, 3, 3, 42, 5, 42, 6, 
+        42, 42, 42, 42, 42, 42, 42, 16, 
+        42, 42, 9, 10, 11, 42, 13, 14, 
+        15, 16, 17, 42, 2, 3, 3, 3, 
+        42, 5, 42, 6, 42, 42, 42, 42, 
+        42, 42, 42, 8, 42, 42, 9, 10, 
+        11, 12, 13, 14, 15, 16, 17, 42, 
         51, 50, 0
 };
 
 static const char _myanmar_syllable_machine_trans_targs[] = {
-        0, 1, 22, 0, 0, 23, 29, 32,
-        35, 36, 40, 41, 42, 25, 38, 39,
-        37, 28, 43, 44, 0, 2, 12, 0,
-        3, 9, 13, 14, 18, 19, 20, 5,
-        16, 17, 15, 8, 21, 4, 6, 7,
-        10, 11, 0, 24, 26, 27, 30, 31,
+        0, 1, 22, 0, 0, 23, 29, 32, 
+        35, 36, 40, 41, 42, 25, 38, 39, 
+        37, 28, 43, 44, 0, 2, 12, 0, 
+        3, 9, 13, 14, 18, 19, 20, 5, 
+        16, 17, 15, 8, 21, 4, 6, 7, 
+        10, 11, 0, 24, 26, 27, 30, 31, 
         33, 34, 0, 0
 };
 
 static const char _myanmar_syllable_machine_trans_actions[] = {
-        3, 0, 0, 4, 5, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 6, 0, 0, 7,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 8, 0, 0, 0, 0, 0,
+        3, 0, 0, 4, 5, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 6, 0, 0, 7, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 8, 0, 0, 0, 0, 0, 
         0, 0, 9, 10
 };
 
 static const char _myanmar_syllable_machine_to_state_actions[] = {
-        1, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
+        1, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
         0, 0, 0, 0, 0
 };
 
 static const char _myanmar_syllable_machine_from_state_actions[] = {
-        2, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
+        2, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
         0, 0, 0, 0, 0
 };
 
 static const short _myanmar_syllable_machine_eof_trans[] = {
-        0, 21, 21, 21, 21, 21, 21, 21,
-        21, 21, 21, 21, 21, 21, 21, 21,
-        21, 21, 21, 21, 21, 21, 43, 43,
-        43, 43, 43, 43, 43, 43, 43, 43,
-        21, 21, 43, 43, 43, 43, 43, 43,
+        0, 21, 21, 21, 21, 21, 21, 21, 
+        21, 21, 21, 21, 21, 21, 21, 21, 
+        21, 21, 21, 21, 21, 21, 43, 43, 
+        43, 43, 43, 43, 43, 43, 43, 43, 
+        21, 21, 43, 43, 43, 43, 43, 43, 
         43, 43, 43, 43, 51
 };
 
@@ -284,7 +284,7 @@
   unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED;
   int cs;
   hb_glyph_info_t *info = buffer->info;
-
+  
 #line 289 "../../src/hb-ot-shape-complex-myanmar-machine.hh.tmp"
         {
         cs = myanmar_syllable_machine_start;
@@ -301,7 +301,7 @@
 
   unsigned int last = 0;
   unsigned int syllable_serial = 1;
-
+  
 #line 306 "../../src/hb-ot-shape-complex-myanmar-machine.hh.tmp"
         {
         int _slen;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -521,6 +521,7 @@
   NULL, /* decompose */
   NULL, /* compose */
   NULL, /* setup_masks */
+  NULL, /* disable_otl */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   true, /* fallback_position */
 };
@@ -538,6 +539,7 @@
   NULL, /* decompose */
   NULL, /* compose */
   setup_masks_myanmar,
+  NULL, /* disable_otl */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY,
   false, /* fallback_position */
 };
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -146,6 +146,14 @@
                        hb_buffer_t              *buffer,
                        hb_font_t                *font);
 
+  /* disable_otl()
+   * Called during shape().
+   * If set and returns true, GDEF/GSUB/GPOS of the font are ignored
+   * and fallback operations used.
+   * May be NULL.
+   */
+  bool (*disable_otl) (const hb_ot_shape_plan_t *plan);
+
   hb_ot_shape_zero_width_marks_type_t zero_width_marks;
 
   bool fallback_position;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-thai.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-thai.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -376,6 +376,7 @@
   NULL, /* decompose */
   NULL, /* compose */
   NULL, /* setup_masks */
+  NULL, /* disable_otl */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   false,/* fallback_position */
 };
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-tibetan.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-tibetan.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -57,6 +57,7 @@
   NULL, /* decompose */
   NULL, /* compose */
   NULL, /* setup_masks */
+  NULL, /* disable_otl */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   true, /* fallback_position */
 };
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use-machine.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use-machine.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -36,247 +36,247 @@
 
 #line 38 "hb-ot-shape-complex-use-machine.hh"
 static const unsigned char _use_syllable_machine_trans_keys[] = {
-        1u, 1u, 0u, 39u, 21u, 21u, 8u, 39u, 8u, 39u, 1u, 1u, 8u, 39u, 8u, 39u,
-        8u, 39u, 8u, 26u, 8u, 26u, 8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u,
-        8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 13u, 21u,
-        4u, 4u, 13u, 13u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 26u, 8u, 26u,
-        8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u,
-        8u, 39u, 8u, 39u, 8u, 39u, 1u, 1u, 1u, 39u, 8u, 39u, 21u, 42u, 41u, 42u,
+        1u, 1u, 0u, 39u, 21u, 21u, 8u, 39u, 8u, 39u, 1u, 1u, 8u, 39u, 8u, 39u, 
+        8u, 39u, 8u, 26u, 8u, 26u, 8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 
+        8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 13u, 21u, 
+        4u, 4u, 13u, 13u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 26u, 8u, 26u, 
+        8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 
+        8u, 39u, 8u, 39u, 8u, 39u, 1u, 1u, 1u, 39u, 8u, 39u, 21u, 42u, 41u, 42u, 
         42u, 42u, 0
 };
 
 static const char _use_syllable_machine_key_spans[] = {
-        1, 40, 1, 32, 32, 1, 32, 32,
-        32, 19, 19, 19, 32, 32, 32, 32,
-        32, 32, 32, 32, 32, 32, 32, 9,
-        1, 1, 32, 32, 32, 32, 19, 19,
-        19, 32, 32, 32, 32, 32, 32, 32,
-        32, 32, 32, 1, 39, 32, 22, 2,
+        1, 40, 1, 32, 32, 1, 32, 32, 
+        32, 19, 19, 19, 32, 32, 32, 32, 
+        32, 32, 32, 32, 32, 32, 32, 9, 
+        1, 1, 32, 32, 32, 32, 19, 19, 
+        19, 32, 32, 32, 32, 32, 32, 32, 
+        32, 32, 32, 1, 39, 32, 22, 2, 
         1
 };
 
 static const short _use_syllable_machine_index_offsets[] = {
-        0, 2, 43, 45, 78, 111, 113, 146,
-        179, 212, 232, 252, 272, 305, 338, 371,
-        404, 437, 470, 503, 536, 569, 602, 635,
-        645, 647, 649, 682, 715, 748, 781, 801,
-        821, 841, 874, 907, 940, 973, 1006, 1039,
-        1072, 1105, 1138, 1171, 1173, 1213, 1246, 1269,
+        0, 2, 43, 45, 78, 111, 113, 146, 
+        179, 212, 232, 252, 272, 305, 338, 371, 
+        404, 437, 470, 503, 536, 569, 602, 635, 
+        645, 647, 649, 682, 715, 748, 781, 801, 
+        821, 841, 874, 907, 940, 973, 1006, 1039, 
+        1072, 1105, 1138, 1171, 1173, 1213, 1246, 1269, 
         1272
 };
 
 static const char _use_syllable_machine_indicies[] = {
-        1, 0, 2, 3, 4, 2, 5, 3,
-        4, 4, 6, 4, 4, 1, 7, 4,
-        4, 4, 2, 2, 8, 9, 4, 4,
-        10, 11, 12, 13, 14, 15, 16, 10,
-        17, 18, 19, 20, 21, 22, 4, 23,
-        24, 25, 4, 27, 26, 29, 28, 28,
-        30, 31, 28, 28, 28, 28, 28, 28,
-        28, 28, 32, 33, 34, 35, 36, 37,
-        38, 39, 33, 40, 32, 41, 42, 43,
-        44, 28, 45, 46, 47, 28, 29, 28,
-        28, 30, 31, 28, 28, 28, 28, 28,
-        28, 28, 28, 48, 33, 34, 35, 36,
-        37, 38, 39, 33, 40, 41, 41, 42,
-        43, 44, 28, 45, 46, 47, 28, 30,
-        49, 29, 28, 28, 30, 31, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 33,
-        34, 35, 36, 37, 38, 39, 33, 40,
-        41, 41, 42, 43, 44, 28, 45, 46,
-        47, 28, 29, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        33, 34, 35, 36, 37, 28, 28, 28,
-        28, 28, 28, 42, 43, 44, 28, 45,
-        46, 47, 28, 29, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 34, 35, 36, 37, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        45, 46, 47, 28, 29, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 35, 36, 37, 28,
-        29, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 36, 37, 28, 29, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 37, 28,
-        29, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        35, 36, 37, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 45, 46, 47,
-        28, 29, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 35, 36, 37, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 46,
-        47, 28, 29, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 35, 36, 37, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 47, 28, 29, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 34, 35, 36, 37, 28, 28,
-        28, 28, 28, 28, 42, 43, 44, 28,
-        45, 46, 47, 28, 29, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 34, 35, 36, 37, 28,
-        28, 28, 28, 28, 28, 28, 43, 44,
-        28, 45, 46, 47, 28, 29, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 34, 35, 36, 37,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        44, 28, 45, 46, 47, 28, 29, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 33, 34, 35, 36,
-        37, 28, 39, 33, 28, 28, 28, 42,
-        43, 44, 28, 45, 46, 47, 28, 29,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 33, 34, 35,
-        36, 37, 28, 28, 33, 28, 28, 28,
-        42, 43, 44, 28, 45, 46, 47, 28,
-        29, 28, 28, 28, 28, 28, 28, 28,
-        28, 28, 28, 28, 28, 28, 33, 34,
-        35, 36, 37, 38, 39, 33, 28, 28,
-        28, 42, 43, 44, 28, 45, 46, 47,
-        28, 29, 28, 28, 30, 31, 28, 28,
-        28, 28, 28, 28, 28, 28, 28, 33,
-        34, 35, 36, 37, 38, 39, 33, 40,
-        28, 41, 42, 43, 44, 28, 45, 46,
-        47, 28, 29, 28, 28, 30, 31, 28,
-        28, 28, 28, 28, 28, 28, 28, 28,
-        33, 34, 35, 36, 37, 38, 39, 33,
-        40, 32, 41, 42, 43, 44, 28, 45,
-        46, 47, 28, 51, 50, 50, 50, 50,
-        50, 50, 50, 52, 50, 5, 53, 51,
-        50, 6, 54, 54, 1, 55, 54, 54,
-        54, 54, 54, 54, 54, 54, 56, 10,
-        11, 12, 13, 14, 15, 16, 10, 17,
-        19, 19, 20, 21, 22, 54, 23, 24,
-        25, 54, 6, 54, 54, 1, 55, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        10, 11, 12, 13, 14, 15, 16, 10,
-        17, 19, 19, 20, 21, 22, 54, 23,
-        24, 25, 54, 6, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 10, 11, 12, 13, 14, 54, 54,
-        54, 54, 54, 54, 20, 21, 22, 54,
-        23, 24, 25, 54, 6, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 11, 12, 13, 14, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 23, 24, 25, 54, 6, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 12, 13, 14,
-        54, 6, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 13, 14, 54, 6, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 14,
-        54, 6, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 12, 13, 14, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 23, 24,
-        25, 54, 6, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 12, 13, 14, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        24, 25, 54, 6, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 12, 13, 14, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 25, 54, 6, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 11, 12, 13, 14, 54,
-        54, 54, 54, 54, 54, 20, 21, 22,
-        54, 23, 24, 25, 54, 6, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 11, 12, 13, 14,
-        54, 54, 54, 54, 54, 54, 54, 21,
-        22, 54, 23, 24, 25, 54, 6, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 11, 12, 13,
-        14, 54, 54, 54, 54, 54, 54, 54,
-        54, 22, 54, 23, 24, 25, 54, 6,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 10, 11, 12,
-        13, 14, 54, 16, 10, 54, 54, 54,
-        20, 21, 22, 54, 23, 24, 25, 54,
-        6, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 10, 11,
-        12, 13, 14, 54, 54, 10, 54, 54,
-        54, 20, 21, 22, 54, 23, 24, 25,
-        54, 6, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 54, 54, 54, 54, 10,
-        11, 12, 13, 14, 15, 16, 10, 54,
-        54, 54, 20, 21, 22, 54, 23, 24,
-        25, 54, 6, 54, 54, 1, 55, 54,
-        54, 54, 54, 54, 54, 54, 54, 54,
-        10, 11, 12, 13, 14, 15, 16, 10,
-        17, 54, 19, 20, 21, 22, 54, 23,
-        24, 25, 54, 1, 57, 3, 54, 54,
-        54, 3, 54, 54, 6, 54, 54, 1,
-        55, 54, 54, 54, 54, 54, 54, 54,
-        54, 54, 10, 11, 12, 13, 14, 15,
-        16, 10, 17, 18, 19, 20, 21, 22,
-        54, 23, 24, 25, 54, 6, 54, 54,
-        1, 55, 54, 54, 54, 54, 54, 54,
-        54, 54, 54, 10, 11, 12, 13, 14,
-        15, 16, 10, 17, 18, 19, 20, 21,
-        22, 54, 23, 24, 25, 54, 59, 58,
-        58, 58, 58, 58, 58, 58, 58, 58,
-        58, 58, 58, 58, 58, 58, 58, 58,
-        58, 58, 59, 60, 58, 59, 60, 58,
+        1, 0, 2, 3, 4, 2, 5, 3, 
+        4, 4, 6, 4, 4, 1, 7, 4, 
+        4, 4, 2, 2, 8, 9, 4, 4, 
+        10, 11, 12, 13, 14, 15, 16, 10, 
+        17, 18, 19, 20, 21, 22, 4, 23, 
+        24, 25, 4, 27, 26, 29, 28, 28, 
+        30, 31, 28, 28, 28, 28, 28, 28, 
+        28, 28, 32, 33, 34, 35, 36, 37, 
+        38, 39, 33, 40, 32, 41, 42, 43, 
+        44, 28, 45, 46, 47, 28, 29, 28, 
+        28, 30, 31, 28, 28, 28, 28, 28, 
+        28, 28, 28, 48, 33, 34, 35, 36, 
+        37, 38, 39, 33, 40, 41, 41, 42, 
+        43, 44, 28, 45, 46, 47, 28, 30, 
+        49, 29, 28, 28, 30, 31, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 33, 
+        34, 35, 36, 37, 38, 39, 33, 40, 
+        41, 41, 42, 43, 44, 28, 45, 46, 
+        47, 28, 29, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        33, 34, 35, 36, 37, 28, 28, 28, 
+        28, 28, 28, 42, 43, 44, 28, 45, 
+        46, 47, 28, 29, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 34, 35, 36, 37, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        45, 46, 47, 28, 29, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 35, 36, 37, 28, 
+        29, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 36, 37, 28, 29, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 37, 28, 
+        29, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        35, 36, 37, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 45, 46, 47, 
+        28, 29, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 35, 36, 37, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 46, 
+        47, 28, 29, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 35, 36, 37, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 47, 28, 29, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 34, 35, 36, 37, 28, 28, 
+        28, 28, 28, 28, 42, 43, 44, 28, 
+        45, 46, 47, 28, 29, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 34, 35, 36, 37, 28, 
+        28, 28, 28, 28, 28, 28, 43, 44, 
+        28, 45, 46, 47, 28, 29, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 34, 35, 36, 37, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        44, 28, 45, 46, 47, 28, 29, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 33, 34, 35, 36, 
+        37, 28, 39, 33, 28, 28, 28, 42, 
+        43, 44, 28, 45, 46, 47, 28, 29, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 33, 34, 35, 
+        36, 37, 28, 28, 33, 28, 28, 28, 
+        42, 43, 44, 28, 45, 46, 47, 28, 
+        29, 28, 28, 28, 28, 28, 28, 28, 
+        28, 28, 28, 28, 28, 28, 33, 34, 
+        35, 36, 37, 38, 39, 33, 28, 28, 
+        28, 42, 43, 44, 28, 45, 46, 47, 
+        28, 29, 28, 28, 30, 31, 28, 28, 
+        28, 28, 28, 28, 28, 28, 28, 33, 
+        34, 35, 36, 37, 38, 39, 33, 40, 
+        28, 41, 42, 43, 44, 28, 45, 46, 
+        47, 28, 29, 28, 28, 30, 31, 28, 
+        28, 28, 28, 28, 28, 28, 28, 28, 
+        33, 34, 35, 36, 37, 38, 39, 33, 
+        40, 32, 41, 42, 43, 44, 28, 45, 
+        46, 47, 28, 51, 50, 50, 50, 50, 
+        50, 50, 50, 52, 50, 5, 53, 51, 
+        50, 6, 54, 54, 1, 55, 54, 54, 
+        54, 54, 54, 54, 54, 54, 56, 10, 
+        11, 12, 13, 14, 15, 16, 10, 17, 
+        19, 19, 20, 21, 22, 54, 23, 24, 
+        25, 54, 6, 54, 54, 1, 55, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        10, 11, 12, 13, 14, 15, 16, 10, 
+        17, 19, 19, 20, 21, 22, 54, 23, 
+        24, 25, 54, 6, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 10, 11, 12, 13, 14, 54, 54, 
+        54, 54, 54, 54, 20, 21, 22, 54, 
+        23, 24, 25, 54, 6, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 11, 12, 13, 14, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 23, 24, 25, 54, 6, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 12, 13, 14, 
+        54, 6, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 13, 14, 54, 6, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 14, 
+        54, 6, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 12, 13, 14, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 23, 24, 
+        25, 54, 6, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 12, 13, 14, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        24, 25, 54, 6, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 12, 13, 14, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 25, 54, 6, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 11, 12, 13, 14, 54, 
+        54, 54, 54, 54, 54, 20, 21, 22, 
+        54, 23, 24, 25, 54, 6, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 11, 12, 13, 14, 
+        54, 54, 54, 54, 54, 54, 54, 21, 
+        22, 54, 23, 24, 25, 54, 6, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 11, 12, 13, 
+        14, 54, 54, 54, 54, 54, 54, 54, 
+        54, 22, 54, 23, 24, 25, 54, 6, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 10, 11, 12, 
+        13, 14, 54, 16, 10, 54, 54, 54, 
+        20, 21, 22, 54, 23, 24, 25, 54, 
+        6, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 10, 11, 
+        12, 13, 14, 54, 54, 10, 54, 54, 
+        54, 20, 21, 22, 54, 23, 24, 25, 
+        54, 6, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 54, 54, 54, 54, 10, 
+        11, 12, 13, 14, 15, 16, 10, 54, 
+        54, 54, 20, 21, 22, 54, 23, 24, 
+        25, 54, 6, 54, 54, 1, 55, 54, 
+        54, 54, 54, 54, 54, 54, 54, 54, 
+        10, 11, 12, 13, 14, 15, 16, 10, 
+        17, 54, 19, 20, 21, 22, 54, 23, 
+        24, 25, 54, 1, 57, 3, 54, 54, 
+        54, 3, 54, 54, 6, 54, 54, 1, 
+        55, 54, 54, 54, 54, 54, 54, 54, 
+        54, 54, 10, 11, 12, 13, 14, 15, 
+        16, 10, 17, 18, 19, 20, 21, 22, 
+        54, 23, 24, 25, 54, 6, 54, 54, 
+        1, 55, 54, 54, 54, 54, 54, 54, 
+        54, 54, 54, 10, 11, 12, 13, 14, 
+        15, 16, 10, 17, 18, 19, 20, 21, 
+        22, 54, 23, 24, 25, 54, 59, 58, 
+        58, 58, 58, 58, 58, 58, 58, 58, 
+        58, 58, 58, 58, 58, 58, 58, 58, 
+        58, 58, 59, 60, 58, 59, 60, 58, 
         60, 58, 0
 };
 
 static const char _use_syllable_machine_trans_targs[] = {
-        1, 26, 2, 3, 1, 23, 1, 43,
-        44, 46, 28, 29, 30, 31, 32, 39,
-        40, 41, 45, 42, 36, 37, 38, 33,
-        34, 35, 1, 1, 1, 1, 4, 5,
-        22, 7, 8, 9, 10, 11, 18, 19,
-        20, 21, 15, 16, 17, 12, 13, 14,
-        6, 1, 1, 24, 25, 1, 1, 0,
+        1, 26, 2, 3, 1, 23, 1, 43, 
+        44, 46, 28, 29, 30, 31, 32, 39, 
+        40, 41, 45, 42, 36, 37, 38, 33, 
+        34, 35, 1, 1, 1, 1, 4, 5, 
+        22, 7, 8, 9, 10, 11, 18, 19, 
+        20, 21, 15, 16, 17, 12, 13, 14, 
+        6, 1, 1, 24, 25, 1, 1, 0, 
         27, 1, 1, 47, 48
 };
 
 static const char _use_syllable_machine_trans_actions[] = {
-        1, 2, 0, 0, 5, 0, 6, 0,
-        2, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 2, 2, 0, 0, 0, 0,
-        0, 0, 7, 8, 9, 10, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 11, 12, 0, 0, 13, 14, 0,
+        1, 2, 0, 0, 5, 0, 6, 0, 
+        2, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 2, 2, 0, 0, 0, 0, 
+        0, 0, 7, 8, 9, 10, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 11, 12, 0, 0, 13, 14, 0, 
         2, 15, 16, 0, 0
 };
 
 static const char _use_syllable_machine_to_state_actions[] = {
-        0, 3, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
+        0, 3, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
         0
 };
 
 static const char _use_syllable_machine_from_state_actions[] = {
-        0, 4, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0,
+        0, 4, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
+        0, 0, 0, 0, 0, 0, 0, 0, 
         0
 };
 
 static const short _use_syllable_machine_eof_trans[] = {
-        1, 0, 27, 29, 29, 50, 29, 29,
-        29, 29, 29, 29, 29, 29, 29, 29,
-        29, 29, 29, 29, 29, 29, 29, 51,
-        54, 51, 55, 55, 55, 55, 55, 55,
-        55, 55, 55, 55, 55, 55, 55, 55,
-        55, 55, 55, 58, 55, 55, 59, 59,
+        1, 0, 27, 29, 29, 50, 29, 29, 
+        29, 29, 29, 29, 29, 29, 29, 29, 
+        29, 29, 29, 29, 29, 29, 29, 51, 
+        54, 51, 55, 55, 55, 55, 55, 55, 
+        55, 55, 55, 55, 55, 55, 55, 55, 
+        55, 55, 55, 58, 55, 55, 59, 59, 
         59
 };
 
@@ -310,7 +310,7 @@
   unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED;
   int cs;
   hb_glyph_info_t *info = buffer->info;
-
+  
 #line 315 "hb-ot-shape-complex-use-machine.hh"
         {
         cs = use_syllable_machine_start;
@@ -327,7 +327,7 @@
 
   unsigned int last = 0;
   unsigned int syllable_serial = 1;
-
+  
 #line 332 "hb-ot-shape-complex-use-machine.hh"
         {
         int _slen;
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -559,6 +559,47 @@
 }
 
 static bool
+decompose_use (const hb_ot_shape_normalize_context_t *c,
+                hb_codepoint_t  ab,
+                hb_codepoint_t *a,
+                hb_codepoint_t *b)
+{
+  switch (ab)
+  {
+    /* Chakma:
+     * Special case where the Unicode decomp gives matras in the wrong order
+     * for cluster validation.
+     */
+    case 0x1112Eu : *a = 0x11127u; *b= 0x11131u; return true;
+    case 0x1112Fu : *a = 0x11127u; *b= 0x11132u; return true;
+
+    /*
+     * Decompose split matras that don't have Unicode decompositions.
+     */
+
+    /* Limbu */
+    case 0x1925u  : *a = 0x1920u; *b= 0x1923u; return true;
+    case 0x1926u  : *a = 0x1920u; *b= 0x1924u; return true;
+
+    /* Balinese */
+    case 0x1B3Cu  : *a = 0x1B42u; *b= 0x1B3Cu; return true;
+
+#if 0
+    /* Lepcha */
+    case 0x1C29u  : *a = no decomp, -> LEFT; return true;
+
+    /* Javanese */
+    case 0xA9C0u  : *a = no decomp, -> RIGHT; return true;
+
+    /* Sharada */
+    case 0x111BFu  : *a = no decomp, -> ABOVE; return true;
+#endif
+  }
+
+  return (bool) c->unicode->decompose (ab, a, b);
+}
+
+static bool
 compose_use (const hb_ot_shape_normalize_context_t *c,
              hb_codepoint_t  a,
              hb_codepoint_t  b,
@@ -582,9 +623,10 @@
   NULL, /* preprocess_text */
   NULL, /* postprocess_glyphs */
   HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT,
-  NULL, /* decompose */
+  decompose_use,
   compose_use,
   setup_masks_use,
+  NULL, /* disable_otl */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY,
   false, /* fallback_position */
 };
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -77,11 +77,13 @@
                          map (face, &props) {}
   ~hb_ot_shape_planner_t (void) { map.finish (); }
 
-  inline void compile (hb_ot_shape_plan_t &plan)
+  inline void compile (hb_ot_shape_plan_t &plan,
+                       const int          *coords,
+                       unsigned int        num_coords)
   {
     plan.props = props;
     plan.shaper = shaper;
-    map.compile (plan.map);
+    map.compile (plan.map, coords, num_coords);
 
     plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m'));
     plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c'));
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -69,6 +69,9 @@
 {
   hb_ot_map_builder_t *map = &planner->map;
 
+  map->add_global_bool_feature (HB_TAG('r','v','r','n'));
+  map->add_gsub_pause (NULL);
+
   switch (props->direction) {
     case HB_DIRECTION_LTR:
       map->add_global_bool_feature (HB_TAG ('l','t','r','a'));
@@ -163,7 +166,9 @@
 hb_ot_shaper_shape_plan_data_t *
 _hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t    *shape_plan,
                                       const hb_feature_t *user_features,
-                                      unsigned int        num_user_features)
+                                      unsigned int        num_user_features,
+                                      const int          *coords,
+                                      unsigned int        num_coords)
 {
   hb_ot_shape_plan_t *plan = (hb_ot_shape_plan_t *) calloc (1, sizeof (hb_ot_shape_plan_t));
   if (unlikely (!plan))
@@ -173,9 +178,10 @@
 
   planner.shaper = hb_ot_shape_complex_categorize (&planner);
 
-  hb_ot_shape_collect_features (&planner, &shape_plan->props, user_features, num_user_features);
+  hb_ot_shape_collect_features (&planner, &shape_plan->props,
+                                user_features, num_user_features);
 
-  planner.compile (*plan);
+  planner.compile (*plan, coords, num_coords);
 
   if (plan->shaper->data_create) {
     plan->data = plan->shaper->data_create (plan);
@@ -212,6 +218,8 @@
   unsigned int        num_user_features;
 
   /* Transient stuff */
+  bool fallback_positioning;
+  bool fallback_glyph_classes;
   hb_direction_t target_direction;
 };
 
@@ -524,6 +532,32 @@
 }
 
 static inline void
+hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
+{
+  unsigned int count = c->buffer->len;
+  hb_glyph_info_t *info = c->buffer->info;
+  for (unsigned int i = 0; i < count; i++)
+  {
+    hb_ot_layout_glyph_props_flags_t klass;
+
+    /* Never mark default-ignorables as marks.
+     * They won't get in the way of lookups anyway,
+     * but having them as mark will cause them to be skipped
+     * over if the lookup-flag says so, but at least for the
+     * Mongolian variation selectors, looks like Uniscribe
+     * marks them as non-mark.  Some Mongolian fonts without
+     * GDEF rely on this.  Another notable character that
+     * this applies to is COMBINING GRAPHEME JOINER. */
+    klass = (_hb_glyph_info_get_general_category (&info[i]) !=
+             HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK ||
+             _hb_glyph_info_is_default_ignorable (&info[i])) ?
+            HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH :
+            HB_OT_LAYOUT_GLYPH_PROPS_MARK;
+    _hb_glyph_info_set_glyph_props (&info[i], klass);
+  }
+}
+
+static inline void
 hb_ot_substitute_default (hb_ot_shape_context_t *c)
 {
   hb_buffer_t *buffer = c->buffer;
@@ -539,7 +573,7 @@
   hb_ot_shape_setup_masks (c);
 
   /* This is unfortunate to go here, but necessary... */
-  if (!hb_ot_layout_has_positioning (c->face))
+  if (c->fallback_positioning)
     _hb_ot_shape_fallback_position_recategorize_marks (c->plan, c->font, buffer);
 
   hb_ot_map_glyphs_fast (buffer);
@@ -554,6 +588,9 @@
 
   hb_ot_layout_substitute_start (c->font, buffer);
 
+  if (!hb_ot_layout_has_glyph_classes (c->face))
+    hb_synthesize_glyph_classes (c);
+
   c->plan->substitute (c->font, buffer);
 
   return;
@@ -632,14 +669,12 @@
     _hb_ot_shape_fallback_spaces (c->plan, c->font, c->buffer);
 }
 
-static inline bool
+static inline void
 hb_ot_position_complex (hb_ot_shape_context_t *c)
 {
   hb_ot_layout_position_start (c->font, c->buffer);
 
-  bool ret = false;
   unsigned int count = c->buffer->len;
-  bool has_positioning = (bool) hb_ot_layout_has_positioning (c->face);
 
   /* If the font has no GPOS, AND, no fallback positioning will
    * happen, AND, direction is forward, then when zeroing mark
@@ -650,8 +685,9 @@
    * If fallback positinoing happens or GPOS is present, we don't
    * care.
    */
-  bool adjust_offsets_when_zeroing = !(has_positioning || c->plan->shaper->fallback_position ||
-                                       HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction));
+  bool adjust_offsets_when_zeroing = c->fallback_positioning &&
+                                     !c->plan->shaper->fallback_position &&
+                                     HB_DIRECTION_IS_FORWARD (c->buffer->props.direction);
 
   switch (c->plan->shaper->zero_width_marks)
   {
@@ -665,7 +701,7 @@
       break;
   }
 
-  if (has_positioning)
+  if (likely (!c->fallback_positioning))
   {
     hb_glyph_info_t *info = c->buffer->info;
     hb_glyph_position_t *pos = c->buffer->pos;
@@ -688,7 +724,6 @@
                                           &pos[i].x_offset,
                                           &pos[i].y_offset);
 
-    ret = true;
   }
 
   switch (c->plan->shaper->zero_width_marks)
@@ -707,8 +742,6 @@
   hb_ot_layout_position_finish_advances (c->font, c->buffer);
   hb_ot_zero_width_default_ignorables (c);
   hb_ot_layout_position_finish_offsets (c->font, c->buffer);
-
-  return ret;
 }
 
 static inline void
@@ -718,9 +751,9 @@
 
   hb_ot_position_default (c);
 
-  hb_bool_t fallback = !hb_ot_position_complex (c);
+  hb_ot_position_complex (c);
 
-  if (fallback && c->plan->shaper->fallback_position)
+  if (c->fallback_positioning && c->plan->shaper->fallback_position)
     _hb_ot_shape_fallback_position (c->plan, c->font, c->buffer);
 
   if (HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction))
@@ -728,7 +761,7 @@
 
   /* Visual fallback goes here. */
 
-  if (fallback)
+  if (c->fallback_positioning)
     _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer);
 
   _hb_buffer_deallocate_gsubgpos_vars (c->buffer);
@@ -748,6 +781,11 @@
                               (unsigned) HB_BUFFER_MAX_LEN_MIN);
   }
 
+  bool disable_otl = c->plan->shaper->disable_otl && c->plan->shaper->disable_otl (c->plan);
+  //c->fallback_substitute     = disable_otl || !hb_ot_layout_has_substitution (c->face);
+  c->fallback_positioning    = disable_otl || !hb_ot_layout_has_positioning (c->face);
+  c->fallback_glyph_classes  = disable_otl || !hb_ot_layout_has_glyph_classes (c->face);
+
   /* Save the original direction, we use it later. */
   c->target_direction = c->buffer->props.direction;
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-tag.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-tag.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -826,16 +826,19 @@
 };
 
 typedef struct {
-  char language[8];
+  char language[11];
   hb_tag_t tag;
 } LangTagLong;
 static const LangTagLong ot_languages_zh[] = {
+  /* Store longest-first, if one is a prefix of another. */
   {"zh-cn",     HB_TAG('Z','H','S',' ')},       /* Chinese (China) */
   {"zh-hk",     HB_TAG('Z','H','H',' ')},       /* Chinese (Hong Kong) */
-  {"zh-mo",     HB_TAG('Z','H','T',' ')},       /* Chinese (Macao) */
+  {"zh-mo",     HB_TAG('Z','H','H',' ')},       /* Chinese (Macao) */
   {"zh-sg",     HB_TAG('Z','H','S',' ')},       /* Chinese (Singapore) */
   {"zh-tw",     HB_TAG('Z','H','T',' ')},       /* Chinese (Taiwan) */
   {"zh-hans",   HB_TAG('Z','H','S',' ')},       /* Chinese (Simplified) */
+  {"zh-hant-hk",HB_TAG('Z','H','H',' ')},       /* Chinese (Hong Kong) */
+  {"zh-hant-mo",HB_TAG('Z','H','H',' ')},       /* Chinese (Macao) */
   {"zh-hant",   HB_TAG('Z','H','T',' ')},       /* Chinese (Traditional) */
 };
 
@@ -889,13 +892,21 @@
   }
 
   /*
-   * The International Phonetic Alphabet is a variant tag in BCP-47,
-   * which can be applied to any language.
+   * "fonipa" is a variant tag in BCP-47, meaning the International Phonetic Alphabet.
+   * It can be applied to any language.
    */
   if (strstr (lang_str, "-fonipa")) {
     return HB_TAG('I','P','P','H');  /* Phonetic transcription—IPA conventions */
   }
 
+  /*
+   * "fonnapa" is a variant tag in BCP-47, meaning the North American Phonetic Alphabet
+   * also known as Americanist Phonetic Notation.  It can be applied to any language.
+   */
+  if (strstr (lang_str, "-fonnapa")) {
+    return HB_TAG('A','P','P','H');  /* Phonetic transcription—Americanist conventions */
+  }
+
   /* Find a language matching in the first component */
   {
     const LangTag *lang_tag;
@@ -937,7 +948,7 @@
 /**
  * hb_ot_tag_to_language:
  *
- *
+ * 
  *
  * Return value: (transfer none):
  *
@@ -967,6 +978,8 @@
 
   /* struct LangTag has only room for 3-letter language tags. */
   switch (tag) {
+  case HB_TAG('A','P','P','H'):  /* Phonetic transcription—Americanist conventions */
+    return hb_language_from_string ("und-fonnapa", -1);
   case HB_TAG('I','P','P','H'):  /* Phonetic transcription—IPA conventions */
     return hb_language_from_string ("und-fonipa", -1);
   }
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot.h	Tue Jan 24 00:30:25 2017 +0100
@@ -32,6 +32,7 @@
 
 #include "hb-ot-font.h"
 #include "hb-ot-layout.h"
+#include "hb-ot-math.h"
 #include "hb-ot-tag.h"
 #include "hb-ot-shape.h"
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -689,17 +689,20 @@
     fprintf (stderr, " %*s  ", (unsigned int) (2 * sizeof (void *)), "");
 
   if (indented) {
-/* One may want to add ASCII version of these.  See:
- * https://bugs.freedesktop.org/show_bug.cgi?id=50970 */
 #define VBAR    "\342\224\202"  /* U+2502 BOX DRAWINGS LIGHT VERTICAL */
 #define VRBAR   "\342\224\234"  /* U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
 #define DLBAR   "\342\225\256"  /* U+256E BOX DRAWINGS LIGHT ARC DOWN AND LEFT */
 #define ULBAR   "\342\225\257"  /* U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT */
 #define LBAR    "\342\225\264"  /* U+2574 BOX DRAWINGS LIGHT LEFT */
-    static const char bars[] = VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR;
+    static const char bars[] =
+      VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR
+      VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR
+      VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR
+      VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR
+      VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR;
     fprintf (stderr, "%2u %s" VRBAR "%s",
              level,
-             bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars), (unsigned int) (sizeof (VBAR) - 1) * level),
+             bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars) - 1, (unsigned int) (sizeof (VBAR) - 1) * level),
              level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR);
   } else
     fprintf (stderr, "   " VRBAR LBAR);
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -313,7 +313,7 @@
     for (unsigned int i = 0; i < ELTS; i++)
       if (elts[i])
         for (unsigned int j = 0; j < BITS; j++)
-          if (elts[i] & (1 << j))
+          if (elts[i] & (1u << j))
             return i * BITS + j;
     return INVALID;
   }
@@ -322,7 +322,7 @@
     for (unsigned int i = ELTS; i; i--)
       if (elts[i - 1])
         for (unsigned int j = BITS; j; j--)
-          if (elts[i - 1] & (1 << (j - 1)))
+          if (elts[i - 1] & (1u << (j - 1)))
             return (i - 1) * BITS + (j - 1);
     return INVALID;
   }
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -143,9 +143,9 @@
  * hb_set_allocation_successful:
  * @set: a set.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -159,7 +159,7 @@
  * hb_set_clear:
  * @set: a set.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -173,9 +173,9 @@
  * hb_set_is_empty:
  * @set: a set.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.7
  **/
@@ -188,11 +188,11 @@
 /**
  * hb_set_has:
  * @set: a set.
- * @codepoint:
- *
+ * @codepoint: 
  *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -206,9 +206,9 @@
 /**
  * hb_set_add:
  * @set: a set.
- * @codepoint:
+ * @codepoint: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -222,10 +222,10 @@
 /**
  * hb_set_add_range:
  * @set: a set.
- * @first:
- * @last:
+ * @first: 
+ * @last: 
  *
- *
+ * 
  *
  * Since: 0.9.7
  **/
@@ -240,9 +240,9 @@
 /**
  * hb_set_del:
  * @set: a set.
- * @codepoint:
+ * @codepoint: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -256,10 +256,10 @@
 /**
  * hb_set_del_range:
  * @set: a set.
- * @first:
- * @last:
+ * @first: 
+ * @last: 
  *
- *
+ * 
  *
  * Since: 0.9.7
  **/
@@ -274,11 +274,11 @@
 /**
  * hb_set_is_equal:
  * @set: a set.
- * @other:
- *
+ * @other: 
  *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.7
  **/
@@ -292,9 +292,9 @@
 /**
  * hb_set_set:
  * @set: a set.
- * @other:
+ * @other: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -308,9 +308,9 @@
 /**
  * hb_set_union:
  * @set: a set.
- * @other:
+ * @other: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -324,9 +324,9 @@
 /**
  * hb_set_intersect:
  * @set: a set.
- * @other:
+ * @other: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -340,9 +340,9 @@
 /**
  * hb_set_subtract:
  * @set: a set.
- * @other:
+ * @other: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -356,9 +356,9 @@
 /**
  * hb_set_symmetric_difference:
  * @set: a set.
- * @other:
+ * @other: 
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -373,7 +373,7 @@
  * hb_set_invert:
  * @set: a set.
  *
- *
+ * 
  *
  * Since: 0.9.10
  **/
@@ -436,7 +436,7 @@
  * @set: a set.
  * @codepoint: (inout):
  *
- *
+ * 
  *
  * Return value: whether there was a next value.
  *
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan-private.hh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan-private.hh	Tue Jan 24 00:30:25 2017 +0100
@@ -47,12 +47,17 @@
   hb_feature_t *user_features;
   unsigned int num_user_features;
 
+  int *coords;
+  unsigned int num_coords;
+
   struct hb_shaper_data_t shaper_data;
 };
 
 #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS \
-        , const hb_feature_t            *user_features \
-        , unsigned int                   num_user_features
+        , const hb_feature_t *user_features \
+        , unsigned int        num_user_features \
+        , const int          *coords \
+        , unsigned int        num_coords
 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, shape_plan);
 #include "hb-shaper-list.hh"
 #undef HB_SHAPER_IMPLEMENT
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -46,11 +46,14 @@
 hb_shape_plan_plan (hb_shape_plan_t    *shape_plan,
                     const hb_feature_t *user_features,
                     unsigned int        num_user_features,
+                    const int          *coords,
+                    unsigned int        num_coords,
                     const char * const *shaper_list)
 {
   DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan,
-                  "num_features=%d shaper_list=%p",
+                  "num_features=%d num_coords=%d shaper_list=%p",
                   num_user_features,
+                  num_coords,
                   shaper_list);
 
   const hb_shaper_pair_t *shapers = _hb_shapers_get ();
@@ -59,7 +62,9 @@
         HB_STMT_START { \
           if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face_unsafe)) { \
             HB_SHAPER_DATA (shaper, shape_plan) = \
-              HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, user_features, num_user_features); \
+              HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, \
+                                                               user_features, num_user_features, \
+                                                               coords, num_coords); \
             shape_plan->shaper_func = _hb_##shaper##_shape; \
             shape_plan->shaper_name = #shaper; \
             return; \
@@ -96,13 +101,13 @@
 
 /**
  * hb_shape_plan_create: (Xconstructor)
- * @face:
- * @props:
+ * @face: 
+ * @props: 
  * @user_features: (array length=num_user_features):
- * @num_user_features:
+ * @num_user_features: 
  * @shaper_list: (array zero-terminated=1):
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -115,14 +120,31 @@
                       unsigned int                   num_user_features,
                       const char * const            *shaper_list)
 {
+  return hb_shape_plan_create2 (face, props,
+                                user_features, num_user_features,
+                                NULL, 0,
+                                shaper_list);
+}
+
+hb_shape_plan_t *
+hb_shape_plan_create2 (hb_face_t                     *face,
+                       const hb_segment_properties_t *props,
+                       const hb_feature_t            *user_features,
+                       unsigned int                   num_user_features,
+                       const int                     *orig_coords,
+                       unsigned int                   num_coords,
+                       const char * const            *shaper_list)
+{
   DEBUG_MSG_FUNC (SHAPE_PLAN, NULL,
-                  "face=%p num_features=%d shaper_list=%p",
+                  "face=%p num_features=%d num_coords=%d shaper_list=%p",
                   face,
                   num_user_features,
+                  num_coords,
                   shaper_list);
 
   hb_shape_plan_t *shape_plan;
   hb_feature_t *features = NULL;
+  int *coords = NULL;
 
   if (unlikely (!face))
     face = hb_face_get_empty ();
@@ -130,7 +152,14 @@
     return hb_shape_plan_get_empty ();
   if (num_user_features && !(features = (hb_feature_t *) calloc (num_user_features, sizeof (hb_feature_t))))
     return hb_shape_plan_get_empty ();
-  if (!(shape_plan = hb_object_create<hb_shape_plan_t> ())) {
+  if (num_coords && !(coords = (int *) calloc (num_coords, sizeof (int))))
+  {
+    free (features);
+    return hb_shape_plan_get_empty ();
+  }
+  if (!(shape_plan = hb_object_create<hb_shape_plan_t> ()))
+  {
+    free (coords);
     free (features);
     return hb_shape_plan_get_empty ();
   }
@@ -145,8 +174,15 @@
   shape_plan->user_features = features;
   if (num_user_features)
     memcpy (features, user_features, num_user_features * sizeof (hb_feature_t));
+  shape_plan->num_coords = num_coords;
+  shape_plan->coords = coords;
+  if (num_coords)
+    memcpy (coords, orig_coords, num_coords * sizeof (int));
 
-  hb_shape_plan_plan (shape_plan, user_features, num_user_features, shaper_list);
+  hb_shape_plan_plan (shape_plan,
+                      user_features, num_user_features,
+                      coords, num_coords,
+                      shaper_list);
 
   return shape_plan;
 }
@@ -154,7 +190,7 @@
 /**
  * hb_shape_plan_get_empty:
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -176,6 +212,9 @@
     NULL, /* user_features */
     0,    /* num_user_featurs */
 
+    NULL, /* coords */
+    0,    /* num_coords */
+
     {
 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
 #include "hb-shaper-list.hh"
@@ -190,7 +229,7 @@
  * hb_shape_plan_reference: (skip)
  * @shape_plan: a shape plan.
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -206,7 +245,7 @@
  * hb_shape_plan_destroy: (skip)
  * @shape_plan: a shape plan.
  *
- *
+ * 
  *
  * Since: 0.9.7
  **/
@@ -220,6 +259,7 @@
 #undef HB_SHAPER_IMPLEMENT
 
   free (shape_plan->user_features);
+  free (shape_plan->coords);
 
   free (shape_plan);
 }
@@ -227,14 +267,14 @@
 /**
  * hb_shape_plan_set_user_data: (skip)
  * @shape_plan: a shape plan.
- * @key:
- * @data:
- * @destroy:
- * @replace:
+ * @key: 
+ * @data: 
+ * @destroy: 
+ * @replace: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.7
  **/
@@ -251,9 +291,9 @@
 /**
  * hb_shape_plan_get_user_data: (skip)
  * @shape_plan: a shape plan.
- * @key:
+ * @key: 
  *
- *
+ * 
  *
  * Return value: (transfer none):
  *
@@ -273,11 +313,11 @@
  * @font: a font.
  * @buffer: a buffer.
  * @features: (array length=num_features):
- * @num_features:
- *
+ * @num_features: 
  *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.7
  **/
@@ -289,9 +329,10 @@
                        unsigned int        num_features)
 {
   DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan,
-                  "num_features=%d shaper_func=%p",
+                  "num_features=%d shaper_func=%p, shaper_name=%s",
                   num_features,
-                  shape_plan->shaper_func);
+                  shape_plan->shaper_func,
+                  shape_plan->shaper_name);
 
   if (unlikely (!buffer->len))
     return true;
@@ -350,6 +391,8 @@
   const char * const            *shaper_list;
   const hb_feature_t            *user_features;
   unsigned int                   num_user_features;
+  const int                     *coords;
+  unsigned int                   num_coords;
   hb_shape_func_t               *shaper_func;
 };
 
@@ -357,12 +400,26 @@
 hb_shape_plan_user_features_match (const hb_shape_plan_t          *shape_plan,
                                    const hb_shape_plan_proposal_t *proposal)
 {
-  if (proposal->num_user_features != shape_plan->num_user_features) return false;
+  if (proposal->num_user_features != shape_plan->num_user_features)
+    return false;
   for (unsigned int i = 0, n = proposal->num_user_features; i < n; i++)
     if (proposal->user_features[i].tag   != shape_plan->user_features[i].tag   ||
         proposal->user_features[i].value != shape_plan->user_features[i].value ||
         proposal->user_features[i].start != shape_plan->user_features[i].start ||
-        proposal->user_features[i].end   != shape_plan->user_features[i].end) return false;
+        proposal->user_features[i].end   != shape_plan->user_features[i].end)
+      return false;
+  return true;
+}
+
+static inline hb_bool_t
+hb_shape_plan_coords_match (const hb_shape_plan_t          *shape_plan,
+                            const hb_shape_plan_proposal_t *proposal)
+{
+  if (proposal->num_coords != shape_plan->num_coords)
+    return false;
+  for (unsigned int i = 0, n = proposal->num_coords; i < n; i++)
+    if (proposal->coords[i] != shape_plan->coords[i])
+      return false;
   return true;
 }
 
@@ -372,6 +429,7 @@
 {
   return hb_segment_properties_equal (&shape_plan->props, &proposal->props) &&
          hb_shape_plan_user_features_match (shape_plan, proposal) &&
+         hb_shape_plan_coords_match (shape_plan, proposal) &&
          ((shape_plan->default_shaper_list && proposal->shaper_list == NULL) ||
           (shape_plan->shaper_func == proposal->shaper_func));
 }
@@ -388,15 +446,22 @@
   return false;
 }
 
+static inline hb_bool_t
+hb_coords_present (const int *coords,
+                   unsigned int num_coords)
+{
+  return num_coords != 0;
+}
+
 /**
  * hb_shape_plan_create_cached:
- * @face:
- * @props:
+ * @face: 
+ * @props: 
  * @user_features: (array length=num_user_features):
- * @num_user_features:
+ * @num_user_features: 
  * @shaper_list: (array zero-terminated=1):
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -409,6 +474,21 @@
                              unsigned int                   num_user_features,
                              const char * const            *shaper_list)
 {
+  return hb_shape_plan_create_cached2 (face, props,
+                                       user_features, num_user_features,
+                                       NULL, 0,
+                                       shaper_list);
+}
+
+hb_shape_plan_t *
+hb_shape_plan_create_cached2 (hb_face_t                     *face,
+                              const hb_segment_properties_t *props,
+                              const hb_feature_t            *user_features,
+                              unsigned int                   num_user_features,
+                              const int                     *coords,
+                              unsigned int                   num_coords,
+                              const char * const            *shaper_list)
+{
   DEBUG_MSG_FUNC (SHAPE_PLAN, NULL,
                   "face=%p num_features=%d shaper_list=%p",
                   face,
@@ -455,16 +535,21 @@
 
   /* Not found. */
 
-  hb_shape_plan_t *shape_plan = hb_shape_plan_create (face, props, user_features, num_user_features, shaper_list);
+  hb_shape_plan_t *shape_plan = hb_shape_plan_create2 (face, props,
+                                                       user_features, num_user_features,
+                                                       coords, num_coords,
+                                                       shaper_list);
 
   /* Don't add to the cache if face is inert. */
   if (unlikely (hb_object_is_inert (face)))
     return shape_plan;
 
   /* Don't add the plan to the cache if there were user features with non-global ranges */
-
   if (hb_non_global_user_features_present (user_features, num_user_features))
     return shape_plan;
+  /* Don't add the plan to the cache if there were variation coordinates XXX Fix me. */
+  if (hb_coords_present (coords, num_coords))
+    return shape_plan;
 
   hb_face_t::plan_node_t *node = (hb_face_t::plan_node_t *) calloc (1, sizeof (hb_face_t::plan_node_t));
   if (unlikely (!node))
@@ -487,7 +572,7 @@
  * hb_shape_plan_get_shaper:
  * @shape_plan: a shape plan.
  *
- *
+ * 
  *
  * Return value: (transfer none):
  *
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.h	Tue Jan 24 00:30:25 2017 +0100
@@ -53,6 +53,25 @@
                              const char * const            *shaper_list);
 
 HB_EXTERN hb_shape_plan_t *
+hb_shape_plan_create2 (hb_face_t                     *face,
+                       const hb_segment_properties_t *props,
+                       const hb_feature_t            *user_features,
+                       unsigned int                   num_user_features,
+                       const int                     *coords,
+                       unsigned int                   num_coords,
+                       const char * const            *shaper_list);
+
+HB_EXTERN hb_shape_plan_t *
+hb_shape_plan_create_cached2 (hb_face_t                     *face,
+                              const hb_segment_properties_t *props,
+                              const hb_feature_t            *user_features,
+                              unsigned int                   num_user_features,
+                              const int                     *coords,
+                              unsigned int                   num_coords,
+                              const char * const            *shaper_list);
+
+
+HB_EXTERN hb_shape_plan_t *
 hb_shape_plan_get_empty (void);
 
 HB_EXTERN hb_shape_plan_t *
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -373,7 +373,10 @@
                unsigned int        num_features,
                const char * const *shaper_list)
 {
-  hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props, features, num_features, shaper_list);
+  hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached2 (font->face, &buffer->props,
+                                                              features, num_features,
+                                                              font->coords, font->num_coords,
+                                                              shaper_list);
   hb_bool_t res = hb_shape_plan_execute (shape_plan, font, buffer, features, num_features);
   hb_shape_plan_destroy (shape_plan);
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-unicode.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-unicode.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -131,12 +131,12 @@
 #define HB_UNICODE_FUNCS_IMPLEMENT(set) \
   return hb_##set##_get_unicode_funcs ();
 
-#ifdef HAVE_GLIB
+#if defined(HAVE_UCDN)
+  HB_UNICODE_FUNCS_IMPLEMENT(ucdn)
+#elif defined(HAVE_GLIB)
   HB_UNICODE_FUNCS_IMPLEMENT(glib)
 #elif defined(HAVE_ICU) && defined(HAVE_ICU_BUILTIN)
   HB_UNICODE_FUNCS_IMPLEMENT(icu)
-#elif defined(HAVE_UCDN)
-  HB_UNICODE_FUNCS_IMPLEMENT(ucdn)
 #else
 #define HB_UNICODE_FUNCS_NIL 1
   HB_UNICODE_FUNCS_IMPLEMENT(nil)
@@ -154,7 +154,7 @@
  * hb_unicode_funcs_create: (Xconstructor)
  * @parent: (nullable):
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -200,7 +200,7 @@
 /**
  * hb_unicode_funcs_get_empty:
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -216,7 +216,7 @@
  * hb_unicode_funcs_reference: (skip)
  * @ufuncs: Unicode functions.
  *
- *
+ * 
  *
  * Return value: (transfer full):
  *
@@ -232,7 +232,7 @@
  * hb_unicode_funcs_destroy: (skip)
  * @ufuncs: Unicode functions.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -254,14 +254,14 @@
 /**
  * hb_unicode_funcs_set_user_data: (skip)
  * @ufuncs: Unicode functions.
- * @key:
- * @data:
- * @destroy:
- * @replace:
+ * @key: 
+ * @data: 
+ * @destroy: 
+ * @replace: 
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -278,9 +278,9 @@
 /**
  * hb_unicode_funcs_get_user_data: (skip)
  * @ufuncs: Unicode functions.
- * @key:
+ * @key: 
  *
- *
+ * 
  *
  * Return value: (transfer none):
  *
@@ -298,7 +298,7 @@
  * hb_unicode_funcs_make_immutable:
  * @ufuncs: Unicode functions.
  *
- *
+ * 
  *
  * Since: 0.9.2
  **/
@@ -315,9 +315,9 @@
  * hb_unicode_funcs_is_immutable:
  * @ufuncs: Unicode functions.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -331,9 +331,9 @@
  * hb_unicode_funcs_get_parent:
  * @ufuncs: Unicode functions.
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -387,13 +387,13 @@
 /**
  * hb_unicode_compose:
  * @ufuncs: Unicode functions.
- * @a:
- * @b:
+ * @a: 
+ * @b: 
  * @ab: (out):
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -409,13 +409,13 @@
 /**
  * hb_unicode_decompose:
  * @ufuncs: Unicode functions.
- * @ab:
+ * @ab: 
  * @a: (out):
  * @b: (out):
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
@@ -431,12 +431,12 @@
 /**
  * hb_unicode_decompose_compatibility:
  * @ufuncs: Unicode functions.
- * @u:
+ * @u: 
  * @decomposed: (out):
  *
- *
+ * 
  *
- * Return value:
+ * Return value: 
  *
  * Since: 0.9.2
  **/
--- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-version.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-version.h	Tue Jan 24 00:30:25 2017 +0100
@@ -37,10 +37,10 @@
 
 
 #define HB_VERSION_MAJOR 1
-#define HB_VERSION_MINOR 3
-#define HB_VERSION_MICRO 0
+#define HB_VERSION_MINOR 4
+#define HB_VERSION_MICRO 1
 
-#define HB_VERSION_STRING "1.3.0"
+#define HB_VERSION_STRING "1.4.1"
 
 #define HB_VERSION_ATLEAST(major,minor,micro) \
         ((major)*10000+(minor)*100+(micro) <= \
--- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc	Tue Jan 24 00:30:25 2017 +0100
@@ -49,7 +49,7 @@
     JNIEnv* env = jdkFontInfo->env;
     jobject font2D = jdkFontInfo->font2D;
     hb_codepoint_t u = (variation_selector==0) ? unicode : variation_selector;
- 
+
     *glyph = (hb_codepoint_t)
           env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, u);
     return (*glyph != 0);
@@ -61,7 +61,7 @@
 			   hb_codepoint_t glyph,
 			   void *user_data HB_UNUSED)
 {
-    
+
     float fadv = 0.0f;
     if ((glyph & 0xfffe) == 0xfffe) {
         return 0; // JDK uses this glyph code.
@@ -72,7 +72,7 @@
     jobject fontStrike = jdkFontInfo->fontStrike;
     jobject pt = env->CallObjectMethod(fontStrike,
                                        sunFontIDs.getGlyphMetricsMID, glyph);
-  
+
     if (pt == NULL) {
         return 0;
     }
@@ -89,7 +89,7 @@
 			   hb_codepoint_t glyph,
 			   void *user_data HB_UNUSED)
 {
-  
+
     float fadv = 0.0f;
     if ((glyph & 0xfffe) == 0xfffe) {
         return 0; // JDK uses this glyph code.
@@ -100,7 +100,7 @@
     jobject fontStrike = jdkFontInfo->fontStrike;
     jobject pt = env->CallObjectMethod(fontStrike,
                                        sunFontIDs.getGlyphMetricsMID, glyph);
-  
+
     if (pt == NULL) {
         return 0;
     }
@@ -108,7 +108,7 @@
     env->DeleteLocalRef(pt);
 
     return HBFloatToFixed(fadv);
-  
+
 }
 
 static hb_bool_t
@@ -196,7 +196,7 @@
     jobject pt = env->CallObjectMethod(fontStrike,
                                        sunFontIDs.getGlyphPointMID,
                                        glyph, point_index);
-  
+
     if (pt == NULL) {
         *x = 0; *y = 0;
         return true;
@@ -238,8 +238,8 @@
   hb_font_funcs_t *ff;
 
   if (!jdk_ffuncs) {
-      ff = hb_font_funcs_create(); 
-      
+      ff = hb_font_funcs_create();
+
       hb_font_funcs_set_glyph_func(ff, hb_jdk_get_glyph, NULL, NULL);
       hb_font_funcs_set_glyph_h_advance_func(ff,
                     hb_jdk_get_glyph_h_advance, NULL, NULL);
@@ -278,7 +278,7 @@
   jobject font2D = jdkFontInfo->font2D;
   jsize length;
   jbyte* buffer;
-  
+
   // HB_TAG_NONE is 0 and is used to get the whole font file.
   // It is not expected not be needed for JDK.
   if (tag == 0) {
--- a/jdk/src/java.desktop/share/native/libmlib_image/safe_alloc.h	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/share/native/libmlib_image/safe_alloc.h	Tue Jan 24 00:30:25 2017 +0100
@@ -35,10 +35,10 @@
  */
 #define SAFE_TO_ALLOC_2(c, sz)                                             \
     (((c) > 0) && ((sz) > 0) &&                                            \
-     ((0xffffffffu / ((juint)(c))) > ((juint)(sz))))
+     ((0x7fffffff / (c)) > (sz)))
 
 #define SAFE_TO_ALLOC_3(w, h, sz)                                          \
     (((w) > 0) && ((h) > 0) && ((sz) > 0) &&                               \
-     (((0xffffffffu / ((juint)(w))) / ((juint)(h))) > ((juint)(sz))))
+     (((0x7fffffff / (w)) / (h)) > (sz)))
 
 #endif // __SAFE_ALLOC_H__
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -51,9 +51,9 @@
     boolean insets_corrected;
 
     XIconWindow iconWindow;
-    WindowDimensions dimensions;
+    volatile WindowDimensions dimensions;
     XContentWindow content;
-    Insets currentInsets;
+    volatile Insets currentInsets;
     XFocusProxyWindow focusProxy;
     static final Map<Class<?>,Insets> lastKnownInsets =
                                    Collections.synchronizedMap(new HashMap<>());
@@ -106,7 +106,7 @@
 
         // The lines that follow need to be in a postInit, so they
         // happen after the X window is created.
-        initResizability();
+        setResizable(winAttr.initialResizability);
         XWM.requestWMExtents(getWindow());
 
         content = XContentWindow.createContent(this);
@@ -130,7 +130,12 @@
 
     public void updateMinimumSize() {
         super.updateMinimumSize();
-        updateMinSizeHints();
+        XToolkit.awtLock();
+        try {
+            updateMinSizeHints();
+        } finally {
+            XToolkit.awtUnlock();
+        }
     }
 
     private void updateMinSizeHints() {
@@ -193,8 +198,13 @@
         if (log.isLoggable(PlatformLogger.Level.FINE)) {
             log.fine("Title is " + title);
         }
-        winAttr.title = title;
-        updateWMName();
+        XToolkit.awtLock();
+        try {
+            winAttr.title = title;
+            updateWMName();
+        } finally {
+            XToolkit.awtUnlock();
+        }
     }
 
     protected String getWMName() {
@@ -206,10 +216,10 @@
     }
 
     void updateWMName() {
-        super.updateWMName();
-        String name = getWMName();
         XToolkit.awtLock();
         try {
+            super.updateWMName();
+            String name = getWMName();
             if (name == null || name.trim().equals("")) {
                 name = "Java";
             }
@@ -304,6 +314,8 @@
         if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
             currentInsets = new Insets(0, 0, 0, 0);
             wm_set_insets = null;
+        } else {
+            insets_corrected = false;
         }
     }
 
@@ -330,7 +342,7 @@
             if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
                 getWMSetInsets(XAtom.get(ev.get_atom()));
             } else {
-                if(!isReparented()) {
+                if (!isReparented()) {
                     return;
                 }
                 wm_set_insets = null;
@@ -377,137 +389,127 @@
             insLog.fine(xe.toString());
         }
         reparent_serial = xe.get_serial();
-        XToolkit.awtLock();
-        try {
-            long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
+        long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
+
+        if (isEmbedded()) {
+            setReparented(true);
+            insets_corrected = true;
+            return;
+        }
+        if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
+            setReparented(true);
+            insets_corrected = true;
+            reshape(dimensions, SET_SIZE, false);
+        } else if (xe.get_parent() == root) {
+            configure_seen = false;
+            insets_corrected = false;
 
-            if (isEmbedded()) {
-                setReparented(true);
-                insets_corrected = true;
+            /*
+             * We can be repareted to root for two reasons:
+             *   . setVisible(false)
+             *   . WM exited
+             */
+            if (isVisible()) { /* WM exited */
+                /* Work around 4775545 */
+                XWM.getWM().unshadeKludge(this);
+                insLog.fine("- WM exited");
+            } else {
+                insLog.fine(" - reparent due to hide");
+            }
+        } else { /* reparented to WM frame, figure out our insets */
+            setReparented(true);
+            insets_corrected = false;
+            if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
                 return;
             }
-            Component t = target;
-            if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
-                setReparented(true);
-                insets_corrected = true;
-                reshape(dimensions, SET_SIZE, false);
-            } else if (xe.get_parent() == root) {
-                configure_seen = false;
-                insets_corrected = false;
 
-                /*
-                 * We can be repareted to root for two reasons:
-                 *   . setVisible(false)
-                 *   . WM exited
-                 */
-                if (isVisible()) { /* WM exited */
-                    /* Work around 4775545 */
-                    XWM.getWM().unshadeKludge(this);
-                    insLog.fine("- WM exited");
-                } else {
-                    insLog.fine(" - reparent due to hide");
+            // Check if we have insets provided by the WM
+            Insets correctWM = getWMSetInsets(null);
+            if (correctWM != null) {
+                if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
+                    insLog.finer("wm-provided insets {0}", correctWM);
                 }
-            } else { /* reparented to WM frame, figure out our insets */
-                setReparented(true);
-                insets_corrected = false;
-                if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
+                // If these insets are equal to our current insets - no actions are necessary
+                Insets dimInsets = dimensions.getInsets();
+                if (correctWM.equals(dimInsets)) {
+                    insLog.finer("Insets are the same as estimated - no additional reshapes necessary");
+                    no_reparent_artifacts = true;
+                    insets_corrected = true;
+                    applyGuessedInsets();
                     return;
                 }
+            } else {
+                correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());
+                if (correctWM != null) {
+                    correctWM = copyAndScaleDown(correctWM);
+                }
 
-                // Check if we have insets provided by the WM
-                Insets correctWM = getWMSetInsets(null);
-                if (correctWM != null) {
-                    if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
-                        insLog.finer("wm-provided insets {0}", correctWM);
-                    }
-                    // If these insets are equal to our current insets - no actions are necessary
-                    Insets dimInsets = dimensions.getInsets();
-                    if (correctWM.equals(dimInsets)) {
-                        insLog.finer("Insets are the same as estimated - no additional reshapes necessary");
-                        no_reparent_artifacts = true;
-                        insets_corrected = true;
-                        applyGuessedInsets();
-                        return;
-                    }
-                } else {
-                    correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());
+                if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
                     if (correctWM != null) {
-                        correctWM = copyAndScaleDown(correctWM);
-                    }
-
-                    if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
-                        if (correctWM != null) {
-                            insLog.finer("correctWM {0}", correctWM);
-                        } else {
-                            insLog.finer("correctWM insets are not available, waiting for configureNotify");
-                        }
+                        insLog.finer("correctWM {0}", correctWM);
+                    } else {
+                        insLog.finer("correctWM insets are not available, waiting for configureNotify");
                     }
                 }
+            }
 
-                if (correctWM != null) {
-                    handleCorrectInsets(correctWM);
-                }
+            if (correctWM != null) {
+                handleCorrectInsets(correctWM);
             }
-        } finally {
-            XToolkit.awtUnlock();
         }
     }
 
-    protected void handleCorrectInsets(Insets correctWM) {
-        XToolkit.awtLock();
-        try {
-            /*
-             * Ok, now see if we need adjust window size because
-             * initial insets were wrong (most likely they were).
-             */
-            Insets correction = difference(correctWM, currentInsets);
-            if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
-                insLog.finest("Corrention {0}", correction);
-            }
-            if (!isNull(correction)) {
-                currentInsets = copy(correctWM);
-                applyGuessedInsets();
+    private void handleCorrectInsets(Insets correctWM) {
+        /*
+         * Ok, now see if we need adjust window size because
+         * initial insets were wrong (most likely they were).
+         */
+        Insets correction = difference(correctWM, currentInsets);
+        if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
+            insLog.finest("Corrention {0}", correction);
+        }
+        if (!isNull(correction)) {
+            currentInsets = copy(correctWM);
+            applyGuessedInsets();
 
-                //Fix for 6318109: PIT: Min Size is not honored properly when a
-                //smaller size is specified in setSize(), XToolkit
-                //update minimum size hints
-                updateMinSizeHints();
-            }
-            if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
-                insLog.finer("Dimensions before reparent: " + dimensions);
-            }
-
-            dimensions.setInsets(getRealInsets());
-            insets_corrected = true;
+            //Fix for 6318109: PIT: Min Size is not honored properly when a
+            //smaller size is specified in setSize(), XToolkit
+            //update minimum size hints
+            updateMinSizeHints();
+        }
+        if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
+            insLog.finer("Dimensions before reparent: " + dimensions);
+        }
+        WindowDimensions newDimensions = new WindowDimensions(dimensions);
+        newDimensions.setInsets(getRealInsets());
+        dimensions = newDimensions;
+        insets_corrected = true;
 
-            if (isMaximized()) {
-                return;
-            }
+        if (isMaximized()) {
+            return;
+        }
 
-            /*
-             * If this window has been sized by a pack() we need
-             * to keep the interior geometry intact.  Since pack()
-             * computed width and height with wrong insets, we
-             * must adjust the target dimensions appropriately.
-             */
-            if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) {
-                reshape(dimensions, SET_BOUNDS, false);
-            } else {
-                reshape(dimensions, SET_SIZE, false);
-            }
-        } finally {
-            XToolkit.awtUnlock();
+        /*
+         * If this window has been sized by a pack() we need
+         * to keep the interior geometry intact.  Since pack()
+         * computed width and height with wrong insets, we
+         * must adjust the target dimensions appropriately.
+         */
+        if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) {
+            reshape(dimensions, SET_BOUNDS, false);
+        } else {
+            reshape(dimensions, SET_SIZE, false);
         }
     }
 
-    public void handleMoved(WindowDimensions dims) {
+    void handleMoved(WindowDimensions dims) {
         Point loc = dims.getLocation();
         AWTAccessor.getComponentAccessor().setLocation(target, loc.x, loc.y);
         postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
     }
 
 
-    protected Insets guessInsets() {
+    private Insets guessInsets() {
         if (isEmbedded() || isTargetUndecorated()) {
             return new Insets(0, 0, 0, 0);
         } else {
@@ -532,16 +534,7 @@
         currentInsets = copy(guessed);
     }
 
-    public void revalidate() {
-        XToolkit.executeOnEventHandlerThread(target, new Runnable() {
-                public void run() {
-                    target.invalidate();
-                    target.validate();
-                }
-            });
-    }
-
-    Insets getRealInsets() {
+    private Insets getRealInsets() {
         if (isNull(currentInsets)) {
             applyGuessedInsets();
         }
@@ -578,7 +571,7 @@
 
     // Coordinates are that of the target
     // Called only on Toolkit thread
-    public void reshape(WindowDimensions newDimensions, int op,
+    private void reshape(WindowDimensions newDimensions, int op,
                         boolean userReshape)
     {
         if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
@@ -599,81 +592,75 @@
             }
             newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet());
         }
-        XToolkit.awtLock();
-        try {
-            if (!isReparented() || !isVisible()) {
-                if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
-                    insLog.fine("- not reparented({0}) or not visible({1}), default reshape",
-                           Boolean.valueOf(isReparented()), Boolean.valueOf(visible));
-                }
-
-                // Fix for 6323293.
-                // This actually is needed to preserve compatibility with previous releases -
-                // some of licensees are expecting componentMoved event on invisible one while
-                // its location changes.
-                Point oldLocation = getLocation();
+        if (!isReparented() || !isVisible()) {
+            if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
+                insLog.fine("- not reparented({0}) or not visible({1}), default reshape",
+                       Boolean.valueOf(isReparented()), Boolean.valueOf(visible));
+            }
 
-                Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX(target),
-                                              AWTAccessor.getComponentAccessor().getY(target));
-
-                if (!newLocation.equals(oldLocation)) {
-                    handleMoved(newDimensions);
-                }
+            // Fix for 6323293.
+            // This actually is needed to preserve compatibility with previous releases -
+            // some of licensees are expecting componentMoved event on invisible one while
+            // its location changes.
+            Point oldLocation = getLocation();
 
-                dimensions = new WindowDimensions(newDimensions);
-                updateSizeHints(dimensions);
-                Rectangle client = dimensions.getClientRect();
-                checkShellRect(client);
-                setShellBounds(client);
-                if (content != null &&
-                    !content.getSize().equals(newDimensions.getSize()))
-                {
-                    reconfigureContentWindow(newDimensions);
-                }
-                return;
+            Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX(target),
+                                          AWTAccessor.getComponentAccessor().getY(target));
+
+            if (!newLocation.equals(oldLocation)) {
+                handleMoved(newDimensions);
             }
 
-            int wm = XWM.getWMID();
-            updateChildrenSizes();
-            applyGuessedInsets();
-
-            Rectangle shellRect = newDimensions.getClientRect();
-
-            if (gravityBug()) {
-                Insets in = newDimensions.getInsets();
-                shellRect.translate(in.left, in.top);
+            dimensions = new WindowDimensions(newDimensions);
+            updateSizeHints(dimensions);
+            Rectangle client = dimensions.getClientRect();
+            checkShellRect(client);
+            setShellBounds(client);
+            if (content != null &&
+                !content.getSize().equals(newDimensions.getSize()))
+            {
+                reconfigureContentWindow(newDimensions);
             }
+            return;
+        }
 
-            if ((op & NO_EMBEDDED_CHECK) == 0 && isEmbedded()) {
-                shellRect.setLocation(0, 0);
-            }
+        updateChildrenSizes();
+        applyGuessedInsets();
 
-            checkShellRectSize(shellRect);
-            if (!isEmbedded()) {
-                checkShellRectPos(shellRect);
-            }
+        Rectangle shellRect = newDimensions.getClientRect();
+
+        if (gravityBug()) {
+            Insets in = newDimensions.getInsets();
+            shellRect.translate(in.left, in.top);
+        }
 
-            op = op & ~NO_EMBEDDED_CHECK;
+        if ((op & NO_EMBEDDED_CHECK) == 0 && isEmbedded()) {
+            shellRect.setLocation(0, 0);
+        }
 
-            if (op == SET_LOCATION) {
-                setShellPosition(shellRect);
-            } else if (isResizable()) {
-                if (op == SET_BOUNDS) {
-                    setShellBounds(shellRect);
-                } else {
-                    setShellSize(shellRect);
-                }
+        checkShellRectSize(shellRect);
+        if (!isEmbedded()) {
+            checkShellRectPos(shellRect);
+        }
+
+        op = op & ~NO_EMBEDDED_CHECK;
+
+        if (op == SET_LOCATION) {
+            setShellPosition(shellRect);
+        } else if (isResizable()) {
+            if (op == SET_BOUNDS) {
+                setShellBounds(shellRect);
             } else {
-                XWM.setShellNotResizable(this, newDimensions, shellRect, true);
-                if (op == SET_BOUNDS) {
-                    setShellPosition(shellRect);
-                }
+                setShellSize(shellRect);
             }
+        } else {
+            XWM.setShellNotResizable(this, newDimensions, shellRect, true);
+            if (op == SET_BOUNDS) {
+                setShellPosition(shellRect);
+            }
+        }
 
-            reconfigureContentWindow(newDimensions);
-        } finally {
-            XToolkit.awtUnlock();
-        }
+        reconfigureContentWindow(newDimensions);
     }
 
     /**
@@ -682,8 +669,6 @@
     private void reshape(int x, int y, int width, int height, int operation,
                          boolean userReshape)
     {
-        Rectangle newRec;
-        boolean setClient = false;
         WindowDimensions dims = new WindowDimensions(dimensions);
         switch (operation & (~NO_EMBEDDED_CHECK)) {
           case SET_LOCATION:
@@ -726,7 +711,12 @@
      */
     public void setBounds(int x, int y, int width, int height, int op) {
         // TODO: Rewrite with WindowDimensions
-        reshape(x, y, width, height, op, true);
+        XToolkit.awtLock();
+        try {
+            reshape(x, y, width, height, op, true);
+        } finally {
+            XToolkit.awtUnlock();
+        }
         validateSurface();
     }
 
@@ -861,81 +851,74 @@
         checkShellRectPos(shellRect);
     }
 
-    public void setShellBounds(Rectangle rec) {
+    private void setShellBounds(Rectangle rec) {
         if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
             insLog.fine("Setting shell bounds on " + this + " to " + rec);
         }
-        XToolkit.awtLock();
-        try {
-            updateSizeHints(rec.x, rec.y, rec.width, rec.height);
-            XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getShell(),
-                                          scaleUp(rec.x), scaleUp(rec.y),
-                                          scaleUp(rec.width), scaleUp(rec.height));
-        }
-        finally {
-            XToolkit.awtUnlock();
-        }
+        updateSizeHints(rec.x, rec.y, rec.width, rec.height);
+        XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getShell(),
+                                      scaleUp(rec.x), scaleUp(rec.y),
+                                      scaleUp(rec.width), scaleUp(rec.height));
     }
-    public void setShellSize(Rectangle rec) {
+
+    private void setShellSize(Rectangle rec) {
         if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
             insLog.fine("Setting shell size on " + this + " to " + rec);
         }
-        XToolkit.awtLock();
-        try {
-            updateSizeHints(rec.x, rec.y, rec.width, rec.height);
-            XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(),
-                                      scaleUp(rec.width), scaleUp(rec.height));
-        }
-        finally {
-            XToolkit.awtUnlock();
-        }
+        updateSizeHints(rec.x, rec.y, rec.width, rec.height);
+        XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(),
+                                  scaleUp(rec.width), scaleUp(rec.height));
     }
-    public void setShellPosition(Rectangle rec) {
+
+    private void setShellPosition(Rectangle rec) {
         if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
             insLog.fine("Setting shell position on " + this + " to " + rec);
         }
-        XToolkit.awtLock();
-        try {
-            updateSizeHints(rec.x, rec.y, rec.width, rec.height);
-            XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(),
-                                    scaleUp(rec.x), scaleUp(rec.y));
-        }
-        finally {
-            XToolkit.awtUnlock();
-        }
+        updateSizeHints(rec.x, rec.y, rec.width, rec.height);
+        XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(),
+                                scaleUp(rec.x), scaleUp(rec.y));
     }
 
-    void initResizability() {
-        setResizable(winAttr.initialResizability);
-    }
     public void setResizable(boolean resizable) {
-        int fs = winAttr.functions;
-        if (!isResizable() && resizable) {
-            resetWMSetInsets();
-            if (!isEmbedded()) {
-                setReparented(false);
-            }
-            winAttr.isResizable = resizable;
-            if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) {
-                fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
-            } else {
-                fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
+        XToolkit.awtLock();
+        try {
+            int fs = winAttr.functions;
+            if (!isResizable() && resizable) {
+                resetWMSetInsets();
+                if (!isEmbedded()) {
+                    setReparented(false);
+                }
+                winAttr.isResizable = resizable;
+                if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) {
+                    fs &= ~(MWMConstants.MWM_FUNC_RESIZE
+                          | MWMConstants.MWM_FUNC_MAXIMIZE);
+                } else {
+                    fs |= (MWMConstants.MWM_FUNC_RESIZE
+                         | MWMConstants.MWM_FUNC_MAXIMIZE);
+                }
+                winAttr.functions = fs;
+                XWM.setShellResizable(this);
+            } else if (isResizable() && !resizable) {
+                resetWMSetInsets();
+                if (!isEmbedded()) {
+                    setReparented(false);
+                }
+                winAttr.isResizable = resizable;
+                if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) {
+                    fs |= (MWMConstants.MWM_FUNC_RESIZE
+                         | MWMConstants.MWM_FUNC_MAXIMIZE);
+                } else {
+                    fs &= ~(MWMConstants.MWM_FUNC_RESIZE
+                          | MWMConstants.MWM_FUNC_MAXIMIZE);
+                }
+                winAttr.functions = fs;
+                XWM.setShellNotResizable(this, dimensions,
+                        XWM.getWMID() == XWM.UNITY_COMPIZ_WM && configure_seen ?
+                        dimensions.getScreenBounds() :
+                        dimensions.getBounds(), false);
             }
-            winAttr.functions = fs;
-            XWM.setShellResizable(this);
-        } else if (isResizable() && !resizable) {
-            resetWMSetInsets();
-            if (!isEmbedded()) {
-                setReparented(false);
-            }
-            winAttr.isResizable = resizable;
-            if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) {
-                fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
-            } else {
-                fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE);
-            }
-            winAttr.functions = fs;
-            XWM.setShellNotResizable(this, dimensions, dimensions.getBounds(), false);
+        } finally {
+            XToolkit.awtUnlock();
         }
     }
 
@@ -990,17 +973,16 @@
         try {
             if (configure_seen) {
                 return toGlobal(0,0);
-            } else {
-                Point location = target.getLocation();
-                if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
-                    insLog.fine("getLocationOnScreen {0} not reparented: {1} ",
-                                this, location);
-                }
-                return location;
             }
         } finally {
             XToolkit.awtUnlock();
         }
+        Point location = target.getLocation();
+        if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
+            insLog.fine("getLocationOnScreen {0} not reparented: {1} ",
+                        this, location);
+        }
+        return location;
     }
 
 
@@ -1134,7 +1116,7 @@
         return focusProxy;
     }
 
-    public void handleQuit() {
+    private void handleQuit() {
         postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING));
     }
 
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -248,9 +248,11 @@
         XMenuItemPeer.TextMetrics[] itemMetrics = new XMenuItemPeer.TextMetrics[itemCnt];
         for (int i = 0; i < itemCnt; i++) {
             itemMetrics[i] = itemVector[i].getTextMetrics();
-            Dimension dim = itemMetrics[i].getTextDimension();
-            if (dim != null) {
-                maxHeight = Math.max(maxHeight, dim.height);
+            if (itemMetrics[i] != null) {
+                Dimension dim = itemMetrics[i].getTextDimension();
+                if (dim != null) {
+                    maxHeight = Math.max(maxHeight, dim.height);
+                }
             }
         }
         //Calculate bounds
@@ -260,6 +262,9 @@
         for (int i = 0; i < itemCnt; i++) {
             XMenuItemPeer item = itemVector[i];
             XMenuItemPeer.TextMetrics metrics = itemMetrics[i];
+            if (metrics == null) {
+                continue;
+            }
             Dimension dim = metrics.getTextDimension();
             if (dim != null) {
                 int itemWidth = BAR_ITEM_MARGIN_LEFT + dim.width + BAR_ITEM_MARGIN_RIGHT;
@@ -280,9 +285,6 @@
                 Point textOrigin = new Point(nextOffset + BAR_ITEM_MARGIN_LEFT, BAR_SPACING_TOP + BAR_ITEM_MARGIN_TOP + y);
                 nextOffset += itemWidth + BAR_ITEM_SPACING;
                 item.map(bounds, textOrigin);
-            } else {
-                Rectangle bounds = new Rectangle(nextOffset, BAR_SPACING_TOP, 0, 0);
-                Point textOrigin = new Point(nextOffset + BAR_ITEM_MARGIN_LEFT, BAR_SPACING_TOP + BAR_ITEM_MARGIN_TOP);
             }
         }
         XMenuItemPeer mappedVector[] = new XMenuItemPeer[mappedCnt];
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -27,7 +27,7 @@
 import java.awt.*;
 import java.awt.peer.*;
 import java.security.AccessController;
-import java.security.PrivilegedAction;
+import sun.security.action.GetPropertyAction;
 
 import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
@@ -40,11 +40,11 @@
     static final boolean tryGtk;
     static {
         loadNativeLibraries();
-        tryGtk = AccessController.doPrivileged((PrivilegedAction<Boolean>)()
-                -> Boolean.getBoolean("awt.robot.gtk"));
+        tryGtk = Boolean.parseBoolean(
+                            AccessController.doPrivileged(
+                                    new GetPropertyAction("awt.robot.gtk", "true")
+                            ));
     }
-
-    private static boolean isGtkSupported =  false;
     private static volatile boolean useGtk;
     private X11GraphicsConfig   xgc = null;
 
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1029,8 +1029,14 @@
         }
         XToolkit.awtLock();
         try {
-            Rectangle shellBounds = window.getShellBounds();
-            shellBounds.translate(-window.currentInsets.left, -window.currentInsets.top);
+            Rectangle shellBounds;
+            if (getWMID() != UNITY_COMPIZ_WM) {
+                shellBounds = window.getShellBounds();
+                shellBounds.translate(-window.currentInsets.left,
+                                      -window.currentInsets.top);
+            } else {
+                shellBounds = window.getDimensions().getScreenBounds();
+            }
             window.updateSizeHints(window.getDimensions());
             requestWMExtents(window.getWindow());
             XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(),
--- a/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1053,15 +1053,8 @@
             // of setting it, it is a safe assumption to just always
             // include SheetCollate as supported attribute.
 
-            /*
-               In Linux, we use Postscript for rendering but Linux still
-               has issues in propagating Postscript-embedded setpagedevice
-               setting like collation.  Therefore, we temporarily exclude
-               Linux.
-            */
-            if (!PrintServiceLookupProvider.isLinux()) {
-                catList.add(SheetCollate.class);
-            }
+            catList.add(SheetCollate.class);
+
         }
 
         // With the assumption that  Chromaticity is equivalent to
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Tue Jan 24 00:30:25 2017 +0100
@@ -99,7 +99,6 @@
 HWND AwtComponent::sm_focusOwner = NULL;
 HWND AwtComponent::sm_focusedWindow = NULL;
 BOOL AwtComponent::sm_bMenuLoop = FALSE;
-AwtComponent* AwtComponent::sm_getComponentCache = NULL;
 BOOL AwtComponent::sm_inSynthesizeFocus = FALSE;
 
 /************************************************************************/
@@ -276,10 +275,6 @@
      * handle.
      */
     DestroyHWnd();
-
-    if (sm_getComponentCache == this) {
-        sm_getComponentCache = NULL;
-    }
 }
 
 void AwtComponent::Dispose()
@@ -352,9 +347,6 @@
     if (hWnd == AwtToolkit::GetInstance().GetHWnd()) {
         return NULL;
     }
-    if (sm_getComponentCache && sm_getComponentCache->GetHWnd() == hWnd) {
-        return sm_getComponentCache;
-    }
 
     // check that it's an AWT component from the same toolkit as the caller
     if (::IsWindow(hWnd) &&
@@ -362,7 +354,7 @@
     {
         DASSERT(WmAwtIsComponent != 0);
         if (::SendMessage(hWnd, WmAwtIsComponent, 0, 0L)) {
-            return sm_getComponentCache = GetComponentImpl(hWnd);
+            return GetComponentImpl(hWnd);
         }
     }
     return NULL;
--- a/jdk/src/java.logging/share/classes/java/util/logging/Level.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.logging/share/classes/java/util/logging/Level.java	Tue Jan 24 00:30:25 2017 +0100
@@ -692,11 +692,14 @@
                     Level levelObject = ref.get();
                     if (levelObject == null) continue;
                     Level other = ref.mirroredLevel;
+                    Class<? extends Level> type = levelObject.getClass();
                     if (l.value == other.value &&
                            (l.resourceBundleName == other.resourceBundleName ||
                                (l.resourceBundleName != null &&
                                 l.resourceBundleName.equals(other.resourceBundleName)))) {
-                        return Optional.of(levelObject);
+                        if (type == l.getClass()) {
+                            return Optional.of(levelObject);
+                        }
                     }
                 }
             }
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -619,13 +619,21 @@
             throw new IOException("LogRecord: bad version: " + major + "." + minor);
         }
         int len = in.readInt();
-        if (len == -1) {
+        if (len < -1) {
+            throw new NegativeArraySizeException();
+        } else if (len == -1) {
             parameters = null;
-        } else {
+        } else if (len < 255) {
             parameters = new Object[len];
             for (int i = 0; i < parameters.length; i++) {
                 parameters[i] = in.readObject();
             }
+        } else {
+            List<Object> params = new ArrayList<>(Math.min(len, 1024));
+            for (int i = 0; i < len; i++) {
+                params.add(in.readObject());
+            }
+            parameters = params.toArray(new Object[params.size()]);
         }
         // If necessary, try to regenerate the resource bundle.
         if (resourceBundleName != null) {
--- a/jdk/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 package com.sun.jmx.defaults;
 
-import java.util.logging.Logger;
+import java.lang.System.Logger;
 
 /**
  * This contains the property list defined for this
@@ -120,7 +120,7 @@
      * Logger for MBean Server information.
      */
     public static final Logger MBEANSERVER_LOGGER =
-            Logger.getLogger(MBEANSERVER_LOGGER_NAME);
+            System.getLogger(MBEANSERVER_LOGGER_NAME);
 
     /**
      * Logger name for MLet service information.
@@ -132,7 +132,7 @@
      * Logger for MLet service information.
      */
     public static final Logger MLET_LOGGER =
-            Logger.getLogger(MLET_LOGGER_NAME);
+            System.getLogger(MLET_LOGGER_NAME);
 
     /**
      * Logger name for Monitor information.
@@ -144,7 +144,7 @@
      * Logger for Monitor information.
      */
     public static final Logger MONITOR_LOGGER =
-            Logger.getLogger(MONITOR_LOGGER_NAME);
+            System.getLogger(MONITOR_LOGGER_NAME);
 
     /**
      * Logger name for Timer information.
@@ -156,7 +156,7 @@
      * Logger for Timer information.
      */
     public static final Logger TIMER_LOGGER =
-            Logger.getLogger(TIMER_LOGGER_NAME);
+            System.getLogger(TIMER_LOGGER_NAME);
 
     /**
      * Logger name for Event Management information.
@@ -168,7 +168,7 @@
      * Logger for Event Management information.
      */
     public static final Logger NOTIFICATION_LOGGER =
-            Logger.getLogger(NOTIFICATION_LOGGER_NAME);
+            System.getLogger(NOTIFICATION_LOGGER_NAME);
 
     /**
      * Logger name for Relation Service.
@@ -180,7 +180,7 @@
      * Logger for Relation Service.
      */
     public static final Logger RELATION_LOGGER =
-            Logger.getLogger(RELATION_LOGGER_NAME);
+            System.getLogger(RELATION_LOGGER_NAME);
 
     /**
      * Logger name for Model MBean.
@@ -192,7 +192,7 @@
      * Logger for Model MBean.
      */
     public static final Logger MODELMBEAN_LOGGER =
-            Logger.getLogger(MODELMBEAN_LOGGER_NAME);
+            System.getLogger(MODELMBEAN_LOGGER_NAME);
 
     /**
      * Logger name for all other JMX classes.
@@ -204,5 +204,5 @@
      * Logger for all other JMX classes.
      */
     public static final Logger MISC_LOGGER =
-            Logger.getLogger(MISC_LOGGER_NAME);
+            System.getLogger(MISC_LOGGER_NAME);
 }
--- a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
 import java.util.List;
 import java.util.Set;
 import java.util.WeakHashMap;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 // JMX import
 import javax.management.Attribute;
@@ -258,19 +258,16 @@
 
         /* Load the appropriate class. */
         if (withDefaultLoaderRepository) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-                MBEANSERVER_LOGGER.logp(Level.FINER,
-                        DefaultMBeanServerInterceptor.class.getName(),
-                        "createMBean",
+            if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+                MBEANSERVER_LOGGER.log(Level.TRACE,
                         "ClassName = " + className + ", ObjectName = " + name);
             }
             theClass =
                 instantiator.findClassWithDefaultLoaderRepository(className);
         } else if (loaderName == null) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-                MBEANSERVER_LOGGER.logp(Level.FINER,
-                        DefaultMBeanServerInterceptor.class.getName(),
-                        "createMBean", "ClassName = " + className +
+            if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+                MBEANSERVER_LOGGER.log(Level.TRACE,
+                        "ClassName = " + className +
                         ", ObjectName = " + name + ", Loader name = null");
             }
 
@@ -279,10 +276,9 @@
         } else {
             loaderName = nonDefaultDomain(loaderName);
 
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-                MBEANSERVER_LOGGER.logp(Level.FINER,
-                        DefaultMBeanServerInterceptor.class.getName(),
-                        "createMBean", "ClassName = " + className +
+            if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+                MBEANSERVER_LOGGER.log(Level.TRACE,
+                        "ClassName = " + className +
                         ", ObjectName = " + name +
                         ", Loader name = " + loaderName);
             }
@@ -633,10 +629,8 @@
 
         name = nonDefaultDomain(name);
 
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "getAttribute",
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
                     "Attribute = " + attribute + ", ObjectName = " + name);
         }
 
@@ -670,10 +664,8 @@
 
         name = nonDefaultDomain(name);
 
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "getAttributes", "ObjectName = " + name);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name);
         }
 
         final DynamicMBean instance = getMBean(name);
@@ -732,10 +724,8 @@
 
         name = nonDefaultDomain(name);
 
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "setAttribute", "ObjectName = " + name +
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name +
                     ", Attribute = " + attribute.getName());
         }
 
@@ -910,10 +900,9 @@
 
         name = nonDefaultDomain(name);
 
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "registerMBean", "ObjectName = " + name);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
+                    "ObjectName = " + name);
         }
 
         ObjectName logicalName = preRegister(mbean, server, name);
@@ -1023,14 +1012,14 @@
             if (mbean instanceof MBeanRegistration)
                 ((MBeanRegistration) mbean).postRegister(registrationDone);
         } catch (RuntimeException e) {
-            MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
+            MBEANSERVER_LOGGER.log(Level.DEBUG, "While registering MBean ["+logicalName+
                     "]: " + "Exception thrown by postRegister: " +
                     "rethrowing <"+e+">, but keeping the MBean registered");
             throw new RuntimeMBeanException(e,
                       "RuntimeException thrown in postRegister method: "+
                       "rethrowing <"+e+">, but keeping the MBean registered");
         } catch (Error er) {
-            MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
+            MBEANSERVER_LOGGER.log(Level.DEBUG, "While registering MBean ["+logicalName+
                     "]: " + "Error thrown by postRegister: " +
                     "rethrowing <"+er+">, but keeping the MBean registered");
             throw new RuntimeErrorException(er,
@@ -1053,7 +1042,7 @@
         try {
             moi.postDeregister();
         } catch (RuntimeException e) {
-            MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
+            MBEANSERVER_LOGGER.log(Level.DEBUG, "While unregistering MBean ["+mbean+
                     "]: " + "Exception thrown by postDeregister: " +
                     "rethrowing <"+e+">, although the MBean is succesfully " +
                     "unregistered");
@@ -1062,7 +1051,7 @@
                       "rethrowing <"+e+
                       ">, although the MBean is sucessfully unregistered");
         } catch (Error er) {
-            MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
+            MBEANSERVER_LOGGER.log(Level.DEBUG, "While unregistering MBean ["+mbean+
                     "]: " + "Error thrown by postDeregister: " +
                     "rethrowing <"+er+">, although the MBean is succesfully " +
                     "unregistered");
@@ -1087,10 +1076,9 @@
         }
         DynamicMBean obj = repository.retrieve(name);
         if (obj == null) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-                MBEANSERVER_LOGGER.logp(Level.FINER,
-                        DefaultMBeanServerInterceptor.class.getName(),
-                        "getMBean", name + " : Found no object");
+            if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+                MBEANSERVER_LOGGER.log(Level.TRACE,
+                        name + " : Found no object");
             }
             throw new InstanceNotFoundException(name.toString());
         }
@@ -1176,10 +1164,8 @@
 
         // ------------------------------
         // ------------------------------
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "addNotificationListener", "ObjectName = " + name);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name);
         }
 
         DynamicMBean instance = getMBean(name);
@@ -1226,10 +1212,8 @@
         // ----------------
         // Add a listener on an MBean
         // ----------------
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "addNotificationListener",
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
                     "ObjectName = " + name + ", Listener = " + listener);
         }
         server.addNotificationListener(name,(NotificationListener) resource,
@@ -1255,10 +1239,8 @@
             throws InstanceNotFoundException, ListenerNotFoundException {
         NotificationListener instance = getListener(listener);
 
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "removeNotificationListener",
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
                     "ObjectName = " + name + ", Listener = " + listener);
         }
         server.removeNotificationListener(name, instance);
@@ -1272,10 +1254,8 @@
 
         NotificationListener instance = getListener(listener);
 
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "removeNotificationListener",
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
                     "ObjectName = " + name + ", Listener = " + listener);
         }
         server.removeNotificationListener(name, instance, filter, handback);
@@ -1313,10 +1293,8 @@
                                             boolean removeAll)
             throws InstanceNotFoundException, ListenerNotFoundException {
 
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "removeNotificationListener", "ObjectName = " + name);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name);
         }
 
         DynamicMBean instance = getMBean(name);
@@ -1421,10 +1399,9 @@
             return classNameClass.isAssignableFrom(resourceClass);
         } catch (Exception x) {
             /* Could be SecurityException or ClassNotFoundException */
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
-                MBEANSERVER_LOGGER.logp(Level.FINEST,
-                        DefaultMBeanServerInterceptor.class.getName(),
-                        "isInstanceOf", "Exception calling isInstanceOf", x);
+            if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) {
+                MBEANSERVER_LOGGER.log(Level.DEBUG,
+                        "Exception calling isInstanceOf", x);
             }
             return false;
         }
@@ -1489,10 +1466,8 @@
         MBeanServerNotification notif = new MBeanServerNotification(
             NotifType,MBeanServerDelegate.DELEGATE_NAME,0,name);
 
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "sendNotification", NotifType + " " + name);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE, NotifType + " " + name);
         }
 
         delegate.sendNotification(notif);
@@ -1594,10 +1569,8 @@
         try {
             return getClassName(mbean);
         } catch (Exception e) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
-                MBEANSERVER_LOGGER.logp(Level.FINEST,
-                        DefaultMBeanServerInterceptor.class.getName(),
-                        "safeGetClassName",
+            if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) {
+                MBEANSERVER_LOGGER.log(Level.DEBUG,
                         "Exception getting MBean class name", e);
             }
             return null;
@@ -1885,10 +1858,9 @@
         // ---------------------
         // Send create event
         // ---------------------
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "addObject", "Send create notification of object " +
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
+                    "Send create notification of object " +
                     logicalName.getCanonicalName());
         }
 
@@ -1926,10 +1898,9 @@
         // ---------------------
         // Send deletion event
         // ---------------------
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    DefaultMBeanServerInterceptor.class.getName(),
-                    "unregisterMBean", "Send delete notification of object " +
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
+                    "Send delete notification of object " +
                     logicalName.getCanonicalName());
         }
 
--- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import javax.management.MBeanPermission;
 
 import javax.management.ObjectName;
@@ -148,10 +148,9 @@
     // from javax.management.loading.DefaultLoaderRepository
     public final Class<?> loadClassWithout(ClassLoader without, String className)
             throws ClassNotFoundException {
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    ClassLoaderRepositorySupport.class.getName(),
-                    "loadClassWithout", className + " without " + without);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
+                    className + " without " + without);
         }
 
         // without is null => just behave as loadClass
@@ -172,10 +171,9 @@
 
     public final Class<?> loadClassBefore(ClassLoader stop, String className)
             throws ClassNotFoundException {
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    ClassLoaderRepositorySupport.class.getName(),
-                    "loadClassBefore", className + " before " + stop);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
+                    className + " before " + stop);
         }
 
         if (stop == null)
@@ -206,10 +204,8 @@
                     continue;
                 if (cl == stop)
                     break;
-                if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-                    MBEANSERVER_LOGGER.logp(Level.FINER,
-                            ClassLoaderRepositorySupport.class.getName(),
-                            "loadClass", "Trying loader = " + cl);
+                if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+                    MBEANSERVER_LOGGER.log(Level.TRACE, "Trying loader = " + cl);
                 }
                 /* We used to have a special case for "instanceof
                    MLet" here, where we invoked the method
@@ -239,10 +235,9 @@
         //
         List<ClassLoader> excluded = search.get(className);
         if ((excluded!= null) && (excluded.contains(aloader))) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-                MBEANSERVER_LOGGER.logp(Level.FINER,
-                        ClassLoaderRepositorySupport.class.getName(),
-                        "startValidSearch", "Already requested loader = " +
+            if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+                MBEANSERVER_LOGGER.log(Level.TRACE,
+                        "Already requested loader = " +
                         aloader + " class = " + className);
             }
             throw new ClassNotFoundException(className);
@@ -255,10 +250,8 @@
             search.put(className, excluded);
         }
         excluded.add(aloader);
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    ClassLoaderRepositorySupport.class.getName(),
-                    "startValidSearch",
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE,
                     "loader = " + aloader + " class = " + className);
         }
     }
@@ -271,10 +264,8 @@
         List<ClassLoader> excluded = search.get(className);
         if (excluded != null) {
             excluded.remove(aloader);
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-                MBEANSERVER_LOGGER.logp(Level.FINER,
-                        ClassLoaderRepositorySupport.class.getName(),
-                        "stopValidSearch",
+            if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+                MBEANSERVER_LOGGER.log(Level.TRACE,
                         "loader = " + aloader + " class = " + className);
             }
         }
--- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
 import java.security.PrivilegedExceptionAction;
 import java.util.List;
 import java.util.Set;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.Attribute;
 import javax.management.AttributeList;
@@ -1229,16 +1229,14 @@
                 }
             });
         } catch (SecurityException e) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
-                MBEANSERVER_LOGGER.logp(Level.FINEST,
-                        JmxMBeanServer.class.getName(), "initialize",
+            if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) {
+                MBEANSERVER_LOGGER.log(Level.DEBUG,
                         "Unexpected security exception occurred", e);
             }
             throw e;
         } catch (Exception e) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
-                MBEANSERVER_LOGGER.logp(Level.FINEST,
-                        JmxMBeanServer.class.getName(), "initialize",
+            if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) {
+                MBEANSERVER_LOGGER.log(Level.DEBUG,
                         "Unexpected exception occurred", e);
             }
             throw new
--- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
 import java.security.PrivilegedAction;
 import java.security.ProtectionDomain;
 import java.util.Map;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanException;
@@ -186,19 +186,15 @@
                 }
             }
         } catch (ClassNotFoundException e) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
-                MBEANSERVER_LOGGER.logp(Level.FINEST,
-                        MBeanInstantiator.class.getName(),
-                        "findSignatureClasses",
+            if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) {
+                MBEANSERVER_LOGGER.log(Level.DEBUG,
                         "The parameter class could not be found", e);
             }
             throw new ReflectionException(e,
                       "The parameter class could not be found");
         } catch (RuntimeException e) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
-                MBEANSERVER_LOGGER.logp(Level.FINEST,
-                        MBeanInstantiator.class.getName(),
-                        "findSignatureClasses",
+            if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) {
+                MBEANSERVER_LOGGER.log(Level.DEBUG,
                         "Unexpected exception", e);
             }
             throw e;
@@ -696,19 +692,15 @@
                 tab[i] = Class.forName(signature[i], false, aLoader);
             }
         } catch (ClassNotFoundException e) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
-                MBEANSERVER_LOGGER.logp(Level.FINEST,
-                        MBeanInstantiator.class.getName(),
-                        "findSignatureClasses",
+            if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) {
+                MBEANSERVER_LOGGER.log(Level.DEBUG,
                         "The parameter class could not be found", e);
             }
             throw new ReflectionException(e,
                       "The parameter class could not be found");
         } catch (RuntimeException e) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
-                MBEANSERVER_LOGGER.logp(Level.FINEST,
-                        MBeanInstantiator.class.getName(),
-                        "findSignatureClasses",
+            if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) {
+                MBEANSERVER_LOGGER.log(Level.DEBUG,
                         "Unexpected exception", e);
             }
             throw e;
--- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanServerDelegateImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanServerDelegateImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
  */
 package com.sun.jmx.mbeanserver;
 
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.Attribute;
 import javax.management.AttributeList;
@@ -244,10 +244,8 @@
             } catch (Exception x) {
                 // Skip the attribute that couldn't be obtained.
                 //
-                if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
-                    MBEANSERVER_LOGGER.logp(Level.FINEST,
-                            MBeanServerDelegateImpl.class.getName(),
-                            "getAttributes",
+                if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+                    MBEANSERVER_LOGGER.log(Level.TRACE,
                             "Attribute " + attn[i] + " not found");
                 }
             }
--- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import java.util.Map;
 import java.util.Set;
 import javax.management.DynamicMBean;
@@ -264,7 +264,7 @@
             context.unregistered();
         } catch (Exception x) {
             // shouldn't come here...
-            MBEANSERVER_LOGGER.log(Level.FINE,
+            MBEANSERVER_LOGGER.log(Level.DEBUG,
                     "Unexpected exception while unregistering "+name,
                     x);
         }
@@ -385,9 +385,8 @@
             final RegistrationContext context)
         throws InstanceAlreadyExistsException {
 
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(),
-                    "addMBean", "name = " + name);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE, "name = " + name);
         }
 
         // Extract the domain name.
@@ -456,9 +455,8 @@
      *          false otherwise.
      */
     public boolean contains(ObjectName name) {
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(),
-                    "contains", " name = " + name);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE, "name = " + name);
         }
         lock.readLock().lock();
         try {
@@ -478,9 +476,8 @@
      *          null otherwise.
      */
     public DynamicMBean retrieve(ObjectName name) {
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(),
-                    "retrieve", "name = " + name);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE, "name = " + name);
         }
 
         // Calls internal retrieve method to get the named object
@@ -609,9 +606,8 @@
         throws InstanceNotFoundException {
 
         // Debugging stuff
-        if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
-            MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(),
-                    "remove", "name = " + name);
+        if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
+            MBEANSERVER_LOGGER.log(Level.TRACE, "name = " + name);
         }
 
         // Extract domain name.
--- a/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLogger.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLogger.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,222 +25,188 @@
 
 package com.sun.jmx.remote.util;
 
-import java.util.logging.Logger;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
+import java.util.ResourceBundle;
 
-public class ClassLogger {
+public class ClassLogger implements System.Logger {
 
-    private static final boolean ok;
     private final String className;
     private final Logger logger;
 
-    static {
-        /* We attempt to work even if we are running in J2SE 1.3, where
-           there is no java.util.logging.  The technique we use here is
-           not strictly portable, but it does work with Sun's J2SE 1.3
-           at least.  This is just a best effort: the Right Thing is for
-           people to use at least J2SE 1.4.  */
-        boolean loaded = false;
-        try {
-            Class<?> c = java.util.logging.Logger.class;
-            loaded = true;
-        } catch (Error e) {
-            // OK.
-            // java.util.logger package is not available in this jvm.
-        }
-        ok = loaded;
-    }
-
     public ClassLogger(String subsystem, String className) {
-        if (ok)
-            logger = Logger.getLogger(subsystem);
-        else
-            logger = null;
+        logger = System.getLogger(subsystem);
         this.className = className;
     }
 
     public final boolean traceOn() {
-        return finerOn();
+        return logger.isLoggable(Level.TRACE);
     }
 
     public final boolean debugOn() {
-        return finestOn();
+        return logger.isLoggable(Level.DEBUG);
     }
 
     public final boolean warningOn() {
-        return ok && logger.isLoggable(java.util.logging.Level.WARNING);
+        return logger.isLoggable(Level.WARNING);
     }
 
     public final boolean infoOn() {
-        return ok && logger.isLoggable(java.util.logging.Level.INFO);
+        return logger.isLoggable(Level.INFO);
     }
 
     public final boolean configOn() {
-        return ok && logger.isLoggable(java.util.logging.Level.CONFIG);
+        return logger.isLoggable(Level.DEBUG);
     }
 
     public final boolean fineOn() {
-        return ok && logger.isLoggable(java.util.logging.Level.FINE);
+        return logger.isLoggable(Level.DEBUG);
     }
 
     public final boolean finerOn() {
-        return ok && logger.isLoggable(java.util.logging.Level.FINER);
+        return logger.isLoggable(Level.TRACE);
     }
 
     public final boolean finestOn() {
-        return ok && logger.isLoggable(java.util.logging.Level.FINEST);
+        return logger.isLoggable(Level.TRACE);
     }
 
     public final void debug(String func, String msg) {
-        finest(func,msg);
+        logger.log(Level.DEBUG, msg);
     }
 
     public final void debug(String func, Throwable t) {
-        finest(func,t);
+        logger.log(Level.DEBUG, className + "::" + func, t);
     }
 
     public final void debug(String func, String msg, Throwable t) {
-        finest(func,msg,t);
+        logger.log(Level.DEBUG, msg, t);
     }
 
     public final void trace(String func, String msg) {
-        finer(func,msg);
+        logger.log(Level.TRACE, msg);
     }
 
     public final void trace(String func, Throwable t) {
-        finer(func,t);
+        logger.log(Level.TRACE, className + "::" + func, t);
     }
 
     public final void trace(String func, String msg, Throwable t) {
-        finer(func,msg,t);
+        logger.log(Level.TRACE, msg, t);
     }
 
     public final void error(String func, String msg) {
-        severe(func,msg);
+        logger.log(Level.ERROR, msg);
     }
 
     public final void error(String func, Throwable t) {
-        severe(func,t);
+        logger.log(Level.ERROR, className + "::" + func, t);
     }
 
     public final void error(String func, String msg, Throwable t) {
-        severe(func,msg,t);
+        logger.log(Level.ERROR, msg, t);
     }
 
     public final void finest(String func, String msg) {
-        if (ok)
-            logger.logp(java.util.logging.Level.FINEST, className, func, msg);
+        logger.log(Level.TRACE, msg);
     }
 
     public final void finest(String func, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.FINEST, className, func,
-                        t.toString(), t);
+        logger.log(Level.TRACE, className + "::" + func, t);
     }
 
     public final void finest(String func, String msg, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.FINEST, className, func, msg,
-                        t);
+        logger.log(Level.TRACE, msg, t);
     }
 
     public final void finer(String func, String msg) {
-        if (ok)
-            logger.logp(java.util.logging.Level.FINER, className, func, msg);
+        logger.log(Level.TRACE, msg);
     }
 
     public final void finer(String func, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.FINER, className, func,
-                        t.toString(), t);
+        logger.log(Level.TRACE, className + "::" + func, t);
     }
 
     public final void finer(String func, String msg, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.FINER, className, func, msg,t);
+        logger.log(Level.DEBUG, msg, t);
     }
 
     public final void fine(String func, String msg) {
-        if (ok)
-            logger.logp(java.util.logging.Level.FINE, className, func, msg);
+        logger.log(Level.DEBUG, msg);
     }
 
     public final void fine(String func, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.FINE, className, func,
-                        t.toString(), t);
+        logger.log(Level.DEBUG, className + "::" + func, t);
     }
 
     public final void fine(String func, String msg, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.FINE, className, func, msg,
-                        t);
+        logger.log(Level.DEBUG, msg, t);
     }
 
     public final void config(String func, String msg) {
-        if (ok)
-            logger.logp(java.util.logging.Level.CONFIG, className, func, msg);
+        logger.log(Level.DEBUG, msg);
     }
 
     public final void config(String func, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.CONFIG, className, func,
-                        t.toString(), t);
+        logger.log(Level.DEBUG, className + "::" + func, t);
     }
 
     public final void config(String func, String msg, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.CONFIG, className, func, msg,
-                        t);
+        logger.log(Level.DEBUG, msg, t);
     }
 
     public final void info(String func, String msg) {
-        if (ok)
-            logger.logp(java.util.logging.Level.INFO, className, func, msg);
+        logger.log(Level.INFO, msg);
     }
 
     public final void info(String func, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.INFO, className, func,
-                        t.toString(), t);
+        logger.log(Level.INFO, className + "::" + func, t);
     }
 
     public final void info(String func, String msg, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.INFO, className, func, msg,
-                        t);
+        logger.log(Level.INFO, msg, t);
     }
 
     public final void warning(String func, String msg) {
-        if (ok)
-            logger.logp(java.util.logging.Level.WARNING, className, func, msg);
+        logger.log(Level.WARNING, msg);
     }
 
     public final void warning(String func, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.WARNING, className, func,
-                        t.toString(), t);
+        logger.log(Level.WARNING, className + "::" + func, t);
     }
 
     public final void warning(String func, String msg, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.WARNING, className, func, msg,
-                        t);
+        logger.log(Level.WARNING, msg, t);
     }
 
     public final void severe(String func, String msg) {
-        if (ok)
-            logger.logp(java.util.logging.Level.SEVERE, className, func, msg);
+        logger.log(Level.ERROR, msg);
     }
 
     public final void severe(String func, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.SEVERE, className, func,
-                        t.toString(), t);
+        logger.log(Level.ERROR, className + "::" + func, t);
     }
 
     public final void severe(String func, String msg, Throwable t) {
-        if (ok)
-            logger.logp(java.util.logging.Level.SEVERE, className, func, msg,
-                        t);
+        logger.log(Level.ERROR, msg, t);
+    }
+
+    public final String getName() {
+        return logger.getName();
+    }
+
+    public final boolean isLoggable(Level level) {
+        return logger.isLoggable(level);
     }
+
+    public final void log(Level level, ResourceBundle bundle, String msg,
+            Throwable thrown) {
+        logger.log(level, bundle, msg, thrown);
+    }
+
+    public final void log(Level level, ResourceBundle bundle, String format,
+                    Object... params) {
+        logger.log(level, bundle, format, params);
+    }
+
 }
--- a/jdk/src/java.management/share/classes/javax/management/MBeanServerDelegate.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/MBeanServerDelegate.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 package javax.management;
 
+import java.lang.System.Logger.Level;
 import com.sun.jmx.defaults.JmxProperties;
 import com.sun.jmx.defaults.ServiceName;
 import com.sun.jmx.mbeanserver.Util;
@@ -84,7 +85,8 @@
             try {
                 localHost = java.net.InetAddress.getLocalHost().getHostName();
             } catch (java.net.UnknownHostException e) {
-                JmxProperties.MISC_LOGGER.finest("Can't get local host name, " +
+                JmxProperties.MISC_LOGGER.log(Level.TRACE,
+                        "Can't get local host name, " +
                         "using \"localhost\" instead. Cause is: "+e);
                 localHost = "localhost";
             }
--- a/jdk/src/java.management/share/classes/javax/management/MBeanServerFactory.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/MBeanServerFactory.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 import java.security.AccessController;
 import java.security.Permission;
 import java.util.ArrayList;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import javax.management.loading.ClassLoaderRepository;
 import sun.reflect.misc.ReflectUtil;
 
@@ -399,7 +399,7 @@
             return (String) mbs.getAttribute(MBeanServerDelegate.DELEGATE_NAME,
                     "MBeanServerId");
         } catch (JMException e) {
-            JmxProperties.MISC_LOGGER.finest(
+            JmxProperties.MISC_LOGGER.log(Level.TRACE,
                     "Ignoring exception while getting MBeanServerId: "+e);
             return null;
         }
@@ -421,9 +421,7 @@
     private static synchronized void removeMBeanServer(MBeanServer mbs) {
         boolean removed = mBeanServerList.remove(mbs);
         if (!removed) {
-            MBEANSERVER_LOGGER.logp(Level.FINER,
-                    MBeanServerFactory.class.getName(),
-                    "removeMBeanServer(MBeanServer)",
+            MBEANSERVER_LOGGER.log(Level.TRACE,
                     "MBeanServer was not in list!");
             throw new IllegalArgumentException("MBeanServer was not in list!");
         }
@@ -504,15 +502,12 @@
                 throw new JMRuntimeException(msg, x);
             }
         } catch (RuntimeException x) {
-            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
+            if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) {
                 StringBuilder strb = new StringBuilder()
                 .append("Failed to instantiate MBeanServerBuilder: ").append(x)
                 .append("\n\t\tCheck the value of the ")
                 .append(JMX_INITIAL_BUILDER).append(" property.");
-                MBEANSERVER_LOGGER.logp(Level.FINEST,
-                        MBeanServerFactory.class.getName(),
-                        "checkMBeanServerBuilder",
-                        strb.toString());
+                MBEANSERVER_LOGGER.log(Level.DEBUG, strb::toString);
             }
             throw x;
         }
--- a/jdk/src/java.management/share/classes/javax/management/StandardMBean.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/StandardMBean.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.WeakHashMap;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import javax.management.openmbean.OpenMBeanAttributeInfo;
 import javax.management.openmbean.OpenMBeanAttributeInfoSupport;
 import javax.management.openmbean.OpenMBeanConstructorInfo;
@@ -432,16 +432,14 @@
             final MBeanInfo cached = getCachedMBeanInfo();
             if (cached != null) return cached;
         } catch (RuntimeException x) {
-            if (MISC_LOGGER.isLoggable(Level.FINEST)) {
-                MISC_LOGGER.logp(Level.FINEST,
-                        MBeanServerFactory.class.getName(), "getMBeanInfo",
+            if (MISC_LOGGER.isLoggable(Level.DEBUG)) {
+                MISC_LOGGER.log(Level.DEBUG,
                         "Failed to get cached MBeanInfo", x);
             }
         }
 
-        if (MISC_LOGGER.isLoggable(Level.FINER)) {
-            MISC_LOGGER.logp(Level.FINER,
-                    MBeanServerFactory.class.getName(), "getMBeanInfo",
+        if (MISC_LOGGER.isLoggable(Level.TRACE)) {
+            MISC_LOGGER.log(Level.TRACE,
                     "Building MBeanInfo for " +
                     getImplementationClass().getName());
         }
@@ -465,9 +463,8 @@
         try {
             cacheMBeanInfo(nmbi);
         } catch (RuntimeException x) {
-            if (MISC_LOGGER.isLoggable(Level.FINEST)) {
-                MISC_LOGGER.logp(Level.FINEST,
-                        MBeanServerFactory.class.getName(), "getMBeanInfo",
+            if (MISC_LOGGER.isLoggable(Level.DEBUG)) {
+                MISC_LOGGER.log(Level.DEBUG,
                         "Failed to cache MBeanInfo", x);
             }
         }
--- a/jdk/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
 import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
 import java.util.Iterator;
 import java.util.List;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
 
@@ -71,9 +71,7 @@
      */
     public static Class<?> loadClass(String className)
         throws ClassNotFoundException {
-        MBEANSERVER_LOGGER.logp(Level.FINEST,
-                DefaultLoaderRepository.class.getName(),
-                "loadClass", className);
+        MBEANSERVER_LOGGER.log(Level.TRACE, className);
         return load(null, className);
     }
 
@@ -96,9 +94,7 @@
     public static Class<?> loadClassWithout(ClassLoader loader,
                                          String className)
         throws ClassNotFoundException {
-        MBEANSERVER_LOGGER.logp(Level.FINEST,
-                DefaultLoaderRepository.class.getName(),
-                "loadClassWithout", className);
+        MBEANSERVER_LOGGER.log(Level.TRACE, className);
         return load(loader, className);
     }
 
--- a/jdk/src/java.management/share/classes/javax/management/loading/MLet.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/loading/MLet.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -412,9 +412,8 @@
              if (!Arrays.asList(getURLs()).contains(ur))
                  super.addURL(ur);
          } catch (MalformedURLException e) {
-             if (MLET_LOGGER.isLoggable(Level.FINEST)) {
-                 MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                         "addUrl", "Malformed URL: " + url, e);
+             if (MLET_LOGGER.isLoggable(Level.DEBUG)) {
+                 MLET_LOGGER.log(Level.DEBUG, "Malformed URL: " + url, e);
              }
              throw new
                  ServiceNotFoundException("The specified URL is malformed");
@@ -481,23 +480,19 @@
      public Set<Object> getMBeansFromURL(String url)
              throws ServiceNotFoundException  {
 
-         String mth = "getMBeansFromURL";
-
          if (server == null) {
              throw new IllegalStateException("This MLet MBean is not " +
                                              "registered with an MBeanServer.");
          }
          // Parse arguments
          if (url == null) {
-             MLET_LOGGER.logp(Level.FINER, MLet.class.getName(),
-                     mth, "URL is null");
+             MLET_LOGGER.log(Level.TRACE, "URL is null");
              throw new ServiceNotFoundException("The specified URL is null");
          } else {
              url = url.replace(File.separatorChar,'/');
          }
-         if (MLET_LOGGER.isLoggable(Level.FINER)) {
-             MLET_LOGGER.logp(Level.FINER, MLet.class.getName(),
-                     mth, "<URL = " + url + ">");
+         if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+             MLET_LOGGER.log(Level.TRACE, "<URL = " + url + ">");
          }
 
          // Parse URL
@@ -508,7 +503,7 @@
              final String msg =
                  "Problems while parsing URL [" + url +
                  "], got exception [" + e.toString() + "]";
-             MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, msg);
+             MLET_LOGGER.log(Level.TRACE, msg);
              throw EnvHelp.initCause(new ServiceNotFoundException(msg), e);
          }
 
@@ -516,7 +511,7 @@
          if (mletList.size() == 0) {
              final String msg =
                  "File " + url + " not found or MLET tag not defined in file";
-             MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, msg);
+             MLET_LOGGER.log(Level.TRACE, msg);
              throw new ServiceNotFoundException(msg);
          }
 
@@ -538,7 +533,7 @@
              URL documentBase = elmt.getDocumentBase();
 
              // Display debug information
-             if (MLET_LOGGER.isLoggable(Level.FINER)) {
+             if (MLET_LOGGER.isLoggable(Level.TRACE)) {
                  final StringBuilder strb = new StringBuilder()
                  .append("\n\tMLET TAG     = ").append(elmt.getAttributes())
                  .append("\n\tCODEBASE     = ").append(codebase)
@@ -548,16 +543,15 @@
                  .append("\n\tNAME         = ").append(name)
                  .append("\n\tVERSION      = ").append(version)
                  .append("\n\tDOCUMENT URL = ").append(documentBase);
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(),
-                         mth, strb.toString());
+                 MLET_LOGGER.log(Level.TRACE, strb::toString);
              }
 
              // Load classes from JAR files
              StringTokenizer st = new StringTokenizer(jarFiles, ",", false);
              while (st.hasMoreTokens()) {
                  String tok = st.nextToken().trim();
-                 if (MLET_LOGGER.isLoggable(Level.FINER)) {
-                     MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+                 if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+                     MLET_LOGGER.log(Level.TRACE,
                              "Load archive for codebase <" + codebase +
                              ">, file <" + tok + ">");
                  }
@@ -570,8 +564,8 @@
                  try {
                      codebase = check(version, codebase, tok, elmt);
                  } catch (Exception ex) {
-                     MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                             mth, "Got unexpected exception", ex);
+                     MLET_LOGGER.log(Level.DEBUG,
+                             "Got unexpected exception", ex);
                      mbeans.add(ex);
                      continue;
                  }
@@ -599,7 +593,7 @@
                  final String msg =
                      "CODE and OBJECT parameters cannot be specified at the " +
                      "same time in tag MLET";
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, msg);
+                 MLET_LOGGER.log(Level.TRACE, msg);
                  mbeans.add(new Error(msg));
                  continue;
              }
@@ -607,7 +601,7 @@
                  final String msg =
                      "Either CODE or OBJECT parameter must be specified in " +
                      "tag MLET";
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, msg);
+                 MLET_LOGGER.log(Level.TRACE, msg);
                  mbeans.add(new Error(msg));
                  continue;
              }
@@ -635,7 +629,7 @@
                          Object[] parms = objectPars.toArray();
                          String[] signature = new String[signat.size()];
                          signat.toArray(signature);
-                         if (MLET_LOGGER.isLoggable(Level.FINEST)) {
+                         if (MLET_LOGGER.isLoggable(Level.TRACE)) {
                              final StringBuilder strb = new StringBuilder();
                              for (int i = 0; i < signature.length; i++) {
                                  strb.append("\n\tSignature     = ")
@@ -643,9 +637,7 @@
                                  .append("\t\nParams        = ")
                                  .append(parms[i]);
                              }
-                             MLET_LOGGER.logp(Level.FINEST,
-                                     MLet.class.getName(),
-                                     mth, strb.toString());
+                             MLET_LOGGER.log(Level.TRACE, strb::toString);
                          }
                          if (name == null) {
                              objInst =
@@ -668,53 +660,46 @@
                      objInst = new ObjectInstance(name, o.getClass().getName());
                  }
              } catch (ReflectionException  ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
-                         "ReflectionException", ex);
+                 MLET_LOGGER.log(Level.TRACE, "ReflectionException", ex);
                  mbeans.add(ex);
                  continue;
              } catch (InstanceAlreadyExistsException  ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+                 MLET_LOGGER.log(Level.TRACE,
                          "InstanceAlreadyExistsException", ex);
                  mbeans.add(ex);
                  continue;
              } catch (MBeanRegistrationException ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
-                         "MBeanRegistrationException", ex);
+                 MLET_LOGGER.log(Level.TRACE, "MBeanRegistrationException", ex);
                  mbeans.add(ex);
                  continue;
              } catch (MBeanException  ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
-                         "MBeanException", ex);
+                 MLET_LOGGER.log(Level.TRACE, "MBeanException", ex);
                  mbeans.add(ex);
                  continue;
              } catch (NotCompliantMBeanException  ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+                 MLET_LOGGER.log(Level.TRACE,
                          "NotCompliantMBeanException", ex);
                  mbeans.add(ex);
                  continue;
              } catch (InstanceNotFoundException   ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+                 MLET_LOGGER.log(Level.TRACE,
                          "InstanceNotFoundException", ex);
                  mbeans.add(ex);
                  continue;
              } catch (IOException ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
-                         "IOException", ex);
+                 MLET_LOGGER.log(Level.TRACE, "IOException", ex);
                  mbeans.add(ex);
                  continue;
              } catch (SecurityException ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
-                         "SecurityException", ex);
+                 MLET_LOGGER.log(Level.TRACE, "SecurityException", ex);
                  mbeans.add(ex);
                  continue;
              } catch (Exception ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
-                         "Exception", ex);
+                 MLET_LOGGER.log(Level.TRACE, "Exception", ex);
                  mbeans.add(ex);
                  continue;
              } catch (Error ex) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
-                         "Error", ex);
+                 MLET_LOGGER.log(Level.TRACE, "Error", ex);
                  mbeans.add(ex);
                  continue;
              }
@@ -937,20 +922,18 @@
      Class<?> findClass(String name, ClassLoaderRepository clr)
          throws ClassNotFoundException {
          Class<?> c = null;
-         MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), "findClass", name);
+         MLET_LOGGER.log(Level.TRACE, name);
          // Try looking in the JAR:
          try {
              c = super.findClass(name);
-             if (MLET_LOGGER.isLoggable(Level.FINER)) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(),
-                         "findClass",
+             if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+                 MLET_LOGGER.log(Level.TRACE,
                          "Class " + name + " loaded through MLet classloader");
              }
          } catch (ClassNotFoundException e) {
              // Drop through
-             if (MLET_LOGGER.isLoggable(Level.FINEST)) {
-                 MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                         "findClass",
+             if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+                 MLET_LOGGER.log(Level.TRACE,
                          "Class " + name + " not found locally");
              }
          }
@@ -959,32 +942,28 @@
              // Try the classloader repository:
              //
              try {
-                 if (MLET_LOGGER.isLoggable(Level.FINEST)) {
-                     MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                             "findClass",
+                 if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+                     MLET_LOGGER.log(Level.TRACE,
                              "Class " + name + " : looking in CLR");
                  }
                  c = clr.loadClassBefore(this, name);
                  // The loadClassBefore method never returns null.
                  // If the class is not found we get an exception.
-                 if (MLET_LOGGER.isLoggable(Level.FINER)) {
-                     MLET_LOGGER.logp(Level.FINER, MLet.class.getName(),
-                             "findClass",
+                 if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+                     MLET_LOGGER.log(Level.TRACE,
                              "Class " + name + " loaded through " +
                              "the default classloader repository");
                  }
              } catch (ClassNotFoundException e) {
                  // Drop through
-                 if (MLET_LOGGER.isLoggable(Level.FINEST)) {
-                     MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                             "findClass",
+                 if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+                     MLET_LOGGER.log(Level.TRACE,
                              "Class " + name + " not found in CLR");
                  }
              }
          }
          if (c == null) {
-             MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                     "findClass", "Failed to load class " + name);
+             MLET_LOGGER.log(Level.TRACE, "Failed to load class " + name);
              throw new ClassNotFoundException(name);
          }
          return c;
@@ -1041,8 +1020,8 @@
          //
          // See if the native library is accessible as a resource through the JAR file.
          //
-         if (MLET_LOGGER.isLoggable(Level.FINER)) {
-             MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+         if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+             MLET_LOGGER.log(Level.TRACE,
                      "Search " + libname + " in all JAR files");
          }
 
@@ -1051,14 +1030,14 @@
          // for "foo" on Solaris SPARC 5.7 we try to load "libfoo.so"
          // from the JAR file.
          //
-         if (MLET_LOGGER.isLoggable(Level.FINER)) {
-             MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+         if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+             MLET_LOGGER.log(Level.TRACE,
                      "loadLibraryAsResource(" + nativelibname + ")");
          }
          abs_path = loadLibraryAsResource(nativelibname);
          if (abs_path != null) {
-             if (MLET_LOGGER.isLoggable(Level.FINER)) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+             if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+                 MLET_LOGGER.log(Level.TRACE,
                          nativelibname + " loaded, absolute path = " + abs_path);
              }
              return abs_path;
@@ -1073,15 +1052,15 @@
              removeSpace(System.getProperty("os.arch")) + File.separator +
              removeSpace(System.getProperty("os.version")) + File.separator +
              "lib" + File.separator + nativelibname;
-         if (MLET_LOGGER.isLoggable(Level.FINER)) {
-             MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+         if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+             MLET_LOGGER.log(Level.TRACE,
                      "loadLibraryAsResource(" + nativelibname + ")");
          }
 
          abs_path = loadLibraryAsResource(nativelibname);
          if (abs_path != null) {
-             if (MLET_LOGGER.isLoggable(Level.FINER)) {
-                 MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+             if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+                 MLET_LOGGER.log(Level.TRACE,
                          nativelibname + " loaded, absolute path = " + abs_path);
              }
              return abs_path;
@@ -1091,10 +1070,10 @@
          // All paths exhausted, library not found in JAR file.
          //
 
-         if (MLET_LOGGER.isLoggable(Level.FINER)) {
-             MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+         if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+             MLET_LOGGER.log(Level.TRACE,
                      libname + " not found in any JAR file");
-             MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth,
+             MLET_LOGGER.log(Level.TRACE,
                      "Search " + libname + " along the path " +
                      "specified as the java.library.path property");
          }
@@ -1127,8 +1106,8 @@
              if (tmpDirFile == null) return null;
              return tmpDirFile.getAbsolutePath();
          } catch (Exception x) {
-             MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                     "getTmpDir", "Failed to determine system temporary dir");
+             MLET_LOGGER.log(Level.DEBUG,
+                     "Failed to determine system temporary dir");
              return null;
          } finally {
              // Cleanup ...
@@ -1136,12 +1115,12 @@
                  try {
                      boolean deleted = tmpFile.delete();
                      if (!deleted) {
-                         MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                                 "getTmpDir", "Failed to delete temp file");
+                         MLET_LOGGER.log(Level.DEBUG,
+                                 "Failed to delete temp file");
                      }
                  } catch (Exception x) {
-                     MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                             "getTmpDir", "Failed to delete temporary file", x);
+                     MLET_LOGGER.log(Level.DEBUG,
+                             "Failed to delete temporary file", x);
                  }
              }
         }
@@ -1183,8 +1162,7 @@
                  }
              }
          } catch (Exception e) {
-             MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                     "loadLibraryAsResource",
+             MLET_LOGGER.log(Level.DEBUG,
                      "Failed to load library : " + libname, e);
              return null;
          }
@@ -1248,9 +1226,8 @@
         if (filename != null) {
             filename = filename.replace(File.separatorChar,'/');
         }
-        if (MLET_LOGGER.isLoggable(Level.FINER)) {
-            MLET_LOGGER.logp(Level.FINER, MLet.class.getName(),
-                    "loadSerializedObject", codebase.toString() + filename);
+        if (MLET_LOGGER.isLoggable(Level.TRACE)) {
+            MLET_LOGGER.log(Level.TRACE, codebase.toString() + filename);
         }
         InputStream is = getResourceAsStream(filename);
         if (is != null) {
@@ -1260,24 +1237,21 @@
                 ois.close();
                 return serObject;
             } catch (IOException e) {
-                if (MLET_LOGGER.isLoggable(Level.FINEST)) {
-                    MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                            "loadSerializedObject",
+                if (MLET_LOGGER.isLoggable(Level.DEBUG)) {
+                    MLET_LOGGER.log(Level.DEBUG,
                             "Exception while deserializing " + filename, e);
                 }
                 throw e;
             } catch (ClassNotFoundException e) {
-                if (MLET_LOGGER.isLoggable(Level.FINEST)) {
-                    MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                            "loadSerializedObject",
+                if (MLET_LOGGER.isLoggable(Level.DEBUG)) {
+                    MLET_LOGGER.log(Level.DEBUG,
                             "Exception while deserializing " + filename, e);
                 }
                 throw e;
             }
         } else {
-            if (MLET_LOGGER.isLoggable(Level.FINEST)) {
-                MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                        "loadSerializedObject", "Error: File " + filename +
+            if (MLET_LOGGER.isLoggable(Level.DEBUG)) {
+                MLET_LOGGER.log(Level.DEBUG, "Error: File " + filename +
                         " containing serialized object not found");
             }
             throw new Error("File " + filename + " containing serialized object not found");
@@ -1300,8 +1274,7 @@
                 return(cons.newInstance(oo));
 
             } catch (Exception  e) {
-                MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                        "constructParameter", "Got unexpected exception", e);
+                MLET_LOGGER.log(Level.DEBUG, "Got unexpected exception", e);
             }
         }
         if (type.compareTo("java.lang.Boolean") == 0)
--- a/jdk/src/java.management/share/classes/javax/management/loading/MLetParser.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/loading/MLetParser.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 /**
  * This class is used for parsing URLs.
@@ -153,7 +153,6 @@
      * Scan an html file for {@literal <mlet>} tags.
      */
     public List<MLetContent> parse(URL url) throws IOException {
-        String mth = "parse";
         // Warning Messages
         String requiresTypeWarning = "<arg type=... value=...> tag requires type parameter.";
         String requiresValueWarning = "<arg type=... value=...> tag requires value parameter.";
@@ -204,33 +203,25 @@
                         Map<String,String> t = scanTag(in);
                         String att = t.get("type");
                         if (att == null) {
-                            MLET_LOGGER.logp(Level.FINER,
-                                    MLetParser.class.getName(),
-                                    mth, requiresTypeWarning);
+                            MLET_LOGGER.log(Level.TRACE, requiresTypeWarning);
                             throw new IOException(requiresTypeWarning);
                         } else {
                             if (atts != null) {
                                 types.add(att);
                             } else {
-                                MLET_LOGGER.logp(Level.FINER,
-                                        MLetParser.class.getName(),
-                                        mth, paramOutsideWarning);
+                                MLET_LOGGER.log(Level.TRACE, paramOutsideWarning);
                                 throw new IOException(paramOutsideWarning);
                             }
                         }
                         String val = t.get("value");
                         if (val == null) {
-                            MLET_LOGGER.logp(Level.FINER,
-                                    MLetParser.class.getName(),
-                                    mth, requiresValueWarning);
+                            MLET_LOGGER.log(Level.TRACE, requiresValueWarning);
                             throw new IOException(requiresValueWarning);
                         } else {
                             if (atts != null) {
                                 values.add(val);
                             } else {
-                                MLET_LOGGER.logp(Level.FINER,
-                                        MLetParser.class.getName(),
-                                        mth, paramOutsideWarning);
+                                MLET_LOGGER.log(Level.TRACE, paramOutsideWarning);
                                 throw new IOException(paramOutsideWarning);
                             }
                         }
@@ -238,15 +229,11 @@
                         if (nm.equalsIgnoreCase(tag)) {
                             atts = scanTag(in);
                             if (atts.get("code") == null && atts.get("object") == null) {
-                                MLET_LOGGER.logp(Level.FINER,
-                                        MLetParser.class.getName(),
-                                        mth, requiresCodeWarning);
+                                MLET_LOGGER.log(Level.TRACE, requiresCodeWarning);
                                 throw new IOException(requiresCodeWarning);
                             }
                             if (atts.get("archive") == null) {
-                                MLET_LOGGER.logp(Level.FINER,
-                                        MLetParser.class.getName(),
-                                        mth, requiresJarsWarning);
+                                MLET_LOGGER.log(Level.TRACE, requiresJarsWarning);
                                 throw new IOException(requiresJarsWarning);
                             }
                         }
--- a/jdk/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@
 import java.util.SortedMap;
 import java.util.StringTokenizer;
 import java.util.TreeMap;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.Descriptor;
 import javax.management.ImmutableDescriptor;
@@ -164,10 +164,8 @@
      * (the method {@link #isValid isValid} returns <CODE>false</CODE>)
      */
     public DescriptorSupport() {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "DescriptorSupport()" , "Constructor");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Constructor");
         }
         init(null);
     }
@@ -188,17 +186,14 @@
      */
     public DescriptorSupport(int initNumFields)
             throws MBeanException, RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(initNumFields = " + initNumFields + ")",
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Descriptor(initNumFields = " + initNumFields + ") " +
                     "Constructor");
         }
         if (initNumFields <= 0) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                        DescriptorSupport.class.getName(),
-                        "Descriptor(initNumFields)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                         "Illegal arguments: initNumFields <= 0");
             }
             final String msg =
@@ -219,10 +214,9 @@
      * fields, an empty Descriptor will be created.
      */
     public DescriptorSupport(DescriptorSupport inDescr) {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(Descriptor)", "Constructor");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Descriptor(Descriptor) Constructor");
         }
         if (inDescr == null)
             init(null);
@@ -268,16 +262,14 @@
                    XMLParseException {
         /* parse an XML-formatted string and populate internal
          * structure with it */
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(String = '" + inStr + "')", "Constructor");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Descriptor(String = '" + inStr + "') Constructor");
         }
         if (inStr == null) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                        DescriptorSupport.class.getName(),
-                        "Descriptor(String = null)", "Illegal arguments");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "Descriptor(String = null) Illegal arguments");
             }
             final String msg = "String in parameter is null";
             final RuntimeException iae = new IllegalArgumentException(msg);
@@ -350,10 +342,9 @@
                 }
             }
         }  // while tokens
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(XMLString)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Descriptor(XMLString) Exit");
         }
     }
 
@@ -380,19 +371,17 @@
      */
     public DescriptorSupport(String[] fieldNames, Object[] fieldValues)
             throws RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(fieldNames,fieldObjects)", "Constructor");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Descriptor(fieldNames,fieldObjects) Constructor");
         }
 
         if ((fieldNames == null) || (fieldValues == null) ||
             (fieldNames.length != fieldValues.length)) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                        DescriptorSupport.class.getName(),
-                        "Descriptor(fieldNames,fieldObjects)",
-                        "Illegal arguments");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "Descriptor(fieldNames,fieldObjects)" +
+                        " Illegal arguments");
             }
 
             final String msg =
@@ -408,10 +397,9 @@
             // the fieldName and fieldValue will be validated in setField.
             setField(fieldNames[i], fieldValues[i]);
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(fieldNames,fieldObjects)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Descriptor(fieldNames,fieldObjects) Exit");
         }
     }
 
@@ -444,10 +432,9 @@
      */
     public DescriptorSupport(String... fields)
     {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(String... fields)", "Constructor");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Descriptor(String... fields) Constructor");
         }
         init(null);
         if (( fields == null ) || ( fields.length == 0))
@@ -462,10 +449,9 @@
             int eq_separator = fields[i].indexOf('=');
             if (eq_separator < 0) {
                 // illegal if no = or is first character
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINEST,
-                            DescriptorSupport.class.getName(),
-                            "Descriptor(String... fields)",
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                            "Descriptor(String... fields) " +
                             "Illegal arguments: field does not have " +
                             "'=' as a name and value separator");
                 }
@@ -482,10 +468,9 @@
             }
 
             if (fieldName.equals("")) {
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINEST,
-                            DescriptorSupport.class.getName(),
-                            "Descriptor(String... fields)",
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                            "Descriptor(String... fields) " +
                             "Illegal arguments: fieldName is empty");
                 }
 
@@ -496,10 +481,9 @@
 
             setField(fieldName,fieldValue);
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(String... fields)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Descriptor(String... fields) Exit");
         }
     }
 
@@ -517,10 +501,8 @@
             throws RuntimeOperationsException {
 
         if ((fieldName == null) || (fieldName.equals(""))) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                        DescriptorSupport.class.getName(),
-                        "getFieldValue(String fieldName)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                         "Illegal arguments: null field name");
             }
             final String msg = "Fieldname requested is null";
@@ -528,10 +510,9 @@
             throw new RuntimeOperationsException(iae, msg);
         }
         Object retValue = descriptorMap.get(fieldName);
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFieldValue(String fieldName = " + fieldName + ")",
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "getFieldValue(String fieldName = " + fieldName + ") " +
                     "Returns '" + retValue + "'");
         }
         return(retValue);
@@ -542,10 +523,8 @@
 
         // field name cannot be null or empty
         if ((fieldName == null) || (fieldName.equals(""))) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                        DescriptorSupport.class.getName(),
-                        "setField(fieldName,fieldValue)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                         "Illegal arguments: null or empty field name");
             }
 
@@ -555,10 +534,8 @@
         }
 
         if (!validateField(fieldName, fieldValue)) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                        DescriptorSupport.class.getName(),
-                        "setField(fieldName,fieldValue)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                         "Illegal arguments");
             }
 
@@ -568,10 +545,8 @@
             throw new RuntimeOperationsException(iae, msg);
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "setField(fieldName,fieldValue)", "Entry: setting '"
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry: setting '"
                     + fieldName + "' to '" + fieldValue + "'");
         }
 
@@ -582,10 +557,8 @@
     }
 
     public synchronized String[] getFields() {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFields()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         int numberOfEntries = descriptorMap.size();
 
@@ -594,20 +567,18 @@
 
         int i = 0;
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFields()", "Returning " + numberOfEntries + " fields");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Returning " + numberOfEntries + " fields");
         }
         for (Iterator<Map.Entry<String, Object>> iter = returnedSet.iterator();
              iter.hasNext(); i++) {
             Map.Entry<String, Object> currElement = iter.next();
 
             if (currElement == null) {
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINEST,
-                            DescriptorSupport.class.getName(),
-                            "getFields()", "Element is null");
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                            "Element is null");
                 }
             } else {
                 Object currValue = currElement.getValue();
@@ -626,20 +597,16 @@
             }
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFields()", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return responseFields;
     }
 
     public synchronized String[] getFieldNames() {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFieldNames()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         int numberOfEntries = descriptorMap.size();
 
@@ -648,10 +615,8 @@
 
         int i = 0;
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFieldNames()",
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                     "Returning " + numberOfEntries + " fields");
         }
 
@@ -660,20 +625,16 @@
             Map.Entry<String, Object> currElement = iter.next();
 
             if (( currElement == null ) || (currElement.getKey() == null)) {
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINEST,
-                            DescriptorSupport.class.getName(),
-                            "getFieldNames()", "Field is null");
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE, "Field is null");
                 }
             } else {
                 responseFields[i] = currElement.getKey().toString();
             }
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFieldNames()", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return responseFields;
@@ -681,10 +642,8 @@
 
 
     public synchronized Object[] getFieldValues(String... fieldNames) {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFieldValues(String... fieldNames)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         // if fieldNames == null return all values
         // if fieldNames is String[0] return no values
@@ -695,10 +654,8 @@
 
         int i = 0;
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFieldValues(String... fieldNames)",
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                     "Returning " + numberOfEntries + " fields");
         }
 
@@ -715,10 +672,8 @@
             }
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "getFieldValues(String... fieldNames)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return responseFields;
@@ -728,18 +683,14 @@
                                        Object[] fieldValues)
             throws RuntimeOperationsException {
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "setFields(fieldNames,fieldValues)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if ((fieldNames == null) || (fieldValues == null) ||
             (fieldNames.length != fieldValues.length)) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                        DescriptorSupport.class.getName(),
-                        "setFields(fieldNames,fieldValues)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                         "Illegal arguments");
             }
 
@@ -750,10 +701,8 @@
 
         for (int i=0; i < fieldNames.length; i++) {
             if (( fieldNames[i] == null) || (fieldNames[i].equals(""))) {
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINEST,
-                            DescriptorSupport.class.getName(),
-                            "setFields(fieldNames,fieldValues)",
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "Null field name encountered at element " + i);
                 }
                 final String msg = "fieldNames is null or invalid";
@@ -762,10 +711,8 @@
             }
             setField(fieldNames[i], fieldValues[i]);
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "setFields(fieldNames,fieldValues)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
@@ -779,10 +726,8 @@
 
     @Override
     public synchronized Object clone() throws RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "clone()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         return(new DescriptorSupport(this));
     }
@@ -898,20 +843,17 @@
      */
 
     public synchronized boolean isValid() throws RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "isValid()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         // verify that the descriptor is valid, by iterating over each field...
 
         Set<Map.Entry<String, Object>> returnedSet = descriptorMap.entrySet();
 
         if (returnedSet == null) {   // null descriptor, not valid
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                        DescriptorSupport.class.getName(),
-                        "isValid()", "Returns false (null set)");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "isValid() Returns false (null set)");
             }
             return false;
         }
@@ -934,10 +876,8 @@
                                       (currElement.getValue()).toString())) {
                         continue;
                     } else {
-                        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                                    DescriptorSupport.class.getName(),
-                                    "isValid()",
+                        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                            MODELMBEAN_LOGGER.log(Level.TRACE,
                                     "Field " + currElement.getKey() + "=" +
                                     currElement.getValue() + " is not valid");
                         }
@@ -948,10 +888,9 @@
         }
 
         // fell through, all fields OK
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "isValid()", "Returns true");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "isValid() Returns true");
         }
         return true;
     }
@@ -1287,28 +1226,23 @@
      */
     @Override
     public synchronized String toString() {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "toString()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         String respStr = "";
         String[] fields = getFields();
 
         if ((fields == null) || (fields.length == 0)) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                        DescriptorSupport.class.getName(),
-                        "toString()", "Empty Descriptor");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Empty Descriptor");
             }
             return respStr;
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "toString()", "Printing " + fields.length + " fields");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Printing " + fields.length + " fields");
         }
 
         for (int i=0; i < fields.length; i++) {
@@ -1319,10 +1253,8 @@
             }
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "toString()", "Exit returning " + respStr);
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit returning " + respStr);
         }
 
         return respStr;
--- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 import java.io.ObjectStreamField;
 import java.lang.reflect.Method;
 import java.security.AccessController;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.Descriptor;
 import javax.management.DescriptorKey;
@@ -201,12 +201,11 @@
         throws javax.management.IntrospectionException {
                 super(name, description, getter, setter);
 
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanAttributeInfo.class.getName(),
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "ModelMBeanAttributeInfo(" +
-                            "String,String,Method,Method)",
-                            "Entry", name);
+                            "String,String,Method,Method) " +
+                            "Entry " + name);
                 }
 
                 attrDescriptor = validDescriptor(null);
@@ -251,12 +250,11 @@
 
                 super(name, description, getter, setter);
                 // put getter and setter methods in operations list
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanAttributeInfo.class.getName(),
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "ModelMBeanAttributeInfo(" +
-                            "String,String,Method,Method,Descriptor)",
-                            "Entry", name);
+                            "String,String,Method,Method,Descriptor) " +
+                            "Entry " + name);
                 }
                 attrDescriptor = validDescriptor(descriptor);
         }
@@ -282,8 +280,8 @@
 
                 super(name, type, description, isReadable, isWritable, isIs);
                 // create default descriptor
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             ModelMBeanAttributeInfo.class.getName(),
                             "ModelMBeanAttributeInfo(" +
                             "String,String,String,boolean,boolean,boolean)",
@@ -321,12 +319,11 @@
                                        Descriptor descriptor)
         {
                 super(name, type, description, isReadable, isWritable, isIs);
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanAttributeInfo.class.getName(),
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "ModelMBeanAttributeInfo(String,String,String," +
-                            "boolean,boolean,boolean,Descriptor)",
-                            "Entry", name);
+                            "boolean,boolean,boolean,Descriptor)" +
+                            "Entry " + name);
                 }
                 attrDescriptor = validDescriptor(descriptor);
         }
@@ -347,10 +344,9 @@
                           inInfo.isReadable(),
                           inInfo.isWritable(),
                           inInfo.isIs());
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanAttributeInfo.class.getName(),
-                            "ModelMBeanAttributeInfo(ModelMBeanAttributeInfo)",
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                            "ModelMBeanAttributeInfo(ModelMBeanAttributeInfo) " +
                             "Entry");
                 }
                 Descriptor newDesc = inInfo.getDescriptor();
@@ -368,10 +364,8 @@
          */
 
         public Descriptor getDescriptor() {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanAttributeInfo.class.getName(),
-                        "getDescriptor()", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
                 if (attrDescriptor == null) {
                     attrDescriptor = validDescriptor(null);
@@ -411,10 +405,8 @@
         @Override
         public Object clone()
         {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanAttributeInfo.class.getName(),
-                        "clone()", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
                 return(new ModelMBeanAttributeInfo(this));
         }
@@ -454,7 +446,7 @@
             boolean defaulted = (in == null);
             if (defaulted) {
                 clone = new DescriptorSupport();
-                MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new.");
             } else {
                 clone = (Descriptor) in.clone();
             }
@@ -462,15 +454,15 @@
             //Setting defaults.
             if (defaulted && clone.getFieldValue("name")==null) {
                 clone.setField("name", this.getName());
-                MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName());
             }
             if (defaulted && clone.getFieldValue("descriptorType")==null) {
                 clone.setField("descriptorType", "attribute");
-                MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"attribute\"");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"attribute\"");
             }
             if (clone.getFieldValue("displayName") == null) {
                 clone.setField("displayName",this.getName());
-                MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName());
             }
 
             //Checking validity
--- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 import java.io.ObjectStreamField;
 import java.lang.reflect.Constructor;
 import java.security.AccessController;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.Descriptor;
 import javax.management.DescriptorAccess;
@@ -164,10 +164,9 @@
                                          Constructor<?> constructorMethod)
     {
                 super(description, constructorMethod);
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanConstructorInfo.class.getName(),
-                            "ModelMBeanConstructorInfo(String,Constructor)",
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                            "ModelMBeanConstructorInfo(String,Constructor) " +
                             "Entry");
                 }
                 consDescriptor = validDescriptor(null);
@@ -209,11 +208,10 @@
 
                 super(description, constructorMethod);
                 // put getter and setter methods in constructors list
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanConstructorInfo.class.getName(),
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "ModelMBeanConstructorInfo(" +
-                            "String,Constructor,Descriptor)", "Entry");
+                            "String,Constructor,Descriptor) Entry");
                 }
                 consDescriptor = validDescriptor(descriptor);
         }
@@ -232,11 +230,10 @@
 
                 super(name, description, signature);
                 // create default descriptor
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanConstructorInfo.class.getName(),
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "ModelMBeanConstructorInfo(" +
-                            "String,String,MBeanParameterInfo[])", "Entry");
+                            "String,String,MBeanParameterInfo[]) Entry");
                 }
                 consDescriptor = validDescriptor(null);
         }
@@ -265,11 +262,10 @@
                                          Descriptor descriptor)
         {
                 super(name, description, signature);
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanConstructorInfo.class.getName(),
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "ModelMBeanConstructorInfo(" +
-                            "String,String,MBeanParameterInfo[],Descriptor)",
+                            "String,String,MBeanParameterInfo[],Descriptor) " +
                             "Entry");
                 }
                 consDescriptor = validDescriptor(descriptor);
@@ -284,11 +280,10 @@
         ModelMBeanConstructorInfo(ModelMBeanConstructorInfo old)
         {
                 super(old.getName(), old.getDescription(), old.getSignature());
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanConstructorInfo.class.getName(),
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "ModelMBeanConstructorInfo(" +
-                            "ModelMBeanConstructorInfo)", "Entry");
+                            "ModelMBeanConstructorInfo) Entry");
                 }
                 consDescriptor = validDescriptor(consDescriptor);
         }
@@ -300,10 +295,8 @@
         @Override
         public Object clone ()
         {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanConstructorInfo.class.getName(),
-                        "clone()", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
                 return(new ModelMBeanConstructorInfo(this)) ;
         }
@@ -321,10 +314,8 @@
         @Override
         public Descriptor getDescriptor()
         {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanConstructorInfo.class.getName(),
-                        "getDescriptor()", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
             if (consDescriptor == null){
                 consDescriptor = validDescriptor(null);
@@ -356,10 +347,8 @@
         */
         public void setDescriptor(Descriptor inDescriptor)
         {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanConstructorInfo.class.getName(),
-                        "setDescriptor()", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
             consDescriptor = validDescriptor(inDescriptor);
         }
@@ -370,10 +359,8 @@
         @Override
         public String toString()
         {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanConstructorInfo.class.getName(),
-                        "toString()", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
                 String retStr =
                     "ModelMBeanConstructorInfo: " + this.getName() +
@@ -408,7 +395,7 @@
             boolean defaulted = (in == null);
             if (defaulted) {
                 clone = new DescriptorSupport();
-                MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new.");
             } else {
                 clone = (Descriptor) in.clone();
             }
@@ -416,19 +403,19 @@
             //Setting defaults.
             if (defaulted && clone.getFieldValue("name")==null) {
                 clone.setField("name", this.getName());
-                MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName());
             }
             if (defaulted && clone.getFieldValue("descriptorType")==null) {
                 clone.setField("descriptorType", "operation");
-                MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"operation\"");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"operation\"");
             }
             if (clone.getFieldValue("displayName") == null) {
                 clone.setField("displayName",this.getName());
-                MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName());
             }
             if (clone.getFieldValue("role") == null) {
                 clone.setField("role","constructor");
-                MODELMBEAN_LOGGER.finer("Defaulting Descriptor role field to \"constructor\"");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor role field to \"constructor\"");
             }
 
             //Checking validity
--- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamField;
 import java.security.AccessController;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.Descriptor;
 import javax.management.MBeanAttributeInfo;
@@ -231,19 +231,16 @@
             modelMBeanDescriptor = validDescriptor(mbeandescriptor);
         } catch (MBeanException mbe) {
             modelMBeanDescriptor = validDescriptor(null);
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanInfoSupport.class.getName(),
-                        "ModelMBeanInfo(ModelMBeanInfo)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "ModelMBeanInfo(ModelMBeanInfo) " +
                         "Could not get a valid modelMBeanDescriptor, " +
                         "setting a default Descriptor");
             }
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "ModelMBeanInfo(ModelMBeanInfo)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
@@ -330,12 +327,11 @@
         modelMBeanOperations = operations;
         modelMBeanNotifications = notifications;
         modelMBeanDescriptor = validDescriptor(mbeandescriptor);
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                     "ModelMBeanInfoSupport(String,String,ModelMBeanAttributeInfo[]," +
                     "ModelMBeanConstructorInfo[],ModelMBeanOperationInfo[]," +
-                    "ModelMBeanNotificationInfo[],Descriptor)",
+                    "ModelMBeanNotificationInfo[],Descriptor) " +
                     "Exit");
         }
     }
@@ -367,10 +363,8 @@
 
     public Descriptor[] getDescriptors(String inDescriptorType)
     throws MBeanException, RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getDescriptors(String)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if ((inDescriptorType == null) || (inDescriptorType.equals(""))) {
@@ -474,10 +468,8 @@
                     " the descriptors of the MBean";
             throw new RuntimeOperationsException(iae,msg);
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getDescriptors(String)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return retList;
@@ -486,10 +478,8 @@
 
     public void setDescriptors(Descriptor[] inDescriptors)
     throws MBeanException, RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "setDescriptors(Descriptor[])", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         if (inDescriptors==null) {
             // throw RuntimeOperationsException - invalid descriptor
@@ -504,10 +494,8 @@
         for (int j=0; j < inDescriptors.length; j++) {
             setDescriptor(inDescriptors[j],null);
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "setDescriptors(Descriptor[])", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
     }
@@ -530,10 +518,8 @@
 
     public Descriptor getDescriptor(String inDescriptorName)
     throws MBeanException, RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getDescriptor(String)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         return(getDescriptor(inDescriptorName, null));
     }
@@ -606,10 +592,8 @@
             throws MBeanException, RuntimeOperationsException {
         final String excMsg =
                 "Exception occurred trying to set the descriptors of the MBean";
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "setDescriptor(Descriptor,String)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (inDescriptor==null) {
@@ -621,10 +605,9 @@
                     (String) inDescriptor.getFieldValue("descriptorType");
 
             if (inDescriptorType == null) {
-                   MODELMBEAN_LOGGER.logp(Level.FINER,
-                                ModelMBeanInfoSupport.class.getName(),
-                                "setDescriptor(Descriptor,String)",
-                                "descriptorType null in both String parameter and Descriptor, defaulting to "+ MMB);
+                   MODELMBEAN_LOGGER.log(Level.TRACE,
+                                "descriptorType null in both String parameter " +
+                                "and Descriptor, defaulting to "+ MMB);
                 inDescriptorType = MMB;
             }
         }
@@ -632,10 +615,9 @@
         String inDescriptorName =
                 (String) inDescriptor.getFieldValue("name");
         if (inDescriptorName == null) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                                ModelMBeanInfoSupport.class.getName(),
-                                "setDescriptor(Descriptor,String)",
-                                "descriptor name null, defaulting to "+ this.getClassName());
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                                "descriptor name null, defaulting to " +
+                                this.getClassName());
             inDescriptorName = this.getClassName();
         }
         boolean found = false;
@@ -653,17 +635,14 @@
                     ModelMBeanAttributeInfo mmbai =
                             (ModelMBeanAttributeInfo) attrList[i];
                     mmbai.setDescriptor(inDescriptor);
-                    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
+                    if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
                         StringBuilder strb = new StringBuilder()
                         .append("Setting descriptor to ").append(inDescriptor)
                         .append("\t\n local: AttributeInfo descriptor is ")
                         .append(mmbai.getDescriptor())
                         .append("\t\n modelMBeanInfo: AttributeInfo descriptor is ")
                         .append(this.getDescriptor(inDescriptorName,"attribute"));
-                        MODELMBEAN_LOGGER.logp(Level.FINER,
-                                ModelMBeanInfoSupport.class.getName(),
-                                "setDescriptor(Descriptor,String)",
-                                strb.toString());
+                        MODELMBEAN_LOGGER.log(Level.TRACE, strb::toString);
                     }
                 }
             }
@@ -720,10 +699,8 @@
                     "; name=" + inDescriptorName);
             throw new RuntimeOperationsException(iae, excMsg);
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "setDescriptor(Descriptor,String)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
     }
@@ -732,10 +709,8 @@
     public ModelMBeanAttributeInfo getAttribute(String inName)
     throws MBeanException, RuntimeOperationsException {
         ModelMBeanAttributeInfo retInfo = null;
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getAttribute(String)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         if (inName == null) {
             throw new RuntimeOperationsException(
@@ -748,7 +723,7 @@
         if (attrList != null) numAttrs = attrList.length;
 
         for (int i=0; (i < numAttrs) && (retInfo == null); i++) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
                 final StringBuilder strb = new StringBuilder()
                 .append("\t\n this.getAttributes() MBeanAttributeInfo Array ")
                 .append(i).append(":")
@@ -756,18 +731,14 @@
                 .append("\t\n this.modelMBeanAttributes MBeanAttributeInfo Array ")
                 .append(i).append(":")
                 .append(((ModelMBeanAttributeInfo)modelMBeanAttributes[i]).getDescriptor());
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanInfoSupport.class.getName(),
-                        "getAttribute(String)", strb.toString());
+                MODELMBEAN_LOGGER.log(Level.TRACE, strb::toString);
             }
             if (inName.equals(attrList[i].getName())) {
                 retInfo = ((ModelMBeanAttributeInfo)attrList[i].clone());
             }
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getAttribute(String)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return retInfo;
@@ -778,10 +749,8 @@
     public ModelMBeanOperationInfo getOperation(String inName)
     throws MBeanException, RuntimeOperationsException {
         ModelMBeanOperationInfo retInfo = null;
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getOperation(String)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         if (inName == null) {
             throw new RuntimeOperationsException(
@@ -798,10 +767,8 @@
                 retInfo = ((ModelMBeanOperationInfo) operList[i].clone());
             }
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getOperation(String)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return retInfo;
@@ -824,10 +791,8 @@
     public ModelMBeanConstructorInfo getConstructor(String inName)
     throws MBeanException, RuntimeOperationsException {
         ModelMBeanConstructorInfo retInfo = null;
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getConstructor(String)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         if (inName == null) {
             throw new RuntimeOperationsException(
@@ -844,10 +809,8 @@
                 retInfo = ((ModelMBeanConstructorInfo) consList[i].clone());
             }
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getConstructor(String)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return retInfo;
@@ -857,10 +820,8 @@
     public ModelMBeanNotificationInfo getNotification(String inName)
     throws MBeanException, RuntimeOperationsException {
         ModelMBeanNotificationInfo retInfo = null;
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getNotification(String)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         if (inName == null) {
             throw new RuntimeOperationsException(
@@ -877,10 +838,8 @@
                 retInfo = ((ModelMBeanNotificationInfo) notifList[i].clone());
             }
         }
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getNotification(String)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return retInfo;
@@ -901,19 +860,15 @@
     }
 
     private Descriptor getMBeanDescriptorNoException() {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getMBeanDescriptorNoException()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (modelMBeanDescriptor == null)
             modelMBeanDescriptor = validDescriptor(null);
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "getMBeanDescriptorNoException()",
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                     "Exit, returning: " + modelMBeanDescriptor);
         }
         return (Descriptor) modelMBeanDescriptor.clone();
@@ -921,10 +876,8 @@
 
     public void setMBeanDescriptor(Descriptor inMBeanDescriptor)
     throws MBeanException, RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanInfoSupport.class.getName(),
-                    "setMBeanDescriptor(Descriptor)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         modelMBeanDescriptor = validDescriptor(inMBeanDescriptor);
     }
@@ -948,7 +901,7 @@
         boolean defaulted = (in == null);
         if (defaulted) {
             clone = new DescriptorSupport();
-            MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new.");
         } else {
             clone = (Descriptor) in.clone();
         }
@@ -956,27 +909,27 @@
         //Setting defaults.
         if (defaulted && clone.getFieldValue("name")==null) {
             clone.setField("name", this.getClassName());
-            MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getClassName());
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getClassName());
         }
         if (defaulted && clone.getFieldValue("descriptorType")==null) {
             clone.setField("descriptorType", MMB);
-            MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"" + MMB + "\"");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"" + MMB + "\"");
         }
         if (clone.getFieldValue("displayName") == null) {
             clone.setField("displayName",this.getClassName());
-            MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getClassName());
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getClassName());
         }
         if (clone.getFieldValue("persistPolicy") == null) {
             clone.setField("persistPolicy","never");
-            MODELMBEAN_LOGGER.finer("Defaulting Descriptor persistPolicy to \"never\"");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor persistPolicy to \"never\"");
         }
         if (clone.getFieldValue("log") == null) {
             clone.setField("log","F");
-            MODELMBEAN_LOGGER.finer("Defaulting Descriptor \"log\" field to \"F\"");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor \"log\" field to \"F\"");
         }
         if (clone.getFieldValue("visibility") == null) {
             clone.setField("visibility","1");
-            MODELMBEAN_LOGGER.finer("Defaulting Descriptor visibility to 1");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor visibility to 1");
         }
 
         //Checking validity
--- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamField;
 import java.security.AccessController;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.Descriptor;
 import javax.management.DescriptorAccess;
@@ -199,10 +199,8 @@
                                       String description,
                                       Descriptor descriptor) {
         super(notifTypes, name, description);
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanNotificationInfo.class.getName(),
-                    "ModelMBeanNotificationInfo", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         notificationDescriptor = validDescriptor(descriptor);
     }
@@ -225,10 +223,8 @@
      * duplicate of this ModelMBeanNotificationInfo.
      **/
     public Object clone () {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanNotificationInfo.class.getName(),
-                    "clone()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         return(new ModelMBeanNotificationInfo(this));
     }
@@ -243,18 +239,15 @@
      * @see #setDescriptor
      **/
     public Descriptor getDescriptor() {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanNotificationInfo.class.getName(),
-                    "getDescriptor()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (notificationDescriptor == null) {
             // Dead code. Should never happen.
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanNotificationInfo.class.getName(),
-                        "getDescriptor()", "Descriptor value is null, " +
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "Descriptor value is null, " +
                         "setting descriptor to default values");
             }
             notificationDescriptor = validDescriptor(null);
@@ -281,10 +274,8 @@
      * @see #getDescriptor
      **/
     public void setDescriptor(Descriptor inDescriptor) {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanNotificationInfo.class.getName(),
-                    "setDescriptor(Descriptor)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         notificationDescriptor = validDescriptor(inDescriptor);
     }
@@ -296,10 +287,8 @@
      * @return a string describing this object.
      **/
     public String toString() {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    ModelMBeanNotificationInfo.class.getName(),
-                    "toString()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         final StringBuilder retStr = new StringBuilder();
@@ -342,7 +331,7 @@
         boolean defaulted = (in == null);
         if (defaulted) {
             clone = new DescriptorSupport();
-            MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new.");
         } else {
             clone = (Descriptor) in.clone();
         }
@@ -350,19 +339,19 @@
         //Setting defaults.
         if (defaulted && clone.getFieldValue("name")==null) {
             clone.setField("name", this.getName());
-            MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName());
         }
         if (defaulted && clone.getFieldValue("descriptorType")==null) {
             clone.setField("descriptorType", "notification");
-            MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"notification\"");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"notification\"");
         }
         if (clone.getFieldValue("displayName") == null) {
             clone.setField("displayName",this.getName());
-            MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName());
         }
         if (clone.getFieldValue("severity") == null) {
             clone.setField("severity", "6");
-            MODELMBEAN_LOGGER.finer("Defaulting Descriptor severity field to 6");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor severity field to 6");
         }
 
         //Checking validity
--- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 import java.io.ObjectStreamField;
 import java.lang.reflect.Method;
 import java.security.AccessController;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.Descriptor;
 import javax.management.DescriptorAccess;
@@ -185,10 +185,9 @@
         {
                 super(description, operationMethod);
                 // create default descriptor
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanOperationInfo.class.getName(),
-                            "ModelMBeanOperationInfo(String,Method)",
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                            "ModelMBeanOperationInfo(String,Method) " +
                             "Entry");
                 }
                 operationDescriptor = validDescriptor(null);
@@ -228,11 +227,10 @@
         {
 
                 super(description, operationMethod);
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanOperationInfo.class.getName(),
-                            "ModelMBeanOperationInfo(String,Method,Descriptor)",
-                            "Entry");
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                            "ModelMBeanOperationInfo(String,Method,Descriptor) "
+                            + "Entry");
                 }
                 operationDescriptor = validDescriptor(descriptor);
         }
@@ -258,11 +256,10 @@
 
                 super(name, description, signature, type, impact);
                 // create default descriptor
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanOperationInfo.class.getName(),
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "ModelMBeanOperationInfo(" +
-                            "String,String,MBeanParameterInfo[],String,int)",
+                            "String,String,MBeanParameterInfo[],String,int) " +
                             "Entry");
                 }
                 operationDescriptor = validDescriptor(null);
@@ -302,11 +299,10 @@
                                        Descriptor descriptor)
         {
                 super(name, description, signature, type, impact);
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanOperationInfo.class.getName(),
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "ModelMBeanOperationInfo(String,String," +
-                            "MBeanParameterInfo[],String,int,Descriptor)",
+                            "MBeanParameterInfo[],String,int,Descriptor) " +
                             "Entry");
                 }
                 operationDescriptor = validDescriptor(descriptor);
@@ -327,10 +323,9 @@
                           inInfo.getSignature(),
                           inInfo.getReturnType(),
                           inInfo.getImpact());
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            ModelMBeanOperationInfo.class.getName(),
-                            "ModelMBeanOperationInfo(ModelMBeanOperationInfo)",
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                            "ModelMBeanOperationInfo(ModelMBeanOperationInfo)" +
                             "Entry");
                 }
                 Descriptor newDesc = inInfo.getDescriptor();
@@ -345,10 +340,8 @@
 
         public Object clone ()
         {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanOperationInfo.class.getName(),
-                        "clone()", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
                 return(new ModelMBeanOperationInfo(this)) ;
         }
@@ -365,10 +358,8 @@
 
         public Descriptor getDescriptor()
         {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanOperationInfo.class.getName(),
-                        "getDescriptor()", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
             if (operationDescriptor == null) {
                 operationDescriptor = validDescriptor(null);
@@ -396,10 +387,8 @@
          */
         public void setDescriptor(Descriptor inDescriptor)
         {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanOperationInfo.class.getName(),
-                        "setDescriptor(Descriptor)", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
             operationDescriptor = validDescriptor(inDescriptor);
         }
@@ -410,10 +399,8 @@
         */
         public String toString()
         {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        ModelMBeanOperationInfo.class.getName(),
-                        "toString()", "Entry");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
             }
                 String retStr =
                     "ModelMBeanOperationInfo: " + this.getName() +
@@ -449,7 +436,7 @@
             boolean defaulted = (in == null);
             if (defaulted) {
                 clone = new DescriptorSupport();
-                MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new.");
             } else {
                 clone = (Descriptor) in.clone();
             }
@@ -457,19 +444,19 @@
             //Setting defaults.
             if (defaulted && clone.getFieldValue("name")==null) {
                 clone.setField("name", this.getName());
-                MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName());
             }
             if (defaulted && clone.getFieldValue("descriptorType")==null) {
                 clone.setField("descriptorType", "operation");
-                MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"operation\"");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"operation\"");
             }
             if (clone.getFieldValue("displayName") == null) {
                 clone.setField("displayName",this.getName());
-                MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName());
             }
             if (clone.getFieldValue("role") == null) {
                 clone.setField("role","operation");
-                MODELMBEAN_LOGGER.finer("Defaulting Descriptor role field to \"operation\"");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor role field to \"operation\"");
             }
 
             //Checking validity
--- a/jdk/src/java.management/share/classes/javax/management/modelmbean/RequiredModelMBean.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/RequiredModelMBean.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import java.util.Map;
 import java.util.Set;
 
@@ -166,16 +166,12 @@
      **/
     public RequiredModelMBean()
         throws MBeanException, RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                    "RequiredModelMBean()", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         modelMBeanInfo = createDefaultModelMBeanInfo();
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                    "RequiredModelMBean()", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
@@ -202,17 +198,13 @@
     public RequiredModelMBean(ModelMBeanInfo mbi)
         throws MBeanException, RuntimeOperationsException {
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                    "RequiredModelMBean(MBeanInfo)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
         setModelMBeanInfo(mbi);
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                    "RequiredModelMBean(MBeanInfo)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
@@ -257,17 +249,13 @@
     public void setModelMBeanInfo(ModelMBeanInfo mbi)
         throws MBeanException, RuntimeOperationsException {
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setModelMBeanInfo(ModelMBeanInfo)","Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (mbi == null) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                    "setModelMBeanInfo(ModelMBeanInfo)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                     "ModelMBeanInfo is null: Raising exception.");
             }
             final RuntimeException x = new
@@ -279,10 +267,8 @@
         }
 
         if (registered) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                    "setModelMBeanInfo(ModelMBeanInfo)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                     "RequiredMBean is registered: Raising exception.");
             }
             final String exceptionText =
@@ -293,32 +279,24 @@
             throw new RuntimeOperationsException(x,exceptionText);
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setModelMBeanInfo(ModelMBeanInfo)",
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                 "Setting ModelMBeanInfo to " + printModelMBeanInfo(mbi));
             int noOfNotifications = 0;
             if (mbi.getNotifications() != null) {
                 noOfNotifications = mbi.getNotifications().length;
             }
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setModelMBeanInfo(ModelMBeanInfo)",
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                 "ModelMBeanInfo notifications has " +
                 noOfNotifications + " elements");
         }
 
         modelMBeanInfo = (ModelMBeanInfo)mbi.clone();
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setModelMBeanInfo(ModelMBeanInfo)","set mbeanInfo to: "+
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "set mbeanInfo to: "+
                  printModelMBeanInfo(modelMBeanInfo));
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setModelMBeanInfo(ModelMBeanInfo)","Exit");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
@@ -346,37 +324,29 @@
     public void setManagedResource(Object mr, String mr_type)
         throws MBeanException, RuntimeOperationsException,
                InstanceNotFoundException, InvalidTargetObjectTypeException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setManagedResource(Object,String)","Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         // check that the mr_type is supported by this JMXAgent
         // only "objectReference" is supported
         if ((mr_type == null) ||
             (! mr_type.equalsIgnoreCase("objectReference"))) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                    "setManagedResource(Object,String)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                     "Managed Resource Type is not supported: " + mr_type);
             }
             throw new InvalidTargetObjectTypeException(mr_type);
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setManagedResource(Object,String)",
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                 "Managed Resource is valid");
         }
         managedResource = mr;
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setManagedResource(Object, String)", "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
@@ -482,11 +452,9 @@
     private Object resolveForCacheValue(Descriptor descr)
         throws MBeanException, RuntimeOperationsException {
 
-        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER);
-        final String mth = "resolveForCacheValue(Descriptor)";
+        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE);
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,"Entry");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         Object response = null;
@@ -495,25 +463,22 @@
 
         if (descr == null) {
             if (tracing) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),mth,
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                     "Input Descriptor is null");
             }
             return response;
         }
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                    mth, "descriptor is " + descr);
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "descriptor is " + descr);
         }
 
         final Descriptor mmbDescr = modelMBeanInfo.getMBeanDescriptor();
         if (mmbDescr == null) {
             if (tracing) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                        mth,"MBean Descriptor is null");
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "MBean Descriptor is null");
             }
             //return response;
         }
@@ -538,9 +503,8 @@
 
         if (expTime != null) {
             if (tracing) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                        mth,"currencyTimeLimit: " + expTime);
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "currencyTimeLimit: " + expTime);
             }
 
             // convert seconds to milliseconds for time comparison
@@ -550,8 +514,7 @@
                 returnCachedValue = false;
                 resetValue = true;
                 if (tracing) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(),mth,
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                         currencyPeriod + ": never Cached");
                 }
             } else if (currencyPeriod == 0) {
@@ -559,9 +522,7 @@
                 returnCachedValue = true;
                 resetValue = false;
                 if (tracing) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(),mth,
-                        "always valid Cache");
+                    MODELMBEAN_LOGGER.log(Level.TRACE, "always valid Cache");
                 }
             } else {
                 Object objtStamp =
@@ -572,8 +533,7 @@
                 else tStamp = null;
 
                 if (tracing) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(),mth,
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                         "lastUpdatedTimeStamp: " + tStamp);
                 }
 
@@ -583,8 +543,7 @@
                 long lastTime = Long.parseLong(tStamp);
 
                 if (tracing) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(),mth,
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                         "currencyPeriod:" + currencyPeriod +
                         " lastUpdatedTimeStamp:" + lastTime);
                 }
@@ -595,8 +554,7 @@
                     returnCachedValue = true;
                     resetValue = false;
                     if (tracing) {
-                        MODELMBEAN_LOGGER.logp(Level.FINER,
-                                RequiredModelMBean.class.getName(),mth,
+                        MODELMBEAN_LOGGER.log(Level.TRACE,
                             " timed valid Cache for " + now + " < " +
                             (lastTime + currencyPeriod));
                     }
@@ -604,16 +562,14 @@
                     returnCachedValue = false;
                     resetValue = true;
                     if (tracing) {
-                        MODELMBEAN_LOGGER.logp(Level.FINER,
-                                RequiredModelMBean.class.getName(),mth,
+                        MODELMBEAN_LOGGER.log(Level.TRACE,
                             "timed expired cache for " + now + " > " +
                             (lastTime + currencyPeriod));
                     }
                 }
             }
             if (tracing) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),mth,
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                     "returnCachedValue:" + returnCachedValue +
                     " resetValue: " + resetValue);
             }
@@ -625,17 +581,15 @@
                     response = currValue;
                     /* need to cast string cached value to type */
                     if (tracing) {
-                        MODELMBEAN_LOGGER.logp(Level.FINER,
-                                RequiredModelMBean.class.getName(),mth,
+                        MODELMBEAN_LOGGER.log(Level.TRACE,
                             "valid Cache value: " + currValue);
                     }
 
                 } else {
                     response = null;
                     if (tracing) {
-                        MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(),
-                                mth,"no Cached value");
+                        MODELMBEAN_LOGGER.log(Level.TRACE,
+                                 "no Cached value");
                     }
                 }
             }
@@ -647,16 +601,14 @@
                 response = null;
                 modelMBeanInfo.setDescriptor(descr,null);
                 if (tracing) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                            mth,"reset cached value to null");
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "reset cached value to null");
                 }
             }
         }
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,"Exit");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return response;
@@ -672,31 +624,24 @@
      **/
     public MBeanInfo getMBeanInfo() {
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                    "getMBeanInfo()","Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (modelMBeanInfo == null) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                    "getMBeanInfo()","modelMBeanInfo is null");
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "modelMBeanInfo is null");
             }
             modelMBeanInfo = createDefaultModelMBeanInfo();
             //return new ModelMBeanInfo(" ", "", null, null, null, null);
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "getMBeanInfo()","ModelMBeanInfo is " +
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanInfo is " +
                   modelMBeanInfo.getClassName() + " for " +
                   modelMBeanInfo.getDescription());
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "getMBeanInfo()",printModelMBeanInfo(modelMBeanInfo));
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    printModelMBeanInfo(modelMBeanInfo));
         }
 
         return((MBeanInfo) modelMBeanInfo.clone());
@@ -705,10 +650,8 @@
     private String printModelMBeanInfo(ModelMBeanInfo info) {
         final StringBuilder retStr = new StringBuilder();
         if (info == null) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                        "printModelMBeanInfo(ModelMBeanInfo)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                         "ModelMBeanInfo to print is null, " +
                         "printing local ModelMBeanInfo");
             }
@@ -909,12 +852,10 @@
     public Object invoke(String opName, Object[] opArgs, String[] sig)
             throws MBeanException, ReflectionException {
 
-        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER);
-        final String mth = "invoke(String, Object[], String[])";
+        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE);
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(), mth, "Entry");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (opName == null) {
@@ -943,9 +884,8 @@
             opMethodName = opMethodName.substring(0,opSplitter);
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                    mth, "Finding operation " + opName + " as " + opMethodName);
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Finding operation " + opName + " as " + opMethodName);
         }
 
         ModelMBeanOperationInfo opInfo =
@@ -965,10 +905,7 @@
         final Object cached = resolveForCacheValue(opDescr);
         if (cached != null) {
             if (tracing) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                        mth,
-                        "Returning cached value");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Returning cached value");
             }
             return cached;
         }
@@ -996,9 +933,8 @@
 
         final Object targetObjectField = opDescr.getFieldValue("targetObject");
         if (tracing && targetObjectField != null)
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                        mth, "Found target object in descriptor");
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "Found target object in descriptor");
 
         /* Now look for the method, either in RequiredModelMBean itself
            or in the target object.  Set "method" and "targetObject"
@@ -1013,9 +949,8 @@
             targetObject = this;
         else {
             if (tracing) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                        mth, "looking for method in managedResource class");
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "looking for method in managedResource class");
             }
             if (targetObjectField != null)
                 targetObject = targetObjectField;
@@ -1071,18 +1006,15 @@
         }
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                RequiredModelMBean.class.getName(),
-                    mth, "found " + opMethodName + ", now invoking");
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "found " + opMethodName + ", now invoking");
         }
 
         final Object result =
             invokeMethod(opName, method, targetObject, opArgs);
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                RequiredModelMBean.class.getName(),
-                    mth, "successfully invoked method");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "successfully invoked method");
         }
 
         if (result != null)
@@ -1095,12 +1027,11 @@
                                         String opMethodName,
                                         final String[] sig)
             throws ReflectionException {
-        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER);
+        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE);
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                RequiredModelMBean.class.getName(),"resolveMethod",
-                  "resolving " + targetClass.getName() + "." + opMethodName);
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "resolving " + targetClass.getName() + "." + opMethodName);
         }
 
         final Class<?>[] argClasses;
@@ -1119,8 +1050,7 @@
                 public Void run() {
                     for (int i = 0; i < sig.length; i++) {
                         if (tracing) {
-                            MODELMBEAN_LOGGER.logp(Level.FINER,
-                                RequiredModelMBean.class.getName(),"resolveMethod",
+                            MODELMBEAN_LOGGER.log(Level.TRACE,
                                     "resolve type " + sig[i]);
                         }
                         argClasses[i] = (Class<?>) primitiveClassMap.get(sig[i]);
@@ -1131,9 +1061,7 @@
                                     Class.forName(sig[i], false, targetClassLoader);
                             } catch (ClassNotFoundException e) {
                                 if (tracing) {
-                                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                                            RequiredModelMBean.class.getName(),
-                                            "resolveMethod",
+                                    MODELMBEAN_LOGGER.log(Level.TRACE,
                                             "class not found");
                                 }
                                 final String msg = "Parameter class not found";
@@ -1182,12 +1110,10 @@
                                          Object targetObjectField,
                                          String opClassName,
                                          String[] sig) {
-        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER);
+        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE);
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                RequiredModelMBean.class.getName(),
-                    "invoke(String, Object[], String[])",
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                   "looking for method in RequiredModelMBean class");
         }
 
@@ -1340,10 +1266,8 @@
 
             modelMBeanInfo.setDescriptor(opDescr,
                                          "operation");
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                        "invoke(String,Object[],Object[])",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                         "new descriptor is " + opDescr);
             }
         }
@@ -1495,12 +1419,9 @@
                 IllegalArgumentException("attributeName must not be null"),
                 "Exception occurred trying to get attribute of a " +
                 "RequiredModelMBean");
-        final String mth = "getAttribute(String)";
-        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER);
+        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE);
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                mth, "Entry with " + attrName);
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry with " + attrName);
         }
 
         /* Check attributeDescriptor for getMethod */
@@ -1530,16 +1451,14 @@
 
                 /* return current cached value */
                 if (tracing) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(), mth,
-                        "*** cached value is " + response);
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                            "*** cached value is " + response);
                 }
 
                 if (response == null) {
                     /* no cached value, run getMethod */
                     if (tracing) {
-                        MODELMBEAN_LOGGER.logp(Level.FINER,
-                                RequiredModelMBean.class.getName(), mth,
+                        MODELMBEAN_LOGGER.log(Level.TRACE,
                             "**** cached value is null - getting getMethod");
                     }
                     String attrGetMethod =
@@ -1548,9 +1467,8 @@
                     if (attrGetMethod != null) {
                         /* run method from operations descriptor */
                         if (tracing) {
-                            MODELMBEAN_LOGGER.logp(Level.FINER,
-                                    RequiredModelMBean.class.getName(),
-                                mth, "invoking a getMethod for " +  attrName);
+                            MODELMBEAN_LOGGER.log(Level.TRACE,
+                                "invoking a getMethod for " +  attrName);
                         }
 
                         Object getResponse =
@@ -1560,9 +1478,8 @@
                         if (getResponse != null) {
                             // error/validity check return value here
                             if (tracing) {
-                                MODELMBEAN_LOGGER.logp(Level.FINER,
-                                        RequiredModelMBean.class.getName(),
-                                        mth, "got a non-null response " +
+                                MODELMBEAN_LOGGER.log(Level.TRACE,
+                                        "got a non-null response " +
                                         "from getMethod\n");
                             }
 
@@ -1585,9 +1502,7 @@
 
                             if ((ctl != null) && !(ctl.equals("-1"))) {
                                 if (tracing) {
-                                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                                            RequiredModelMBean.class.getName(),
-                                            mth,
+                                    MODELMBEAN_LOGGER.log(Level.TRACE,
                                             "setting cached value and " +
                                             "lastUpdatedTime in descriptor");
                                 }
@@ -1600,19 +1515,15 @@
                                 modelMBeanInfo.setDescriptor(attrDescr,
                                                              "attribute");
                                 if (tracing) {
-                                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                                            RequiredModelMBean.class.getName(),
-                                        mth,"new descriptor is " +attrDescr);
-                                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                                            RequiredModelMBean.class.getName(),
-                                        mth,"AttributeInfo descriptor is " +
+                                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                                            "new descriptor is " +attrDescr);
+                                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                                            "AttributeInfo descriptor is " +
                                             attrInfo.getDescriptor());
                                     final String attStr = modelMBeanInfo.
                                         getDescriptor(attrName,"attribute").
                                             toString();
-                                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                                            RequiredModelMBean.class.getName(),
-                                            mth,
+                                    MODELMBEAN_LOGGER.log(Level.TRACE,
                                             "modelMBeanInfo: AttributeInfo " +
                                             "descriptor is " + attStr);
                                 }
@@ -1620,8 +1531,7 @@
                         } else {
                             // response was invalid or really returned null
                             if (tracing) {
-                                MODELMBEAN_LOGGER.logp(Level.FINER,
-                                        RequiredModelMBean.class.getName(), mth,
+                                MODELMBEAN_LOGGER.log(Level.TRACE,
                                     "got a null response from getMethod\n");
                             }
                             response = null;
@@ -1635,8 +1545,7 @@
                             response = attrDescr.getFieldValue("default");
                         }
                         if (tracing) {
-                            MODELMBEAN_LOGGER.logp(Level.FINER,
-                                    RequiredModelMBean.class.getName(), mth,
+                            MODELMBEAN_LOGGER.log(Level.TRACE,
                                 "could not find getMethod for " +attrName +
                                 ", returning descriptor " +qualifier + "value");
                         }
@@ -1698,9 +1607,8 @@
                                 subtype = false;
 
                                 if (tracing) {
-                                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                                            RequiredModelMBean.class.getName(),
-                                        mth, "Exception: ",e);
+                                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                                            "Exception: ", e);
                                 }
                             }
                             if (!subtype)
@@ -1708,9 +1616,8 @@
                         }
                         if (wrongType) {
                             if (tracing) {
-                                MODELMBEAN_LOGGER.logp(Level.FINER,
-                                        RequiredModelMBean.class.getName(), mth,
-                                    "Wrong response type '" + respType + "'");
+                                MODELMBEAN_LOGGER.log(Level.TRACE,
+                                     "Wrong response type '" + respType + "'");
                             }
                             // throw exception, didn't get
                             // back right attribute type
@@ -1724,8 +1631,7 @@
                 }
             } else {
                 if (tracing) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(), mth,
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "getMethod failed " + attrName +
                             " not in attributeDescriptor\n");
                 }
@@ -1743,8 +1649,7 @@
             throw t;
         } catch (Exception e) {
             if (tracing) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(), mth,
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                         "getMethod failed with " + e.getMessage() +
                         " exception type " + (e.getClass()).toString());
             }
@@ -1753,8 +1658,7 @@
         }
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(), mth, "Exit");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return response;
@@ -1777,10 +1681,9 @@
      * @see #setAttributes(javax.management.AttributeList)
      */
     public AttributeList getAttributes(String[] attrNames)      {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-            "getAttributes(String[])","Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    RequiredModelMBean.class.getName(), "Entry");
         }
 
         if (attrNames == null)
@@ -1797,19 +1700,15 @@
             } catch (Exception e) {
                 // eat exceptions because interface doesn't have an
                 // exception on it
-                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(),
-                        "getAttributes(String[])",
+                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "Failed to get \"" + attrNames[i] + "\": ", e);
                 }
             }
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                RequiredModelMBean.class.getName(),
-                    "getAttributes(String[])","Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return responseList;
@@ -1894,11 +1793,9 @@
     public void setAttribute(Attribute attribute)
         throws AttributeNotFoundException, InvalidAttributeValueException,
                MBeanException, ReflectionException {
-        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER);
+        final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE);
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setAttribute()","Entry");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (attribute == null)
@@ -1958,11 +1855,9 @@
                                             attrValue.getClass().getName() +
                                                            " received.");
                     } catch (ClassNotFoundException x) {
-                        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                            MODELMBEAN_LOGGER.logp(Level.FINER,
-                                    RequiredModelMBean.class.getName(),
-                                "setAttribute(Attribute)","Class " +
-                                    attrType + " for attribute "
+                        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                            MODELMBEAN_LOGGER.log(Level.TRACE,
+                                "Class " + attrType + " for attribute "
                                 + attrName + " not found: ", x);
                         }
                     }
@@ -1996,9 +1891,7 @@
 
             if (updateCache || updateDescriptor) {
                 if (tracing) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                            "setAttribute(Attribute)",
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
                             "setting cached value of " +
                             attrName + " to " + attrValue);
                 }
@@ -2022,26 +1915,22 @@
                     .append(attrInfo.getDescriptor())
                     .append(". AttributeInfo descriptor is ")
                     .append(modelMBeanInfo.getDescriptor(attrName,"attribute"));
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(),
-                            "setAttribute(Attribute)",strb.toString());
+                    MODELMBEAN_LOGGER.log(Level.TRACE, strb::toString);
                 }
 
             }
 
             if (tracing) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                "setAttribute(Attribute)","sending sendAttributeNotification");
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "sending sendAttributeNotification");
             }
             sendAttributeChangeNotification(oldAttr,attribute);
 
         } else { // if descriptor ... else no descriptor
 
             if (tracing) {
-                    MODELMBEAN_LOGGER.logp(Level.FINER,
-                            RequiredModelMBean.class.getName(),
-                        "setAttribute(Attribute)","setMethod failed "+attrName+
+                    MODELMBEAN_LOGGER.log(Level.TRACE,
+                        "setMethod failed " + attrName +
                         " not in attributeDescriptor\n");
             }
 
@@ -2051,9 +1940,7 @@
         } // else no descriptor
 
         if (tracing) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setAttribute(Attribute)", "Exit");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
     }
@@ -2076,10 +1963,8 @@
      **/
     public AttributeList setAttributes(AttributeList attributes) {
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "setAttribute(Attribute)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (attributes == null)
@@ -2118,17 +2003,13 @@
     private synchronized void writeToLog(String logFileName,
                                          String logEntry) throws Exception {
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "writeToLog(String, String)",
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                 "Notification Logging to " + logFileName + ": " + logEntry);
         }
         if ((logFileName == null) || (logEntry == null)) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                    "writeToLog(String, String)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                     "Bad input parameters, will not log this entry.");
             }
             return;
@@ -2139,17 +2020,13 @@
             PrintStream logOut = new PrintStream(fos);
             logOut.println(logEntry);
             logOut.close();
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(),
-                    "writeToLog(String, String)","Successfully opened log " +
-                        logFileName);
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
+                    "Successfully opened log " + logFileName);
             }
         } catch (Exception e) {
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                        "writeToLog(String, String)",
+            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                         "Exception " + e.toString() +
                         " trying to write to the Notification log file " +
                         logFileName);
@@ -2184,11 +2061,8 @@
                                         NotificationFilter filter,
                                         Object handback)
         throws java.lang.IllegalArgumentException {
-        final String mth = "addNotificationListener(" +
-                "NotificationListener, NotificationFilter, Object)";
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(), mth, "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (listener == null)
@@ -2200,12 +2074,10 @@
 
         generalBroadcaster.addNotificationListener(listener, filter,
                                                    handback);
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(), mth,
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE,
                     "NotificationListener added");
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                        RequiredModelMBean.class.getName(), mth, "Exit");
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
@@ -2227,10 +2099,8 @@
             throw new ListenerNotFoundException(
                       "Notification listener is null");
 
-        final String mth="removeNotificationListener(NotificationListener)";
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-                MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(), mth, "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (generalBroadcaster == null)
@@ -2239,9 +2109,8 @@
 
 
         generalBroadcaster.removeNotificationListener(listener);
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(), mth, "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
     }
@@ -2255,12 +2124,8 @@
             throw new ListenerNotFoundException(
                       "Notification listener is null");
 
-        final String mth = "removeNotificationListener(" +
-                "NotificationListener, NotificationFilter, Object)";
-
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(), mth, "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (generalBroadcaster == null)
@@ -2271,19 +2136,16 @@
         generalBroadcaster.removeNotificationListener(listener,filter,
                                                       handback);
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(), mth, "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
     }
 
     public void sendNotification(Notification ntfyObj)
         throws MBeanException, RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "sendNotification(Notification)", "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (ntfyObj == null)
@@ -2324,10 +2186,8 @@
                             ntfyObj.getMessage() + " Severity = " +
                             (String)ntfyDesc.getFieldValue("severity"));
                     } catch (Exception e) {
-                        if (MODELMBEAN_LOGGER.isLoggable(Level.FINE)) {
-                            MODELMBEAN_LOGGER.logp(Level.FINE,
-                                    RequiredModelMBean.class.getName(),
-                                    "sendNotification(Notification)",
+                        if (MODELMBEAN_LOGGER.isLoggable(Level.DEBUG)) {
+                            MODELMBEAN_LOGGER.log(Level.DEBUG,
                                     "Failed to log " +
                                     ntfyObj.getType() + " notification: ", e);
                         }
@@ -2339,14 +2199,10 @@
             generalBroadcaster.sendNotification(ntfyObj);
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                RequiredModelMBean.class.getName(),
-                    "sendNotification(Notification)",
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                     "sendNotification sent provided notification object");
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                RequiredModelMBean.class.getName(),
-                    "sendNotification(Notification)"," Exit");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
     }
@@ -2354,10 +2210,8 @@
 
     public void sendNotification(String ntfyText)
         throws MBeanException, RuntimeOperationsException {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "sendNotification(String)","Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (ntfyText == null)
@@ -2370,13 +2224,9 @@
         Notification myNtfyObj = new Notification("jmx.modelmbean.generic",
                                                   this, 1, ntfyText);
         sendNotification(myNtfyObj);
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "sendNotification(String)","Notification sent");
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "sendNotification(String)","Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Notification sent");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
@@ -2456,10 +2306,8 @@
      *
      **/
     public MBeanNotificationInfo[] getNotificationInfo() {
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "getNotificationInfo()","Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         // Using hasNotification() is not optimal, but shouldn't really
@@ -2518,10 +2366,8 @@
             respInfo[offset+j] = currInfo[j];
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),
-                "getNotificationInfo()","Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
         return respInfo;
@@ -2535,12 +2381,8 @@
                                                        Object inhandback)
         throws MBeanException, RuntimeOperationsException,
                IllegalArgumentException {
-        final String mth="addAttributeChangeNotificationListener(" +
-                "NotificationListener, String, Object)";
-
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,"Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (inlistener == null)
@@ -2581,24 +2423,21 @@
             }
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
             Vector<String> enabledAttrs = currFilter.getEnabledAttributes();
             String s = (enabledAttrs.size() > 1) ?
                         "[" + enabledAttrs.firstElement() + ", ...]" :
                         enabledAttrs.toString();
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(), mth,
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                 "Set attribute change filter to " + s);
         }
 
         attributeBroadcaster.addNotificationListener(inlistener,currFilter,
                                                      inhandback);
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                     "Notification listener added for " + inAttributeName);
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,"Exit");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
@@ -2609,12 +2448,9 @@
         if (inlistener == null) throw new
             ListenerNotFoundException("Notification listener is null");
 
-        final String mth = "removeAttributeChangeNotificationListener(" +
-                "NotificationListener, String)";
-
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,"Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
+                    RequiredModelMBean.class.getName(), "Entry");
         }
 
 
@@ -2648,21 +2484,17 @@
 
         attributeBroadcaster.removeNotificationListener(inlistener);
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,"Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
     public void sendAttributeChangeNotification(AttributeChangeNotification
                                                 ntfyObj)
         throws MBeanException, RuntimeOperationsException {
-        final String mth = "sendAttributeChangeNotification(" +
-                "AttributeChangeNotification)";
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,"Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         if (ntfyObj == null)
@@ -2678,9 +2510,8 @@
         if (oldv == null) oldv = "null";
         if (newv == null) newv = "null";
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE,
                 "Sending AttributeChangeNotification with " +
                 ntfyObj.getAttributeName() + ntfyObj.getAttributeType() +
                 ntfyObj.getNewValue() + ntfyObj.getOldValue());
@@ -2718,9 +2549,8 @@
                            " Old value = " + oldv +
                            " New value = " + newv);
                     } catch (Exception e) {
-                        if (MODELMBEAN_LOGGER.isLoggable(Level.FINE)) {
-                            MODELMBEAN_LOGGER.logp(Level.FINE,
-                                    RequiredModelMBean.class.getName(),mth,
+                        if (MODELMBEAN_LOGGER.isLoggable(Level.DEBUG)) {
+                            MODELMBEAN_LOGGER.log(Level.DEBUG,
                                 "Failed to log " + ntfyObj.getType() +
                                     " notification: ", e);
                         }
@@ -2744,9 +2574,8 @@
                            " Old value = " + oldv +
                            " New value = " + newv);
                     } catch (Exception e) {
-                        if (MODELMBEAN_LOGGER.isLoggable(Level.FINE)) {
-                            MODELMBEAN_LOGGER.logp(Level.FINE,
-                                    RequiredModelMBean.class.getName(),mth,
+                        if (MODELMBEAN_LOGGER.isLoggable(Level.DEBUG)) {
+                            MODELMBEAN_LOGGER.log(Level.DEBUG,
                                 "Failed to log " + ntfyObj.getType() +
                                     " notification: ", e);
                         }
@@ -2768,25 +2597,17 @@
             generalBroadcaster.sendNotification(ntfyObj);
         }
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,
-                "sent notification");
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,
-                "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "sent notification");
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
     }
 
     public void sendAttributeChangeNotification(Attribute inOldVal,
                                                 Attribute inNewVal)
         throws MBeanException, RuntimeOperationsException {
-        final String mth =
-            "sendAttributeChangeNotification(Attribute, Attribute)";
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,
-                "Entry");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
         }
 
         // do we really want to do this?
@@ -2824,10 +2645,8 @@
 
         sendAttributeChangeNotification(myNtfyObj);
 
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
-            MODELMBEAN_LOGGER.logp(Level.FINER,
-                    RequiredModelMBean.class.getName(),mth,
-                "Exit");
+        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
+            MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
         }
 
     }
--- a/jdk/src/java.management/share/classes/javax/management/monitor/CounterMonitor.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/monitor/CounterMonitor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
 package javax.management.monitor;
 
 import static com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import javax.management.ObjectName;
 import javax.management.MBeanNotificationInfo;
 import static javax.management.monitor.Monitor.NumericalType.*;
@@ -228,8 +228,7 @@
      */
     public synchronized void start() {
         if (isActive()) {
-            MONITOR_LOGGER.logp(Level.FINER, CounterMonitor.class.getName(),
-                    "start", "the monitor is already active");
+            MONITOR_LOGGER.log(Level.TRACE, "the monitor is already active");
             return;
         }
         // Reset values.
@@ -696,7 +695,7 @@
                 }
             }
         } else {
-            if (MONITOR_LOGGER.isLoggable(Level.FINER)) {
+            if (MONITOR_LOGGER.isLoggable(Level.TRACE)) {
                 final StringBuilder strb = new StringBuilder()
                 .append("The notification:")
                 .append("\n\tNotification observed object = ")
@@ -708,8 +707,7 @@
                 .append("\n\tNotification derived gauge = ")
                 .append(o.getDerivedGauge())
                 .append("\nhas already been sent");
-                MONITOR_LOGGER.logp(Level.FINER, CounterMonitor.class.getName(),
-                        "updateNotifications", strb.toString());
+                MONITOR_LOGGER.log(Level.TRACE, strb::toString);
             }
         }
 
@@ -756,9 +754,7 @@
                         break;
                     default:
                         // Should never occur...
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                CounterMonitor.class.getName(),
-                                "updateThreshold",
+                        MONITOR_LOGGER.log(Level.TRACE,
                                 "the threshold type is invalid");
                         break;
                 }
@@ -819,8 +815,7 @@
         case LONG: o.setDerivedGauge(Long.valueOf(derived)); break;
         default:
             // Should never occur...
-            MONITOR_LOGGER.logp(Level.FINEST, CounterMonitor.class.getName(),
-                    "setDerivedGaugeWithDifference",
+            MONITOR_LOGGER.log(Level.TRACE,
                     "the threshold type is invalid");
             break;
         }
--- a/jdk/src/java.management/share/classes/javax/management/monitor/GaugeMonitor.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/monitor/GaugeMonitor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
 package javax.management.monitor;
 
 import static com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import javax.management.MBeanNotificationInfo;
 import javax.management.ObjectName;
 import static javax.management.monitor.Monitor.NumericalType.*;
@@ -224,8 +224,7 @@
      */
     public synchronized void start() {
         if (isActive()) {
-            MONITOR_LOGGER.logp(Level.FINER, GaugeMonitor.class.getName(),
-                    "start", "the monitor is already active");
+            MONITOR_LOGGER.log(Level.TRACE, "the monitor is already active");
             return;
         }
         // Reset values.
@@ -664,8 +663,7 @@
             break;
         default:
             // Should never occur...
-            MONITOR_LOGGER.logp(Level.FINEST, GaugeMonitor.class.getName(),
-                    "setDerivedGaugeWithDifference",
+            MONITOR_LOGGER.log(Level.TRACE,
                     "the threshold type is invalid");
             return;
         }
@@ -698,8 +696,7 @@
             return (greater.doubleValue() >= less.doubleValue());
         default:
             // Should never occur...
-            MONITOR_LOGGER.logp(Level.FINEST, GaugeMonitor.class.getName(),
-                    "isFirstGreaterThanLast",
+            MONITOR_LOGGER.log(Level.TRACE,
                     "the threshold type is invalid");
             return false;
         }
@@ -733,8 +730,7 @@
         }
         else {
             // Should never occur...
-            MONITOR_LOGGER.logp(Level.FINEST, GaugeMonitor.class.getName(),
-                    "isFirstStrictlyGreaterThanLast",
+            MONITOR_LOGGER.log(Level.TRACE,
                     "the threshold type is invalid");
             return false;
         }
--- a/jdk/src/java.management/share/classes/javax/management/monitor/Monitor.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/monitor/Monitor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import javax.management.AttributeNotFoundException;
 import javax.management.InstanceNotFoundException;
 import javax.management.IntrospectionException;
@@ -205,13 +205,11 @@
             try {
                 maximumPoolSizeTmp = Integer.parseInt(maximumPoolSizeStr);
             } catch (NumberFormatException e) {
-                if (MONITOR_LOGGER.isLoggable(Level.FINER)) {
-                    MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(),
-                            "<static initializer>",
+                if (MONITOR_LOGGER.isLoggable(Level.TRACE)) {
+                    MONITOR_LOGGER.log(Level.TRACE,
                             "Wrong value for " + maximumPoolSizeSysProp +
                             " system property", e);
-                    MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(),
-                            "<static initializer>",
+                    MONITOR_LOGGER.log(Level.TRACE,
                             maximumPoolSizeSysProp + " defaults to 10");
                 }
                 maximumPoolSizeTmp = 10;
@@ -391,8 +389,7 @@
     public ObjectName preRegister(MBeanServer server, ObjectName name)
         throws Exception {
 
-        MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(),
-                "preRegister(MBeanServer, ObjectName)",
+        MONITOR_LOGGER.log(Level.TRACE,
                 "initialize the reference on the MBean server");
 
         this.server = server;
@@ -419,8 +416,7 @@
      */
     public void preDeregister() throws Exception {
 
-        MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(),
-                "preDeregister()", "stop the monitor");
+        MONITOR_LOGGER.log(Level.TRACE, "stop the monitor");
 
         // Stop the Monitor.
         //
@@ -693,13 +689,11 @@
      * Starts the monitor.
      */
     void doStart() {
-            MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(),
-                "doStart()", "start the monitor");
+            MONITOR_LOGGER.log(Level.TRACE, "start the monitor");
 
         synchronized (this) {
             if (isActive()) {
-                MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(),
-                        "doStart()", "the monitor is already active");
+                MONITOR_LOGGER.log(Level.TRACE, "the monitor is already active");
                 return;
             }
 
@@ -729,13 +723,11 @@
      * Stops the monitor.
      */
     void doStop() {
-        MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(),
-                "doStop()", "stop the monitor");
+        MONITOR_LOGGER.log(Level.TRACE, "stop the monitor");
 
         synchronized (this) {
             if (!isActive()) {
-                MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(),
-                        "doStop()", "the monitor is not active");
+                MONITOR_LOGGER.log(Level.TRACE, "the monitor is not active");
                 return;
             }
 
@@ -1089,9 +1081,8 @@
         if (!isActive())
             return;
 
-        if (MONITOR_LOGGER.isLoggable(Level.FINER)) {
-            MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(),
-                    "sendNotification", "send notification: " +
+        if (MONITOR_LOGGER.isLoggable(Level.TRACE)) {
+            MONITOR_LOGGER.log(Level.TRACE, "send notification: " +
                     "\n\tNotification observed object = " + object +
                     "\n\tNotification observed attribute = " + observedAttribute +
                     "\n\tNotification derived gauge = " + derGauge);
@@ -1163,8 +1154,7 @@
                     setAlreadyNotified(
                         o, index, OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED, an);
                     msg = "The observed attribute value is null.";
-                    MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                            "monitor", msg);
+                    MONITOR_LOGGER.log(Level.TRACE, msg);
                 }
         } catch (NullPointerException np_ex) {
             if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED))
@@ -1176,10 +1166,8 @@
                     "The monitor must be registered in the MBean " +
                     "server or an MBeanServerConnection must be " +
                     "explicitly supplied.";
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", msg);
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", np_ex.toString());
+                MONITOR_LOGGER.log(Level.TRACE, msg);
+                MONITOR_LOGGER.log(Level.TRACE, np_ex::toString);
             }
         } catch (InstanceNotFoundException inf_ex) {
             if (isAlreadyNotified(o, OBSERVED_OBJECT_ERROR_NOTIFIED))
@@ -1191,10 +1179,8 @@
                 msg =
                     "The observed object must be accessible in " +
                     "the MBeanServerConnection.";
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", msg);
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", inf_ex.toString());
+                MONITOR_LOGGER.log(Level.TRACE, msg);
+                MONITOR_LOGGER.log(Level.TRACE, inf_ex::toString);
             }
         } catch (AttributeNotFoundException anf_ex) {
             if (isAlreadyNotified(o, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED))
@@ -1206,10 +1192,8 @@
                 msg =
                     "The observed attribute must be accessible in " +
                     "the observed object.";
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", msg);
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", anf_ex.toString());
+                MONITOR_LOGGER.log(Level.TRACE, msg);
+                MONITOR_LOGGER.log(Level.TRACE, anf_ex::toString);
             }
         } catch (MBeanException mb_ex) {
             if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED))
@@ -1218,10 +1202,8 @@
                 notifType = RUNTIME_ERROR;
                 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an);
                 msg = mb_ex.getMessage() == null ? "" : mb_ex.getMessage();
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", msg);
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", mb_ex.toString());
+                MONITOR_LOGGER.log(Level.TRACE, msg);
+                MONITOR_LOGGER.log(Level.TRACE, mb_ex::toString);
             }
         } catch (ReflectionException ref_ex) {
             if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) {
@@ -1230,10 +1212,8 @@
                 notifType = RUNTIME_ERROR;
                 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an);
                 msg = ref_ex.getMessage() == null ? "" : ref_ex.getMessage();
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", msg);
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", ref_ex.toString());
+                MONITOR_LOGGER.log(Level.TRACE, msg);
+                MONITOR_LOGGER.log(Level.TRACE, ref_ex::toString);
             }
         } catch (IOException io_ex) {
             if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED))
@@ -1242,10 +1222,8 @@
                 notifType = RUNTIME_ERROR;
                 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an);
                 msg = io_ex.getMessage() == null ? "" : io_ex.getMessage();
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", msg);
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", io_ex.toString());
+                MONITOR_LOGGER.log(Level.TRACE, msg);
+                MONITOR_LOGGER.log(Level.TRACE, io_ex::toString);
             }
         } catch (RuntimeException rt_ex) {
             if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED))
@@ -1254,10 +1232,8 @@
                 notifType = RUNTIME_ERROR;
                 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an);
                 msg = rt_ex.getMessage() == null ? "" : rt_ex.getMessage();
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", msg);
-                MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(),
-                        "monitor", rt_ex.toString());
+                MONITOR_LOGGER.log(Level.TRACE, msg);
+                MONITOR_LOGGER.log(Level.TRACE, rt_ex::toString);
             }
         }
 
@@ -1297,10 +1273,8 @@
                         msg =
                             "The observed attribute value does not " +
                             "implement the Comparable interface.";
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                Monitor.class.getName(), "monitor", msg);
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                Monitor.class.getName(), "monitor", e.toString());
+                        MONITOR_LOGGER.log(Level.TRACE, msg);
+                        MONITOR_LOGGER.log(Level.TRACE, e::toString);
                     }
                 } catch (AttributeNotFoundException e) {
                     if (isAlreadyNotified(o, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED))
@@ -1312,10 +1286,8 @@
                         msg =
                             "The observed attribute must be accessible in " +
                             "the observed object.";
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                Monitor.class.getName(), "monitor", msg);
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                Monitor.class.getName(), "monitor", e.toString());
+                        MONITOR_LOGGER.log(Level.TRACE, msg);
+                        MONITOR_LOGGER.log(Level.TRACE, e::toString);
                     }
                 } catch (RuntimeException e) {
                     if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED))
@@ -1325,10 +1297,8 @@
                         setAlreadyNotified(o, index,
                             RUNTIME_ERROR_NOTIFIED, an);
                         msg = e.getMessage() == null ? "" : e.getMessage();
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                Monitor.class.getName(), "monitor", msg);
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                Monitor.class.getName(), "monitor", e.toString());
+                        MONITOR_LOGGER.log(Level.TRACE, msg);
+                        MONITOR_LOGGER.log(Level.TRACE, e::toString);
                     }
                 }
             }
@@ -1346,8 +1316,7 @@
                         setAlreadyNotified(o, index,
                             OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED, an);
                         msg = "The observed attribute type is not valid.";
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                Monitor.class.getName(), "monitor", msg);
+                        MONITOR_LOGGER.log(Level.TRACE, msg);
                     }
                 }
             }
@@ -1363,8 +1332,7 @@
                         setAlreadyNotified(o, index,
                             THRESHOLD_ERROR_NOTIFIED, an);
                         msg = "The threshold type is not valid.";
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                Monitor.class.getName(), "monitor", msg);
+                        MONITOR_LOGGER.log(Level.TRACE, msg);
                     }
                 }
             }
@@ -1381,8 +1349,7 @@
                         notifType = RUNTIME_ERROR;
                         setAlreadyNotified(o, index,
                             RUNTIME_ERROR_NOTIFIED, an);
-                        MONITOR_LOGGER.logp(Level.FINEST,
-                                Monitor.class.getName(), "monitor", msg);
+                        MONITOR_LOGGER.log(Level.TRACE, msg);
                     }
                 }
             }
--- a/jdk/src/java.management/share/classes/javax/management/monitor/StringMonitor.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/monitor/StringMonitor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
 package javax.management.monitor;
 
 import static com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import javax.management.ObjectName;
 import javax.management.MBeanNotificationInfo;
 import static javax.management.monitor.MonitorNotification.*;
@@ -151,8 +151,7 @@
      */
     public synchronized void start() {
         if (isActive()) {
-            MONITOR_LOGGER.logp(Level.FINER, StringMonitor.class.getName(),
-                    "start", "the monitor is already active");
+            MONITOR_LOGGER.log(Level.TRACE, "the monitor is already active");
             return;
         }
         // Reset values.
--- a/jdk/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
 import javax.management.ObjectName;
 
 import java.util.List;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import java.util.Vector;
 
 /**
@@ -160,14 +160,12 @@
     public MBeanServerNotificationFilter() {
 
         super();
-        RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
-                "MBeanServerNotificationFilter");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         enableType(MBeanServerNotification.REGISTRATION_NOTIFICATION);
         enableType(MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
 
-        RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(),
-                "MBeanServerNotificationFilter");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -181,14 +179,12 @@
      */
     public synchronized void disableAllObjectNames() {
 
-        RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
-                "disableAllObjectNames");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         selectedNames = new Vector<ObjectName>();
         deselectedNames = null;
 
-        RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(),
-                "disableAllObjectNames");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -207,8 +203,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
-                "disableObjectName", objectName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}" + objectName);
 
         // Removes from selected ObjectNames, if present
         if (selectedNames != null) {
@@ -226,8 +221,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(),
-                "disableObjectName");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -236,14 +230,12 @@
      */
     public synchronized void enableAllObjectNames() {
 
-        RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
-                "enableAllObjectNames");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         selectedNames = null;
         deselectedNames = new Vector<ObjectName>();
 
-        RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(),
-                "enableAllObjectNames");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -262,8 +254,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
-                "enableObjectName", objectName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", objectName);
 
         // Removes from deselected ObjectNames, if present
         if (deselectedNames != null) {
@@ -281,8 +272,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(),
-                "enableObjectName");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -349,16 +339,13 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
-                "isNotificationEnabled", notif);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", notif);
 
         // Checks the type first
         String ntfType = notif.getType();
         Vector<String> enabledTypes = getEnabledTypes();
         if (!(enabledTypes.contains(ntfType))) {
-            RELATION_LOGGER.logp(Level.FINER,
-                    MBeanServerNotificationFilter.class.getName(),
-                    "isNotificationEnabled",
+            RELATION_LOGGER.log(Level.TRACE,
                     "Type not selected, exiting");
             return false;
         }
@@ -375,9 +362,7 @@
             // checks for explicit selection
             if (selectedNames.size() == 0) {
                 // All are explicitly not selected
-                RELATION_LOGGER.logp(Level.FINER,
-                        MBeanServerNotificationFilter.class.getName(),
-                        "isNotificationEnabled",
+                RELATION_LOGGER.log(Level.TRACE,
                         "No ObjectNames selected, exiting");
                 return false;
             }
@@ -385,9 +370,7 @@
             isSelectedFlg = selectedNames.contains(objName);
             if (!isSelectedFlg) {
                 // Not in the explicit selected list
-                RELATION_LOGGER.logp(Level.FINER,
-                        MBeanServerNotificationFilter.class.getName(),
-                        "isNotificationEnabled",
+                RELATION_LOGGER.log(Level.TRACE,
                         "ObjectName not in selected list, exiting");
                 return false;
             }
@@ -399,26 +382,20 @@
             if (deselectedNames == null) {
                 // All are implicitly deselected and it is not explicitly
                 // selected
-                RELATION_LOGGER.logp(Level.FINER,
-                        MBeanServerNotificationFilter.class.getName(),
-                        "isNotificationEnabled",
+                RELATION_LOGGER.log(Level.TRACE,
                         "ObjectName not selected, and all " +
                         "names deselected, exiting");
                 return false;
 
             } else if (deselectedNames.contains(objName)) {
                 // Explicitly deselected
-                RELATION_LOGGER.logp(Level.FINER,
-                        MBeanServerNotificationFilter.class.getName(),
-                        "isNotificationEnabled",
+                RELATION_LOGGER.log(Level.TRACE,
                         "ObjectName explicitly not selected, exiting");
                 return false;
             }
         }
 
-        RELATION_LOGGER.logp(Level.FINER,
-                MBeanServerNotificationFilter.class.getName(),
-                "isNotificationEnabled",
+        RELATION_LOGGER.log(Level.TRACE,
                 "ObjectName selected, exiting");
         return true;
     }
--- a/jdk/src/java.management/share/classes/javax/management/relation/RelationService.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/relation/RelationService.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 import javax.management.Attribute;
 import javax.management.AttributeNotFoundException;
@@ -157,13 +157,11 @@
      */
     public RelationService(boolean immediatePurgeFlag) {
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "RelationService");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         setPurgeFlag(immediatePurgeFlag);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "RelationService");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -286,8 +284,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "createRelationType", relationTypeName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
 
         // Can throw an InvalidRelationTypeException
         RelationType relType =
@@ -295,8 +292,7 @@
 
         addRelationTypeInt(relType);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "createRelationType");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -325,8 +321,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "addRelationType");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         // Checks the role infos
         List<RoleInfo> roleInfoList = relationTypeObj.getRoleInfos();
@@ -346,8 +341,7 @@
 
         addRelationTypeInt(relationTypeObj);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "addRelationType");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
      }
 
@@ -385,14 +379,12 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getRoleInfos", relationTypeName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
 
         // Can throw a RelationTypeNotFoundException
         RelationType relType = getRelationType(relationTypeName);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "getRoleInfos");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return relType.getRoleInfos();
     }
 
@@ -421,8 +413,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getRoleInfo", new Object[] {relationTypeName, roleInfoName});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
+                            relationTypeName, roleInfoName);
 
         // Can throw a RelationTypeNotFoundException
         RelationType relType = getRelationType(relationTypeName);
@@ -430,8 +422,7 @@
         // Can throw a RoleInfoNotFoundException
         RoleInfo roleInfo = relType.getRoleInfo(roleInfoName);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "getRoleInfo");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return roleInfo;
     }
 
@@ -461,8 +452,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "removeRelationType", relationTypeName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
 
         // Checks if the relation type to be removed exists
         // Can throw a RelationTypeNotFoundException
@@ -504,8 +494,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "removeRelationType");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -566,9 +555,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "createRelation",
-                new Object[] {relationId, relationTypeName, roleList});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
+                            relationId, relationTypeName, roleList);
 
         // Creates RelationSupport object
         // Can throw InvalidRoleValueException
@@ -588,8 +576,7 @@
                        relationId,
                        relationTypeName,
                        roleList);
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "createRelation");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -654,8 +641,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "addRelation", relationObjectName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationObjectName);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -791,8 +777,7 @@
         newRefList.add(relationObjectName);
         updateUnregistrationListener(newRefList, null);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "addRelation");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -819,8 +804,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "isRelationMBean", relationId);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
 
         // Can throw RelationNotFoundException
         Object result = getRelation(relationId);
@@ -850,8 +834,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "isRelation", objectName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", objectName);
 
         String result = null;
         synchronized(myRelMBeanObjName2RelIdMap) {
@@ -881,8 +864,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "hasRelation", relationId);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
 
         try {
             // Can throw RelationNotFoundException
@@ -933,8 +915,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "checkRoleReading", new Object[] {roleName, relationTypeName});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
+                            roleName, relationTypeName);
 
         Integer result;
 
@@ -956,8 +938,7 @@
             result = Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "checkRoleReading");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -995,9 +976,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "checkRoleWriting",
-                new Object[] {role, relationTypeName, initFlag});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
+                            role, relationTypeName, initFlag);
 
         // Can throw a RelationTypeNotFoundException
         RelationType relType = getRelationType(relationTypeName);
@@ -1013,8 +993,7 @@
         try {
             roleInfo = relType.getRoleInfo(roleName);
         } catch (RoleInfoNotFoundException exc) {
-            RELATION_LOGGER.exiting(RelationService.class.getName(),
-                    "checkRoleWriting");
+            RELATION_LOGGER.log(Level.TRACE, "RETURN");
             return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
         }
 
@@ -1024,8 +1003,7 @@
                                       roleInfo,
                                       writeChkFlag);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "checkRoleWriting");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -1055,8 +1033,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "sendRelationCreationNotification", relationId);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
 
         // Message
         StringBuilder ntfMsg = new StringBuilder("Creation of relation ");
@@ -1071,8 +1048,7 @@
                             null,
                             null);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "sendRelationCreationNotification");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -1114,9 +1090,8 @@
         if (!(oldValue instanceof ArrayList<?>))
             oldValue = new ArrayList<ObjectName>(oldValue);
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "sendRoleUpdateNotification",
-                new Object[] {relationId, newRole, oldValue});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
+                            relationId, newRole, oldValue);
 
         String roleName = newRole.getRoleName();
         List<ObjectName> newRoleVal = newRole.getRoleValue();
@@ -1140,8 +1115,7 @@
                             newRoleVal,
                             oldValue);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "sendRoleUpdateNotification");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
     }
 
     /**
@@ -1172,9 +1146,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "sendRelationRemovalNotification",
-                new Object[] {relationId, unregMBeanList});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
+                            relationId, unregMBeanList);
 
         // Can throw RelationNotFoundException
         sendNotificationInt(3,
@@ -1186,8 +1159,7 @@
                             null);
 
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "sendRelationRemovalNotification");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -1226,8 +1198,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "updateRoleMap", new Object[] {relationId, newRole, oldValue});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
+                            relationId, newRole, oldValue);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -1303,8 +1275,7 @@
         // all ObjectNames of interest
         updateUnregistrationListener(newRefList, obsRefList);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "updateRoleMap");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -1338,8 +1309,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "removeRelation", relationId);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
 
         // Checks there is a relation with this id
         // Can throw RelationNotFoundException
@@ -1442,8 +1412,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "removeRelation");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -1476,8 +1445,7 @@
     public void purgeRelations()
         throws RelationServiceNotRegisteredException {
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "purgeRelations");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -1574,8 +1542,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "purgeRelations");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -1610,9 +1577,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "findReferencingRelations",
-                new Object[] {mbeanName, relationTypeName, roleName});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
+                            mbeanName, relationTypeName, roleName);
 
         Map<String,List<String>> result = new HashMap<String,List<String>>();
 
@@ -1684,8 +1650,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "findReferencingRelations");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -1720,9 +1685,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "findAssociatedMBeans",
-                new Object[] {mbeanName, relationTypeName, roleName});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
+                            mbeanName, relationTypeName, roleName);
 
         // Retrieves the map <relation id> -> <role names> for those
         // criterias
@@ -1769,8 +1733,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "findAssociatedMBeans");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -1794,8 +1757,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "findRelationsOfType");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         // Can throw RelationTypeNotFoundException
         RelationType relType = getRelationType(relationTypeName);
@@ -1809,8 +1771,7 @@
                 result = new ArrayList<String>(result1);
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "findRelationsOfType");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -1845,8 +1806,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getRole", new Object[] {relationId, roleName});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
+                            relationId, roleName);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -1899,7 +1860,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(), "getRole");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -1931,8 +1892,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getRoles", relationId);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -1976,7 +1936,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(), "getRoles");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -2004,8 +1964,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getRoles", relationId);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
 
         // Can throw a RelationNotFoundException
         Object relObj = getRelation(relationId);
@@ -2028,7 +1987,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(), "getRoles");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -2055,8 +2014,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getRoleCardinality", new Object[] {relationId, roleName});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
+                            relationId, roleName);
 
         // Can throw a RelationNotFoundException
         Object relObj = getRelation(relationId);
@@ -2098,8 +2057,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "getRoleCardinality");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -2147,8 +2105,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "setRole", new Object[] {relationId, role});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
+                            relationId, role);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -2211,7 +2169,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(), "setRole");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -2247,8 +2205,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "setRoles", new Object[] {relationId, roleList});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
+                            relationId, roleList);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -2296,7 +2254,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(), "setRoles");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -2322,8 +2280,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getReferencedMBeans", relationId);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}",
+                            relationId);
 
         // Can throw a RelationNotFoundException
         Object relObj = getRelation(relationId);
@@ -2346,8 +2304,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "getReferencedMBeans");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -2371,8 +2328,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getRelationTypeName", relationId);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
 
         // Can throw a RelationNotFoundException
         Object relObj = getRelation(relationId);
@@ -2395,8 +2351,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "getRelationTypeName");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -2421,8 +2376,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "handleNotification", notif);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", notif);
 
         if (notif instanceof MBeanServerNotification) {
 
@@ -2480,8 +2434,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "handleNotification");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -2495,8 +2448,7 @@
      */
     public MBeanNotificationInfo[] getNotificationInfo() {
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getNotificationInfo");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         String ntfClass = "javax.management.relation.RelationNotification";
 
@@ -2514,8 +2466,7 @@
         MBeanNotificationInfo ntfInfo =
             new MBeanNotificationInfo(ntfTypes, ntfClass, ntfDesc);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "getNotificationInfo");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return new MBeanNotificationInfo[] {ntfInfo};
     }
 
@@ -2539,8 +2490,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "addRelationTypeInt");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         String relTypeName = relationTypeObj.getRelationTypeName();
 
@@ -2570,8 +2520,7 @@
             ((RelationTypeSupport)relationTypeObj).setRelationServiceFlag(true);
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "addRelationTypeInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
      }
 
@@ -2595,8 +2544,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getRelationType", relationTypeName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
 
         // No null relation type accepted, so can use get()
         RelationType relType;
@@ -2611,8 +2559,7 @@
             throw new RelationTypeNotFoundException(excMsgStrB.toString());
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "getRelationType");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return relType;
     }
 
@@ -2639,8 +2586,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "getRelation", relationId);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
 
         // No null relation  accepted, so can use get()
         Object rel;
@@ -2653,8 +2599,7 @@
             throw new RelationNotFoundException(excMsg);
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "getRelation");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return rel;
     }
 
@@ -2684,9 +2629,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "addNewMBeanReference",
-                new Object[] {objectName, relationId, roleName});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
+                            objectName, relationId, roleName);
 
         boolean isNewFlag = false;
 
@@ -2739,8 +2683,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "addNewMBeanReference");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return isNewFlag;
     }
 
@@ -2772,9 +2715,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "removeMBeanReference",
-                new Object[] {objectName, relationId, roleName, allRolesFlag});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
+                            objectName, relationId, roleName, allRolesFlag);
 
         boolean noLongerRefFlag = false;
 
@@ -2790,8 +2732,7 @@
 
             if (mbeanRefMap == null) {
                 // The MBean is no longer referenced
-                RELATION_LOGGER.exiting(RelationService.class.getName(),
-                        "removeMBeanReference");
+                RELATION_LOGGER.log(Level.TRACE, "RETURN");
                 return true;
             }
 
@@ -2824,8 +2765,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "removeMBeanReference");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return noLongerRefFlag;
     }
 
@@ -2850,9 +2790,8 @@
             }
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "updateUnregistrationListener",
-                new Object[] {newRefList, obsoleteRefList});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
+                            newRefList, obsoleteRefList);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -2936,8 +2875,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "updateUnregistrationListener");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -3003,9 +2941,10 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "addRelationInt", new Object[] {relationBaseFlag, relationObj,
-                relationObjName, relationId, relationTypeName, roleList});
+        RELATION_LOGGER.log(Level.TRACE,
+                            "ENTRY {0} {1} {2} {3} {4} {5}",
+                            relationBaseFlag, relationObj, relationObjName,
+                            relationId, relationTypeName, roleList);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -3144,8 +3083,7 @@
             // OK : The Relation could not be found.
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "addRelationInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -3185,15 +3123,13 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "checkRoleInt", new Object[] {chkType, roleName,
-                roleValue, roleInfo, writeChkFlag});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4}",
+                            chkType, roleName, roleValue, roleInfo, writeChkFlag);
 
         // Compares names
         String expName = roleInfo.getName();
         if (!(roleName.equals(expName))) {
-            RELATION_LOGGER.exiting(RelationService.class.getName(),
-                    "checkRoleInt");
+            RELATION_LOGGER.log(Level.TRACE, "RETURN");
             return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
         }
 
@@ -3201,13 +3137,11 @@
         if (chkType == 1) {
             boolean isReadable = roleInfo.isReadable();
             if (!isReadable) {
-                RELATION_LOGGER.exiting(RelationService.class.getName(),
-                        "checkRoleInt");
+                RELATION_LOGGER.log(Level.TRACE, "RETURN");
                 return Integer.valueOf(RoleStatus.ROLE_NOT_READABLE);
             } else {
                 // End of check :)
-                RELATION_LOGGER.exiting(RelationService.class.getName(),
-                        "checkRoleInt");
+                RELATION_LOGGER.log(Level.TRACE, "RETURN");
                 return 0;
             }
         }
@@ -3216,8 +3150,7 @@
         if (writeChkFlag) {
             boolean isWritable = roleInfo.isWritable();
             if (!isWritable) {
-                RELATION_LOGGER.exiting(RelationService.class.getName(),
-                        "checkRoleInt");
+                RELATION_LOGGER.log(Level.TRACE, "RETURN");
                 return RoleStatus.ROLE_NOT_WRITABLE;
             }
         }
@@ -3227,16 +3160,14 @@
         // Checks minimum cardinality
         boolean chkMinFlag = roleInfo.checkMinDegree(refNbr);
         if (!chkMinFlag) {
-            RELATION_LOGGER.exiting(RelationService.class.getName(),
-                    "checkRoleInt");
+            RELATION_LOGGER.log(Level.TRACE, "RETURN");
             return RoleStatus.LESS_THAN_MIN_ROLE_DEGREE;
         }
 
         // Checks maximum cardinality
         boolean chkMaxFlag = roleInfo.checkMaxDegree(refNbr);
         if (!chkMaxFlag) {
-            RELATION_LOGGER.exiting(RelationService.class.getName(),
-                    "checkRoleInt");
+            RELATION_LOGGER.log(Level.TRACE, "RETURN");
             return RoleStatus.MORE_THAN_MAX_ROLE_DEGREE;
         }
 
@@ -3252,8 +3183,7 @@
 
             // Checks it is registered
             if (currObjName == null) {
-                RELATION_LOGGER.exiting(RelationService.class.getName(),
-                        "checkRoleInt");
+                RELATION_LOGGER.log(Level.TRACE, "RETURN");
                 return RoleStatus.REF_MBEAN_NOT_REGISTERED;
             }
 
@@ -3263,20 +3193,17 @@
                 boolean classSts = myMBeanServer.isInstanceOf(currObjName,
                                                               expClassName);
                 if (!classSts) {
-                    RELATION_LOGGER.exiting(RelationService.class.getName(),
-                            "checkRoleInt");
+                    RELATION_LOGGER.log(Level.TRACE, "RETURN");
                     return RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS;
                 }
 
             } catch (InstanceNotFoundException exc) {
-                RELATION_LOGGER.exiting(RelationService.class.getName(),
-                        "checkRoleInt");
+                RELATION_LOGGER.log(Level.TRACE, "RETURN");
                 return RoleStatus.REF_MBEAN_NOT_REGISTERED;
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "checkRoleInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return 0;
     }
 
@@ -3328,10 +3255,9 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "initializeMissingRoles", new Object[] {relationBaseFlag,
-                relationObj, relationObjName, relationId, relationTypeName,
-                roleInfoList});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4} {5}",
+                            relationBaseFlag, relationObj, relationObjName,
+                            relationId, relationTypeName, roleInfoList);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -3410,8 +3336,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "initializeMissingRoles");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -3528,9 +3453,9 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "sendNotificationInt", new Object[] {intNtfType, message,
-                relationId, unregMBeanList, roleName, roleNewValue, oldValue});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4} {5} {6}",
+                            intNtfType, message, relationId, unregMBeanList,
+                            roleName, roleNewValue, oldValue);
 
         // Relation type name
         // Note: do not use getRelationTypeName() as if it is a relation MBean
@@ -3616,8 +3541,7 @@
 
         sendNotification(ntf);
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "sendNotificationInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -3654,9 +3578,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationService.class.getName(),
-                "handleReferenceUnregistration",
-                new Object[] {relationId, objectName, roleNameList});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
+                            relationId, objectName, roleNameList);
 
         // Can throw RelationServiceNotRegisteredException
         isActive();
@@ -3782,8 +3705,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationService.class.getName(),
-                "handleReferenceUnregistration");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 }
--- a/jdk/src/java.management/share/classes/javax/management/relation/RelationSupport.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/relation/RelationSupport.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
 
 
 
+import java.lang.System.Logger.Level;
 import java.util.ArrayList;
-
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -162,8 +162,7 @@
 
         super();
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "RelationSupport");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         // Can throw InvalidRoleValueException and IllegalArgumentException
         initMembers(relationId,
@@ -172,8 +171,7 @@
                     relationTypeName,
                     list);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "RelationSupport");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
     }
 
     /**
@@ -239,8 +237,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "RelationSupport");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         // Can throw InvalidRoleValueException and
         // IllegalArgumentException
@@ -250,8 +247,7 @@
                     relationTypeName,
                     list);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "RelationSupport");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
     }
 
     //
@@ -286,15 +282,14 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "getRole", roleName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName);
 
         // Can throw RoleNotFoundException and
         // RelationServiceNotRegisteredException
         List<ObjectName> result = cast(
             getRoleInt(roleName, false, null, false));
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRole");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -324,12 +319,12 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(), "getRoles");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         // Can throw RelationServiceNotRegisteredException
         RoleResult result = getRolesInt(roleNameArray, false, null);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRoles");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -346,8 +341,7 @@
     public RoleResult getAllRoles()
         throws RelationServiceNotRegisteredException {
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "getAllRoles");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         RoleResult result = null;
         try {
@@ -356,7 +350,7 @@
             // OK : Invalid parameters, ignore...
         }
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getAllRoles");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -367,8 +361,7 @@
      */
     public RoleList retrieveAllRoles() {
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "retrieveAllRoles");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         RoleList result;
         synchronized(myRoleName2ValueMap) {
@@ -376,8 +369,7 @@
                 new RoleList(new ArrayList<Role>(myRoleName2ValueMap.values()));
         }
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "retrieveAllRoles");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -400,8 +392,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "getRoleCardinality", roleName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName);
 
         // Try to retrieve the role
         Role role;
@@ -426,8 +417,7 @@
 
         List<ObjectName> roleValue = role.getRoleValue();
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "getRoleCardinality");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return roleValue.size();
     }
 
@@ -476,13 +466,12 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "setRole", role);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", role);
 
         // Will return null :)
         Object result = setRoleInt(role, false, null, false);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRole");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -521,12 +510,11 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "setRoles", list);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", list);
 
         RoleResult result = setRolesInt(list, false, null);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRoles");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -570,9 +558,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "handleMBeanUnregistration",
-                new Object[]{objectName, roleName});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", objectName, roleName);
 
         // Can throw RoleNotFoundException, InvalidRoleValueException,
         // or RelationTypeNotFoundException
@@ -581,8 +567,7 @@
                                      false,
                                      null);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "handleMBeanUnregistration");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -594,8 +579,7 @@
      */
     public Map<ObjectName,List<String>> getReferencedMBeans() {
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "getReferencedMBeans");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         Map<ObjectName,List<String>> refMBeanMap =
             new HashMap<ObjectName,List<String>>();
@@ -628,8 +612,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "getReferencedMBeans");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return refMBeanMap;
     }
 
@@ -779,8 +762,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "getRoleInt", roleName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName);
 
         int pbType = 0;
 
@@ -885,7 +867,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRoleInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -921,8 +903,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "getRolesInt");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         RoleList roleList = new RoleList();
         RoleUnresolvedList roleUnresList = new RoleUnresolvedList();
@@ -966,8 +947,7 @@
         }
 
         RoleResult result = new RoleResult(roleList, roleUnresList);
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "getRolesInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -991,8 +971,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "getAllRolesInt");
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY");
 
         List<String> roleNameList;
         synchronized(myRoleName2ValueMap) {
@@ -1006,8 +985,7 @@
                                         relationServCallFlg,
                                         relationServ);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "getAllRolesInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -1083,9 +1061,9 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "setRoleInt", new Object[] {aRole, relationServCallFlg,
-                relationServ, multiRoleFlg});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
+                            aRole, relationServCallFlg, relationServ,
+                            multiRoleFlg);
 
         String roleName = aRole.getRoleName();
         int pbType = 0;
@@ -1244,7 +1222,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRoleInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -1286,9 +1264,9 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "sendRoleUpdateNotification", new Object[] {newRole,
-                oldRoleValue, relationServCallFlg, relationServ});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
+                            newRole, oldRoleValue, relationServCallFlg,
+                            relationServ);
 
         if (relationServCallFlg) {
             // Direct call to the Relation Service
@@ -1341,8 +1319,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "sendRoleUpdateNotification");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -1383,9 +1360,9 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "updateRelationServiceMap", new Object[] {newRole,
-                oldRoleValue, relationServCallFlg, relationServ});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
+                            newRole, oldRoleValue, relationServCallFlg,
+                            relationServ);
 
         if (relationServCallFlg) {
             // Direct call to the Relation Service
@@ -1433,8 +1410,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "updateRelationServiceMap");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -1484,9 +1460,8 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "setRolesInt",
-                new Object[] {list, relationServCallFlg, relationServ});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
+                            list, relationServCallFlg, relationServ);
 
         RoleList roleList = new RoleList();
         RoleUnresolvedList roleUnresList = new RoleUnresolvedList();
@@ -1534,7 +1509,7 @@
 
         RoleResult result = new RoleResult(roleList, roleUnresList);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRolesInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -1578,9 +1553,9 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "initMembers", new Object[] {relationId, relationServiceName,
-                relationServiceMBeanServer, relationTypeName, list});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4}",
+                            relationId, relationServiceName,
+                            relationServiceMBeanServer, relationTypeName, list);
 
         myRelId = relationId;
         myRelServiceName = relationServiceName;
@@ -1589,7 +1564,7 @@
         // Can throw InvalidRoleValueException
         initRoleMap(list);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initMembers");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -1608,8 +1583,7 @@
             return;
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "initRoleMap", list);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", list);
 
         synchronized(myRoleName2ValueMap) {
 
@@ -1632,7 +1606,7 @@
             }
         }
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initRoleMap");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -1692,9 +1666,9 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationSupport.class.getName(),
-                "handleMBeanUnregistrationInt", new Object[] {objectName,
-                roleName, relationServCallFlg, relationServ});
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
+                            objectName, roleName, relationServCallFlg,
+                            relationServ);
 
         // Retrieves current role value
         Role role;
@@ -1723,8 +1697,7 @@
         Object result =
             setRoleInt(newRole, relationServCallFlg, relationServ, false);
 
-        RELATION_LOGGER.exiting(RelationSupport.class.getName(),
-                "handleMBeanUnregistrationInt");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
--- a/jdk/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 /**
  * A RelationTypeSupport object implements the RelationType interface.
@@ -173,15 +173,13 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationTypeSupport.class.getName(),
-                "RelationTypeSupport", relationTypeName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
 
         // Can throw InvalidRelationTypeException, ClassNotFoundException
         // and NotCompliantMBeanException
         initMembers(relationTypeName, roleInfoArray);
 
-        RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(),
-                "RelationTypeSupport");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -199,13 +197,11 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationTypeSupport.class.getName(),
-                "RelationTypeSupport", relationTypeName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
 
         typeName = relationTypeName;
 
-        RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(),
-                "RelationTypeSupport");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -251,8 +247,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationTypeSupport.class.getName(),
-                "getRoleInfo", roleInfoName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleInfoName);
 
         // No null RoleInfo allowed, so use get()
         RoleInfo result = roleName2InfoMap.get(roleInfoName);
@@ -265,8 +260,7 @@
             throw new RoleInfoNotFoundException(excMsgStrB.toString());
         }
 
-        RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(),
-                "getRoleInfo");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return result;
     }
 
@@ -297,8 +291,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationTypeSupport.class.getName(),
-                "addRoleInfo", roleInfo);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleInfo);
 
         if (isInRelationService) {
             // Trying to update a declared relation type
@@ -319,8 +312,7 @@
 
         roleName2InfoMap.put(roleName, new RoleInfo(roleInfo));
 
-        RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(),
-                "addRoleInfo");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
@@ -351,8 +343,7 @@
             throw new IllegalArgumentException(excMsg);
         }
 
-        RELATION_LOGGER.entering(RelationTypeSupport.class.getName(),
-                "initMembers", relationTypeName);
+        RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
 
         typeName = relationTypeName;
 
@@ -366,8 +357,7 @@
                                  new RoleInfo(currRoleInfo));
         }
 
-        RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(),
-                "initMembers");
+        RELATION_LOGGER.log(Level.TRACE, "RETURN");
         return;
     }
 
--- a/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, 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
@@ -347,7 +347,7 @@
                   +", unwrapping parameters using classLoaderWithRepository.");
 
         values =
-            nullIsEmpty(unwrap(params, classLoaderWithRepository, Object[].class));
+            nullIsEmpty(unwrap(params, classLoaderWithRepository, Object[].class,delegationSubject));
 
         try {
             final Object params2[] =
@@ -411,7 +411,7 @@
         values = nullIsEmpty(unwrap(params,
                                     getClassLoader(loaderName),
                                     defaultClassLoader,
-                                    Object[].class));
+                                    Object[].class,delegationSubject));
 
         try {
             final Object params2[] =
@@ -522,7 +522,7 @@
                  "connectionId=" + connectionId
                  +" unwrapping query with defaultClassLoader.");
 
-        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
+        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject);
 
         try {
             final Object params[] = new Object[] { name, queryValue };
@@ -557,7 +557,7 @@
                  "connectionId=" + connectionId
                  +" unwrapping query with defaultClassLoader.");
 
-        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
+        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject);
 
         try {
             final Object params[] = new Object[] { name, queryValue };
@@ -707,7 +707,7 @@
         attr = unwrap(attribute,
                       getClassLoaderFor(name),
                       defaultClassLoader,
-                      Attribute.class);
+                      Attribute.class, delegationSubject);
 
         try {
             final Object params[] = new Object[] { name, attr };
@@ -758,7 +758,7 @@
             unwrap(attributes,
                    getClassLoaderFor(name),
                    defaultClassLoader,
-                   AttributeList.class);
+                   AttributeList.class, delegationSubject);
 
         try {
             final Object params[] = new Object[] { name, attrlist };
@@ -810,7 +810,7 @@
         values = nullIsEmpty(unwrap(params,
                                     getClassLoaderFor(name),
                                     defaultClassLoader,
-                                    Object[].class));
+                                    Object[].class, delegationSubject));
 
         try {
             final Object params2[] =
@@ -990,7 +990,7 @@
 
                 filterValues[i] =
                     unwrap(filters[i], targetCl, defaultClassLoader,
-                           NotificationFilter.class);
+                           NotificationFilter.class, sbjs[i]);
 
                 if (debug) logger.debug("addNotificationListener"+
                                         "(ObjectName,NotificationFilter)",
@@ -1058,7 +1058,7 @@
                  +" unwrapping filter with target extended ClassLoader.");
 
         filterValue =
-            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class);
+            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class, delegationSubject);
 
         if (debug) logger.debug("addNotificationListener"+
                  "(ObjectName,ObjectName,NotificationFilter,Object)",
@@ -1066,7 +1066,7 @@
                  +" unwrapping handback with target extended ClassLoader.");
 
         handbackValue =
-            unwrap(handback, targetCl, defaultClassLoader, Object.class);
+            unwrap(handback, targetCl, defaultClassLoader, Object.class, delegationSubject);
 
         try {
             final Object params[] =
@@ -1197,7 +1197,7 @@
                  +" unwrapping filter with target extended ClassLoader.");
 
         filterValue =
-            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class);
+            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class, delegationSubject);
 
         if (debug) logger.debug("removeNotificationListener"+
                  "(ObjectName,ObjectName,NotificationFilter,Object)",
@@ -1205,7 +1205,7 @@
                  +" unwrapping handback with target extended ClassLoader.");
 
         handbackValue =
-            unwrap(handback, targetCl, defaultClassLoader, Object.class);
+            unwrap(handback, targetCl, defaultClassLoader, Object.class, delegationSubject);
 
         try {
             final Object params[] =
@@ -1549,20 +1549,38 @@
         }
     }
 
-    private static <T> T unwrap(final MarshalledObject<?> mo,
+    private <T> T unwrap(final MarshalledObject<?> mo,
                                 final ClassLoader cl,
-                                final Class<T> wrappedClass)
+                                final Class<T> wrappedClass,
+                                Subject delegationSubject)
             throws IOException {
         if (mo == null) {
             return null;
         }
         try {
             final ClassLoader old = AccessController.doPrivileged(new SetCcl(cl));
-            try {
-                return wrappedClass.cast(mo.get());
-            } catch (ClassNotFoundException cnfe) {
-                throw new UnmarshalException(cnfe.toString(), cnfe);
-            } finally {
+            try{
+                final AccessControlContext reqACC;
+                if (delegationSubject == null)
+                    reqACC = acc;
+                else {
+                    if (subject == null) {
+                        final String msg =
+                            "Subject delegation cannot be enabled unless " +
+                            "an authenticated subject is put in place";
+                        throw new SecurityException(msg);
+                    }
+                    reqACC = subjectDelegator.delegatedContext(
+                        acc, delegationSubject, removeCallerContext);
+                }
+                if(reqACC != null){
+                    return AccessController.doPrivileged(
+                            (PrivilegedExceptionAction<T>) () ->
+                                    wrappedClass.cast(mo.get()), reqACC);
+                }else{
+                    return wrappedClass.cast(mo.get());
+                }
+            }finally{
                 AccessController.doPrivileged(new SetCcl(old));
             }
         } catch (PrivilegedActionException pe) {
@@ -1575,14 +1593,19 @@
             }
             logger.warning("unwrap", "Failed to unmarshall object: " + e);
             logger.debug("unwrap", e);
+        }catch (ClassNotFoundException ex) {
+            logger.warning("unwrap", "Failed to unmarshall object: " + ex);
+            logger.debug("unwrap", ex);
+            throw new UnmarshalException(ex.toString(), ex);
         }
         return null;
     }
 
-    private static <T> T unwrap(final MarshalledObject<?> mo,
+    private <T> T unwrap(final MarshalledObject<?> mo,
                                 final ClassLoader cl1,
                                 final ClassLoader cl2,
-                                final Class<T> wrappedClass)
+                                final Class<T> wrappedClass,
+                                Subject delegationSubject)
         throws IOException {
         if (mo == null) {
             return null;
@@ -1596,7 +1619,7 @@
                     }
                 }
             );
-            return unwrap(mo, orderCL, wrappedClass);
+            return unwrap(mo, orderCL, wrappedClass,delegationSubject);
         } catch (PrivilegedActionException pe) {
             Exception e = extractException(pe);
             if (e instanceof IOException) {
--- a/jdk/src/java.management/share/classes/javax/management/timer/Timer.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/timer/Timer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.Vector;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 
 // jmx imports
 //
@@ -221,8 +221,7 @@
      */
     public void preDeregister() throws java.lang.Exception {
 
-        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                "preDeregister", "stop the timer");
+        TIMER_LOGGER.log(Level.TRACE, "stop the timer");
 
         // Stop the timer.
         //
@@ -273,8 +272,7 @@
      */
     public synchronized void start() {
 
-        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                "start", "starting the timer");
+        TIMER_LOGGER.log(Level.TRACE, "starting the timer");
 
         // Start the TimerAlarmClock.
         //
@@ -323,11 +321,9 @@
             //
             isActive = true;
 
-            TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                    "start", "timer started");
+            TIMER_LOGGER.log(Level.TRACE, "timer started");
         } else {
-            TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                    "start", "the timer is already activated");
+            TIMER_LOGGER.log(Level.TRACE, "the timer is already activated");
         }
     }
 
@@ -336,8 +332,7 @@
      */
     public synchronized void stop() {
 
-        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                "stop", "stopping the timer");
+        TIMER_LOGGER.log(Level.TRACE, "stopping the timer");
 
         // Stop the TimerAlarmClock.
         //
@@ -370,11 +365,9 @@
             //
             isActive = false;
 
-            TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                    "stop", "timer stopped");
+            TIMER_LOGGER.log(Level.TRACE, "timer stopped");
         } else {
-            TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                    "stop", "the timer is already deactivated");
+            TIMER_LOGGER.log(Level.TRACE, "the timer is already deactivated");
         }
     }
 
@@ -444,9 +437,8 @@
         if (currentDate.after(date)) {
 
             date.setTime(currentDate.getTime());
-            if (TIMER_LOGGER.isLoggable(Level.FINER)) {
-                TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                        "addNotification",
+            if (TIMER_LOGGER.isLoggable(Level.TRACE)) {
+                TIMER_LOGGER.log(Level.TRACE,
                         "update timer notification to add with:" +
                         "\n\tNotification date = " + date);
             }
@@ -486,7 +478,7 @@
         obj[ALARM_CLOCK_INDEX] = (Object)alarmClock;
         obj[FIXED_RATE_INDEX] = Boolean.valueOf(fixedRate);
 
-        if (TIMER_LOGGER.isLoggable(Level.FINER)) {
+        if (TIMER_LOGGER.isLoggable(Level.TRACE)) {
             StringBuilder strb = new StringBuilder()
             .append("adding timer notification:\n\t")
             .append("Notification source = ")
@@ -503,8 +495,7 @@
             .append(nbOccurences)
             .append("\n\tNotification executes at fixed rate = ")
             .append(fixedRate);
-            TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                    "addNotification", strb.toString());
+            TIMER_LOGGER.log(Level.TRACE, strb::toString);
         }
 
         timerTable.put(notifID, obj);
@@ -522,8 +513,7 @@
           }
         }
 
-        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                "addNotification", "timer notification added");
+        TIMER_LOGGER.log(Level.TRACE, "timer notification added");
         return notifID;
     }
 
@@ -677,7 +667,7 @@
 
         // Remove the timer notification from the timer table.
         //
-        if (TIMER_LOGGER.isLoggable(Level.FINER)) {
+        if (TIMER_LOGGER.isLoggable(Level.TRACE)) {
             StringBuilder strb = new StringBuilder()
             .append("removing timer notification:")
             .append("\n\tNotification source = ")
@@ -694,14 +684,12 @@
             .append(obj[TIMER_NB_OCCUR_INDEX])
             .append("\n\tNotification executes at fixed rate = ")
             .append(obj[FIXED_RATE_INDEX]);
-            TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                    "removeNotification", strb.toString());
+            TIMER_LOGGER.log(Level.TRACE, strb::toString);
         }
 
         timerTable.remove(id);
 
-        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                "removeNotification", "timer notification removed");
+        TIMER_LOGGER.log(Level.TRACE, "timer notification removed");
     }
 
     /**
@@ -752,19 +740,16 @@
         }
 
         // Remove all the timer notifications from the timer table.
-        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                "removeAllNotifications", "removing all timer notifications");
+        TIMER_LOGGER.log(Level.TRACE, "removing all timer notifications");
 
         timerTable.clear();
 
-        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                "removeAllNotifications", "all timer notifications removed");
+        TIMER_LOGGER.log(Level.TRACE, "all timer notifications removed");
         // Reset the counterID.
         //
         counterID = 0;
 
-        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                "removeAllNotifications", "timer notification counter ID reset");
+        TIMER_LOGGER.log(Level.TRACE, "timer notification counter ID reset");
     }
 
     // GETTERS AND SETTERS
@@ -1021,7 +1006,7 @@
             while ( (currentDate.after(date)) && (timerTable.containsKey(notifID)) ) {
 
                 if (currentFlag == true) {
-                    if (TIMER_LOGGER.isLoggable(Level.FINER)) {
+                    if (TIMER_LOGGER.isLoggable(Level.TRACE)) {
                         StringBuilder strb = new StringBuilder()
                         .append("sending past timer notification:")
                         .append("\n\tNotification source = ")
@@ -1038,13 +1023,11 @@
                         .append(obj[TIMER_NB_OCCUR_INDEX])
                         .append("\n\tNotification executes at fixed rate = ")
                         .append(obj[FIXED_RATE_INDEX]);
-                        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                                "sendPastNotifications", strb.toString());
+                        TIMER_LOGGER.log(Level.TRACE, strb::toString);
                     }
                     sendNotification(date, notif);
 
-                    TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                            "sendPastNotifications", "past timer notification sent");
+                    TIMER_LOGGER.log(Level.TRACE, "past timer notification sent");
                 }
 
                 // Update the date and the number of occurrences of the timer notification.
@@ -1107,7 +1090,7 @@
                     timer.schedule(alarmClock, alarmClock.timeout);
                   }
                 }
-                if (TIMER_LOGGER.isLoggable(Level.FINER)) {
+                if (TIMER_LOGGER.isLoggable(Level.TRACE)) {
                     TimerNotification notif = (TimerNotification)obj[TIMER_NOTIF_INDEX];
                     StringBuilder strb = new StringBuilder()
                     .append("update timer notification with:")
@@ -1125,8 +1108,7 @@
                     .append(nbOccurences)
                     .append("\n\tNotification executes at fixed rate = ")
                     .append(fixedRate);
-                    TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                            "updateTimerTable", strb.toString());
+                    TIMER_LOGGER.log(Level.TRACE, strb::toString);
                 }
             }
             else {
@@ -1211,7 +1193,7 @@
      */
     void sendNotification(Date timeStamp, TimerNotification notification) {
 
-        if (TIMER_LOGGER.isLoggable(Level.FINER)) {
+        if (TIMER_LOGGER.isLoggable(Level.TRACE)) {
             StringBuilder strb = new StringBuilder()
             .append("sending timer notification:")
             .append("\n\tNotification source = ")
@@ -1222,8 +1204,7 @@
             .append(notification.getNotificationID())
             .append("\n\tNotification date = ")
             .append(timeStamp);
-            TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                    "sendNotification", strb.toString());
+            TIMER_LOGGER.log(Level.TRACE, strb::toString);
         }
         long curSeqNumber;
         synchronized(this) {
@@ -1236,7 +1217,6 @@
             this.sendNotification((TimerNotification)notification.cloneTimerNotification());
         }
 
-        TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(),
-                "sendNotification", "timer notification sent");
+        TIMER_LOGGER.log(Level.TRACE, "timer notification sent");
     }
 }
--- a/jdk/src/java.management/share/classes/javax/management/timer/TimerAlarmClock.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/javax/management/timer/TimerAlarmClock.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
 package javax.management.timer;
 
 import java.util.Date;
-import java.util.logging.Level;
+import java.lang.System.Logger.Level;
 import static com.sun.jmx.defaults.JmxProperties.TIMER_LOGGER;
 
 /**
@@ -73,7 +73,7 @@
             TimerAlarmClockNotification notif = new TimerAlarmClockNotification(this);
             listener.notifyAlarmClock(notif);
         } catch (Exception e) {
-            TIMER_LOGGER.logp(Level.FINEST, Timer.class.getName(), "run",
+            TIMER_LOGGER.log(Level.TRACE,
                     "Got unexpected exception when sending a notification", e);
         }
     }
--- a/jdk/src/java.management/share/classes/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.management/share/classes/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
  */
 module java.management {
     requires transitive java.rmi;
-    requires java.logging;
     requires java.naming;
 
     exports java.lang.management;
@@ -55,4 +54,3 @@
     provides javax.security.auth.spi.LoginModule
         with com.sun.jmx.remote.security.FileLoginModule;
 }
-
--- a/jdk/src/java.rmi/share/classes/java/rmi/MarshalledObject.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.rmi/share/classes/java/rmi/MarshalledObject.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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
@@ -29,11 +29,15 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.ObjectInputFilter;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamConstants;
 import java.io.OutputStream;
 import java.io.Serializable;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 import sun.rmi.server.MarshalInputStream;
 import sun.rmi.server.MarshalOutputStream;
 
@@ -90,6 +94,9 @@
      */
     private int hash;
 
+    /** Filter used when creating the instance from a stream; may be null. */
+    private transient ObjectInputFilter objectInputFilter = null;
+
     /** Indicate compatibility with 1.2 version of class. */
     private static final long serialVersionUID = 8988374069173025854L;
 
@@ -133,9 +140,25 @@
     }
 
     /**
+     * Reads in the state of the object and saves the stream's
+     * serialization filter to be used when the object is deserialized.
+     *
+     * @param stream the stream
+     * @throws IOException if an I/O error occurs
+     * @throws ClassNotFoundException if a class cannot be found
+     */
+    private void readObject(ObjectInputStream stream)
+        throws IOException, ClassNotFoundException {
+        stream.defaultReadObject();     // read in all fields
+        objectInputFilter = stream.getObjectInputFilter();
+    }
+
+    /**
      * Returns a new copy of the contained marshalledobject.  The internal
      * representation is deserialized with the semantics used for
      * unmarshaling parameters for RMI calls.
+     * If the MarshalledObject was read from an ObjectInputStream,
+     * the filter from that stream is used to deserialize the object.
      *
      * @return a copy of the contained object
      * @exception IOException if an <code>IOException</code> occurs while
@@ -155,7 +178,7 @@
         ByteArrayInputStream lin =
             (locBytes == null ? null : new ByteArrayInputStream(locBytes));
         MarshalledObjectInputStream in =
-            new MarshalledObjectInputStream(bin, lin);
+            new MarshalledObjectInputStream(bin, lin, objectInputFilter);
         @SuppressWarnings("unchecked")
         T obj = (T) in.readObject();
         in.close();
@@ -295,11 +318,21 @@
          * <code>null</code>, then all annotations will be
          * <code>null</code>.
          */
-        MarshalledObjectInputStream(InputStream objIn, InputStream locIn)
+        MarshalledObjectInputStream(InputStream objIn, InputStream locIn,
+                    ObjectInputFilter filter)
             throws IOException
         {
             super(objIn);
             this.locIn = (locIn == null ? null : new ObjectInputStream(locIn));
+            if (filter != null) {
+                AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+                    MarshalledObjectInputStream.this.setObjectInputFilter(filter);
+                    if (MarshalledObjectInputStream.this.locIn != null) {
+                        MarshalledObjectInputStream.this.locIn.setObjectInputFilter(filter);
+                    }
+                    return null;
+                });
+            }
         }
 
         /**
--- a/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -25,8 +25,12 @@
 
 package sun.rmi.registry;
 
+import java.io.ObjectInputFilter;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.rmi.server.LogStream;
+import java.security.PrivilegedAction;
+import java.security.Security;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Hashtable;
@@ -39,7 +43,6 @@
 import java.net.*;
 import java.rmi.*;
 import java.rmi.server.ObjID;
-import java.rmi.server.RemoteServer;
 import java.rmi.server.ServerNotActiveException;
 import java.rmi.registry.Registry;
 import java.rmi.server.RMIClientSocketFactory;
@@ -54,12 +57,12 @@
 import java.security.Permissions;
 import java.security.ProtectionDomain;
 import java.text.MessageFormat;
-import sun.rmi.server.LoaderHandler;
+
+import sun.rmi.runtime.Log;
+import sun.rmi.server.UnicastRef;
 import sun.rmi.server.UnicastServerRef;
 import sun.rmi.server.UnicastServerRef2;
 import sun.rmi.transport.LiveRef;
-import sun.rmi.transport.ObjectTable;
-import sun.rmi.transport.Target;
 
 /**
  * A "registry" exists on every node that allows RMI connections to
@@ -91,6 +94,48 @@
     private static ResourceBundle resources = null;
 
     /**
+     * Property name of the RMI Registry serial filter to augment
+     * the built-in list of allowed types.
+     * Setting the property in the {@code conf/security/java.security} file
+     * will enable the augmented filter.
+     */
+    private static final String REGISTRY_FILTER_PROPNAME = "sun.rmi.registry.registryFilter";
+
+    /** Registry max depth of remote invocations. **/
+    private static int REGISTRY_MAX_DEPTH = 5;
+
+    /** Registry maximum array size in remote invocations. **/
+    private static int REGISTRY_MAX_ARRAY_SIZE = 10000;
+
+    /**
+     * The registryFilter created from the value of the {@code "sun.rmi.registry.registryFilter"}
+     * property.
+     */
+    private static final ObjectInputFilter registryFilter =
+            AccessController.doPrivileged((PrivilegedAction<ObjectInputFilter>)RegistryImpl::initRegistryFilter);
+
+    /**
+     * Initialize the registryFilter from the security properties or system property; if any
+     * @return an ObjectInputFilter, or null
+     */
+    @SuppressWarnings("deprecation")
+    private static ObjectInputFilter initRegistryFilter() {
+        ObjectInputFilter filter = null;
+        String props = System.getProperty(REGISTRY_FILTER_PROPNAME);
+        if (props == null) {
+            props = Security.getProperty(REGISTRY_FILTER_PROPNAME);
+        }
+        if (props != null) {
+            filter = ObjectInputFilter.Config.createFilter(props);
+            Log regLog = Log.getLog("sun.rmi.registry", "registry", -1);
+            if (regLog.isLoggable(Log.BRIEF)) {
+                regLog.log(Log.BRIEF, "registryFilter = " + filter);
+            }
+        }
+        return filter;
+    }
+
+    /**
      * Construct a new RegistryImpl on the specified port with the
      * given custom socket factory pair.
      */
@@ -105,7 +150,7 @@
                 AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                     public Void run() throws RemoteException {
                         LiveRef lref = new LiveRef(id, port, csf, ssf);
-                        setup(new UnicastServerRef2(lref));
+                        setup(new UnicastServerRef2(lref, RegistryImpl::registryFilter));
                         return null;
                     }
                 }, null, new SocketPermission("localhost:"+port, "listen,accept"));
@@ -114,7 +159,7 @@
             }
         } else {
             LiveRef lref = new LiveRef(id, port, csf, ssf);
-            setup(new UnicastServerRef2(lref));
+            setup(new UnicastServerRef2(lref, RegistryImpl::registryFilter));
         }
     }
 
@@ -130,7 +175,7 @@
                 AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                     public Void run() throws RemoteException {
                         LiveRef lref = new LiveRef(id, port);
-                        setup(new UnicastServerRef(lref));
+                        setup(new UnicastServerRef(lref, RegistryImpl::registryFilter));
                         return null;
                     }
                 }, null, new SocketPermission("localhost:"+port, "listen,accept"));
@@ -139,7 +184,7 @@
             }
         } else {
             LiveRef lref = new LiveRef(id, port);
-            setup(new UnicastServerRef(lref));
+            setup(new UnicastServerRef(lref, RegistryImpl::registryFilter));
         }
     }
 
@@ -362,6 +407,60 @@
     }
 
     /**
+     * ObjectInputFilter to filter Registry input objects.
+     * The list of acceptable classes is limited to classes normally
+     * stored in a registry.
+     *
+     * @param filterInfo access to the class, array length, etc.
+     * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
+     *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
+     *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
+     */
+    private static ObjectInputFilter.Status registryFilter(ObjectInputFilter.FilterInfo filterInfo) {
+        if (registryFilter != null) {
+            ObjectInputFilter.Status status = registryFilter.checkInput(filterInfo);
+            if (status != ObjectInputFilter.Status.UNDECIDED) {
+                // The Registry filter can override the built-in white-list
+                return status;
+            }
+        }
+
+        if (filterInfo.depth() > REGISTRY_MAX_DEPTH) {
+            return ObjectInputFilter.Status.REJECTED;
+        }
+        Class<?> clazz = filterInfo.serialClass();
+        if (clazz != null) {
+            if (clazz.isArray()) {
+                if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > REGISTRY_MAX_ARRAY_SIZE) {
+                    return ObjectInputFilter.Status.REJECTED;
+                }
+                do {
+                    // Arrays are allowed depending on the component type
+                    clazz = clazz.getComponentType();
+                } while (clazz.isArray());
+            }
+            if (clazz.isPrimitive()) {
+                // Arrays of primitives are allowed
+                return ObjectInputFilter.Status.ALLOWED;
+            }
+            if (String.class == clazz
+                    || java.lang.Number.class.isAssignableFrom(clazz)
+                    || Remote.class.isAssignableFrom(clazz)
+                    || java.lang.reflect.Proxy.class.isAssignableFrom(clazz)
+                    || UnicastRef.class.isAssignableFrom(clazz)
+                    || RMIClientSocketFactory.class.isAssignableFrom(clazz)
+                    || RMIServerSocketFactory.class.isAssignableFrom(clazz)
+                    || java.rmi.activation.ActivationID.class.isAssignableFrom(clazz)
+                    || java.rmi.server.UID.class.isAssignableFrom(clazz)) {
+                return ObjectInputFilter.Status.ALLOWED;
+            } else {
+                return ObjectInputFilter.Status.REJECTED;
+            }
+        }
+        return ObjectInputFilter.Status.UNDECIDED;
+    }
+
+    /**
      * Return a new RegistryImpl on the requested port and export it to serve
      * registry requests. A classloader is initialized from the system property
      * "env.class.path" and a security manager is set unless one is already set.
--- a/jdk/src/java.rmi/share/classes/sun/rmi/runtime/Log.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/runtime/Log.java	Tue Jan 24 00:30:25 2017 +0100
@@ -232,6 +232,11 @@
             }
         }
 
+        public String toString() {
+            return logger.toString() + ", level: " + logger.getLevel() +
+                    ", name: " + logger.getName();
+        }
+
         /**
          * Set the output stream associated with the RMI server call
          * logger.
--- a/jdk/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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 @@
  */
 package sun.rmi.transport;
 
+import java.io.ObjectInputFilter;
 import java.net.SocketPermission;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
@@ -34,11 +35,13 @@
 import java.rmi.server.ObjID;
 import java.rmi.server.RemoteServer;
 import java.rmi.server.ServerNotActiveException;
+import java.rmi.server.UID;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.Permissions;
 import java.security.PrivilegedAction;
 import java.security.ProtectionDomain;
+import java.security.Security;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.HashMap;
@@ -100,6 +103,46 @@
     }
 
     /**
+     * Property name of the DGC serial filter to augment
+     * the built-in list of allowed types.
+     * Setting the property in the {@code conf/security/java.security} file
+     * or system property will enable the augmented filter.
+     */
+    private static final String DGC_FILTER_PROPNAME = "sun.rmi.transport.dgcFilter";
+
+    /** Registry max depth of remote invocations. **/
+    private static int DGC_MAX_DEPTH = 5;
+
+    /** Registry maximum array size in remote invocations. **/
+    private static int DGC_MAX_ARRAY_SIZE = 10000;
+
+    /**
+     * The dgcFilter created from the value of the {@code  "sun.rmi.transport.dgcFilter"}
+     * property.
+     */
+    private static final ObjectInputFilter dgcFilter =
+            AccessController.doPrivileged((PrivilegedAction<ObjectInputFilter>)DGCImpl::initDgcFilter);
+
+    /**
+     * Initialize the dgcFilter from the security properties or system property; if any
+     * @return an ObjectInputFilter, or null
+     */
+    private static ObjectInputFilter initDgcFilter() {
+        ObjectInputFilter filter = null;
+        String props = System.getProperty(DGC_FILTER_PROPNAME);
+        if (props == null) {
+            props = Security.getProperty(DGC_FILTER_PROPNAME);
+        }
+        if (props != null) {
+            filter = ObjectInputFilter.Config.createFilter(props);
+            if (dgcLog.isLoggable(Log.BRIEF)) {
+                dgcLog.log(Log.BRIEF, "dgcFilter = " + filter);
+            }
+        }
+        return filter;
+    }
+
+    /**
      * Construct a new server-side remote object collector at
      * a particular port. Disallow construction from outside.
      */
@@ -293,7 +336,8 @@
                         dgc = new DGCImpl();
                         ObjID dgcID = new ObjID(ObjID.DGC_ID);
                         LiveRef ref = new LiveRef(dgcID, 0);
-                        UnicastServerRef disp = new UnicastServerRef(ref);
+                        UnicastServerRef disp = new UnicastServerRef(ref,
+                                DGCImpl::checkInput);
                         Remote stub =
                             Util.createProxy(DGCImpl.class,
                                              new UnicastRef(ref), true);
@@ -324,6 +368,53 @@
         });
     }
 
+    /**
+     * ObjectInputFilter to filter DGC input objects.
+     * The list of acceptable classes is very short and explicit.
+     * The depth and array sizes are limited.
+     *
+     * @param filterInfo access to class, arrayLength, etc.
+     * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
+     *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
+     *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
+     */
+    private static ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
+        if (dgcFilter != null) {
+            ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo);
+            if (status != ObjectInputFilter.Status.UNDECIDED) {
+                // The DGC filter can override the built-in white-list
+                return status;
+            }
+        }
+
+        if (filterInfo.depth() > DGC_MAX_DEPTH) {
+            return ObjectInputFilter.Status.REJECTED;
+        }
+        Class<?> clazz = filterInfo.serialClass();
+        if (clazz != null) {
+            while (clazz.isArray()) {
+                if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) {
+                    return ObjectInputFilter.Status.REJECTED;
+                }
+                // Arrays are allowed depending on the component type
+                clazz = clazz.getComponentType();
+            }
+            if (clazz.isPrimitive()) {
+                // Arrays of primitives are allowed
+                return ObjectInputFilter.Status.ALLOWED;
+            }
+            return (clazz == ObjID.class ||
+                    clazz == UID.class ||
+                    clazz == VMID.class ||
+                    clazz == Lease.class)
+                    ? ObjectInputFilter.Status.ALLOWED
+                    : ObjectInputFilter.Status.REJECTED;
+        }
+        // Not a class, not size limited
+        return ObjectInputFilter.Status.UNDECIDED;
+    }
+
+
     private static class LeaseInfo {
         VMID vmid;
         long expiration;
--- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,9 @@
 import java.math.*;
 import java.util.*;
 import java.text.*;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 import javax.sql.rowset.*;
 import javax.sql.rowset.spi.*;
@@ -357,8 +360,16 @@
         }
 
         // set the Reader, this maybe overridden latter
-        provider =
-        SyncFactory.getInstance(DEFAULT_SYNC_PROVIDER);
+        try {
+            provider = AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
+                @Override
+                public SyncProvider run() throws SyncFactoryException {
+                    return SyncFactory.getInstance(DEFAULT_SYNC_PROVIDER);
+                }
+            }, null, new RuntimePermission("accessClassInPackage.com.sun.rowset.providers"));
+        } catch (PrivilegedActionException pae) {
+            throw (SyncFactoryException) pae.getException();
+        }
 
         if (!(provider instanceof RIOptimisticProvider)) {
             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidp").toString());
--- a/jdk/src/java.sql/share/classes/java/sql/Timestamp.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.sql/share/classes/java/sql/Timestamp.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -259,7 +259,7 @@
     /**
      * Formats a timestamp in JDBC timestamp escape format.
      *         {@code yyyy-mm-dd hh:mm:ss.fffffffff},
-     * where {@code ffffffffff} indicates nanoseconds.
+     * where {@code fffffffff} indicates nanoseconds.
      *
      * @return a {@code String} object in
      *           {@code yyyy-mm-dd hh:mm:ss.fffffffff} format
--- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java	Tue Jan 24 00:30:25 2017 +0100
@@ -21,7 +21,7 @@
  * under the License.
  */
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * $Id: DOMSignatureMethod.java 1333415 2012-05-03 12:03:51Z coheigea $
@@ -41,6 +41,7 @@
 import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA;
 import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
 import org.jcp.xml.dsig.internal.SignerOutputStream;
+import sun.security.util.KeyUtil;
 
 /**
  * DOM-based abstract implementation of SignatureMethod.
@@ -207,6 +208,7 @@
         if (!(key instanceof PublicKey)) {
             throw new InvalidKeyException("key must be PublicKey");
         }
+        checkKeySize(context, key);
         if (signature == null) {
             Provider p = (Provider)context.getProperty(
                     "org.jcp.xml.dsig.internal.dom.SignatureProvider");
@@ -234,6 +236,37 @@
         return signature.verify(s);
     }
 
+    /**
+     * If secure validation mode is enabled, checks that the key size is
+     * restricted.
+     *
+     * @param context the context
+     * @param key the key to check
+     * @throws XMLSignatureException if the key size is restricted
+     */
+    private static void checkKeySize(XMLCryptoContext context, Key key)
+        throws XMLSignatureException {
+        if (Utils.secureValidation(context)) {
+            int size = KeyUtil.getKeySize(key);
+            if (size == -1) {
+                // key size cannot be determined, so we cannot check against
+                // restrictions. Note that a DSA key w/o params will be
+                // rejected later if the certificate chain is validated.
+                if (log.isLoggable(java.util.logging.Level.FINE)) {
+                    log.log(java.util.logging.Level.FINE, "Size for " +
+                            key.getAlgorithm() + " key cannot be determined");
+                }
+                return;
+            }
+            if (Policy.restrictKey(key.getAlgorithm(), size)) {
+                throw new XMLSignatureException(key.getAlgorithm() +
+                    " keys less than " +
+                    Policy.minKeySize(key.getAlgorithm()) + " bits are" +
+                    " forbidden when secure validation is enabled");
+            }
+        }
+    }
+
     byte[] sign(Key key, SignedInfo si, XMLSignContext context)
         throws InvalidKeyException, XMLSignatureException
     {
@@ -244,6 +277,7 @@
         if (!(key instanceof PrivateKey)) {
             throw new InvalidKeyException("key must be PrivateKey");
         }
+        checkKeySize(context, key);
         if (signature == null) {
             Provider p = (Provider)context.getProperty(
                     "org.jcp.xml.dsig.internal.dom.SignatureProvider");
--- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Policy.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Policy.java	Tue Jan 24 00:30:25 2017 +0100
@@ -31,8 +31,10 @@
 import java.security.PrivilegedAction;
 import java.security.Security;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -46,6 +48,7 @@
     private static int maxTrans = Integer.MAX_VALUE;
     private static int maxRefs = Integer.MAX_VALUE;
     private static Set<String> disallowedRefUriSchemes = new HashSet<>();
+    private static Map<String, Integer> minKeyMap = new HashMap<>();
     private static boolean noDuplicateIds = false;
     private static boolean noRMLoops = false;
 
@@ -101,6 +104,13 @@
                             scheme.toLowerCase(Locale.ROOT));
                     }
                     break;
+                case "minKeySize":
+                    if (tokens.length != 3) {
+                        error(entry);
+                    }
+                    minKeyMap.put(tokens[1],
+                                  Integer.parseUnsignedInt(tokens[2]));
+                    break;
                 case "noDuplicateIds":
                     if (tokens.length != 1) {
                         error(entry);
@@ -147,6 +157,10 @@
         return false;
     }
 
+    public static boolean restrictKey(String type, int size) {
+        return (size < minKeyMap.getOrDefault(type, 0));
+    }
+
     public static boolean restrictDuplicateIds() {
         return noDuplicateIds;
     }
@@ -171,6 +185,10 @@
         return Collections.<String>unmodifiableSet(disallowedRefUriSchemes);
     }
 
+    public static int minKeySize(String type) {
+        return minKeyMap.getOrDefault(type, 0);
+    }
+
     private static void error(String entry) {
         throw new IllegalArgumentException(
             "Invalid jdk.xml.dsig.secureValidationPolicy entry: " + entry);
--- a/jdk/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java	Tue Jan 24 00:30:25 2017 +0100
@@ -455,18 +455,22 @@
     }
 
     // Convert the DER encoding of R and S into a concatenation of R and S
-    private byte[] decodeSignature(byte[] signature) throws SignatureException {
+    private byte[] decodeSignature(byte[] sig) throws SignatureException {
 
         try {
-            DerInputStream in = new DerInputStream(signature);
+            // Enforce strict DER checking for signatures
+            DerInputStream in = new DerInputStream(sig, 0, sig.length, false);
             DerValue[] values = in.getSequence(2);
+
+            // check number of components in the read sequence
+            // and trailing data
+            if ((values.length != 2) || (in.available() != 0)) {
+                throw new IOException("Invalid encoding for signature");
+            }
+
             BigInteger r = values[0].getPositiveBigInteger();
             BigInteger s = values[1].getPositiveBigInteger();
 
-            // Check for trailing signature data
-            if (in.available() != 0) {
-                throw new IOException("Incorrect signature length");
-            }
             // trim leading zeroes
             byte[] rBytes = trimZeroes(r.toByteArray());
             byte[] sBytes = trimZeroes(s.toByteArray());
@@ -480,7 +484,7 @@
             return result;
 
         } catch (Exception e) {
-            throw new SignatureException("Could not decode signature", e);
+            throw new SignatureException("Invalid encoding for signature", e);
         }
     }
 
--- a/jdk/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c	Tue Jan 24 00:30:25 2017 +0100
@@ -34,7 +34,7 @@
  *   Dr Vipul Gupta <vipul.gupta@sun.com> and
  *   Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
  *
- * Last Modified Date from the Original Code: Nov 2016
+ * Last Modified Date from the Original Code: November 2016
  *********************************************************************** */
 
 #include "mplogic.h"
@@ -715,6 +715,16 @@
     }
 
     /*
+     * Using an equivalent exponent of fixed length (same as n or 1 bit less
+     * than n) to keep the kG timing relatively constant.
+     *
+     * Note that this is an extra step on top of the approach defined in
+     * ANSI X9.62 so as to make a fixed length K.
+     */
+    CHECK_MPI_OK( mp_add(&k, &n, &k) );
+    CHECK_MPI_OK( mp_div_2(&k, &k) );
+
+    /*
     ** ANSI X9.62, Section 5.3.2, Step 2
     **
     ** Compute kG
--- a/jdk/src/jdk.crypto.token/share/classes/sun/security/pkcs11/P11Signature.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.crypto.token/share/classes/sun/security/pkcs11/P11Signature.java	Tue Jan 24 00:30:25 2017 +0100
@@ -740,17 +740,21 @@
         }
     }
 
-    private static byte[] asn1ToDSA(byte[] signature) throws SignatureException {
+    private static byte[] asn1ToDSA(byte[] sig) throws SignatureException {
         try {
-            DerInputStream in = new DerInputStream(signature);
+            // Enforce strict DER checking for signatures
+            DerInputStream in = new DerInputStream(sig, 0, sig.length, false);
             DerValue[] values = in.getSequence(2);
+
+            // check number of components in the read sequence
+            // and trailing data
+            if ((values.length != 2) || (in.available() != 0)) {
+                throw new IOException("Invalid encoding for signature");
+            }
+
             BigInteger r = values[0].getPositiveBigInteger();
             BigInteger s = values[1].getPositiveBigInteger();
 
-            // Check for trailing signature data
-            if (in.available() != 0) {
-                throw new IOException("Incorrect signature length");
-            }
             byte[] br = toByteArray(r, 20);
             byte[] bs = toByteArray(s, 20);
             if ((br == null) || (bs == null)) {
@@ -760,21 +764,25 @@
         } catch (SignatureException e) {
             throw e;
         } catch (Exception e) {
-            throw new SignatureException("invalid encoding for signature", e);
+            throw new SignatureException("Invalid encoding for signature", e);
         }
     }
 
-    private byte[] asn1ToECDSA(byte[] signature) throws SignatureException {
+    private byte[] asn1ToECDSA(byte[] sig) throws SignatureException {
         try {
-            DerInputStream in = new DerInputStream(signature);
+            // Enforce strict DER checking for signatures
+            DerInputStream in = new DerInputStream(sig, 0, sig.length, false);
             DerValue[] values = in.getSequence(2);
+
+            // check number of components in the read sequence
+            // and trailing data
+            if ((values.length != 2) || (in.available() != 0)) {
+                throw new IOException("Invalid encoding for signature");
+            }
+
             BigInteger r = values[0].getPositiveBigInteger();
             BigInteger s = values[1].getPositiveBigInteger();
 
-            // Check for trailing signature data
-            if (in.available() != 0) {
-                throw new IOException("Incorrect signature length");
-            }
             // trim leading zeroes
             byte[] br = KeyUtil.trimZeroes(r.toByteArray());
             byte[] bs = KeyUtil.trimZeroes(s.toByteArray());
@@ -785,7 +793,7 @@
             System.arraycopy(bs, 0, res, res.length - bs.length, bs.length);
             return res;
         } catch (Exception e) {
-            throw new SignatureException("invalid encoding for signature", e);
+            throw new SignatureException("Invalid encoding for signature", e);
         }
     }
 
--- a/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp	Tue Jan 24 00:30:25 2017 +0100
@@ -102,26 +102,26 @@
 
 JNIEXPORT jint JNICALL Java_jdk_internal_jline_WindowsTerminal_getWindowsTerminalWidth
   (JNIEnv *, jobject) {
-    HANDLE hStdIn;
-    if ((hStdIn = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) {
+    HANDLE hStdOut;
+    if ((hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)) == INVALID_HANDLE_VALUE) {
         return -1;
     }
     CONSOLE_SCREEN_BUFFER_INFO info;
-    if (! GetConsoleScreenBufferInfo(hStdIn, &info)) {
+    if (! GetConsoleScreenBufferInfo(hStdOut, &info)) {
         return -1;
     }
-    return info.dwSize.X;
+    return info.srWindow.Right - info.srWindow.Left;
 }
 
 JNIEXPORT jint JNICALL Java_jdk_internal_jline_WindowsTerminal_getWindowsTerminalHeight
   (JNIEnv *, jobject) {
-    HANDLE hStdIn;
-    if ((hStdIn = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) {
+    HANDLE hStdOut;
+    if ((hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)) == INVALID_HANDLE_VALUE) {
         return -1;
     }
     CONSOLE_SCREEN_BUFFER_INFO info;
-    if (! GetConsoleScreenBufferInfo(hStdIn, &info)) {
+    if (! GetConsoleScreenBufferInfo(hStdOut, &info)) {
         return -1;
     }
-    return info.dwSize.Y;
+    return info.srWindow.Bottom - info.srWindow.Top + 1;
 }
--- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Tue Jan 24 00:30:25 2017 +0100
@@ -26,6 +26,8 @@
 package sun.security.tools.jarsigner;
 
 import java.io.*;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.PKIXBuilderParameters;
 import java.util.*;
 import java.util.zip.*;
 import java.util.jar.*;
@@ -40,11 +42,9 @@
 import java.net.SocketTimeoutException;
 import java.net.URL;
 import java.security.cert.CertPath;
-import java.security.cert.CertPathValidator;
 import java.security.cert.CertificateExpiredException;
 import java.security.cert.CertificateFactory;
 import java.security.cert.CertificateNotYetValidException;
-import java.security.cert.PKIXParameters;
 import java.security.cert.TrustAnchor;
 import java.util.Map.Entry;
 
@@ -54,6 +54,8 @@
 import sun.security.pkcs.SignerInfo;
 import sun.security.timestamp.TimestampToken;
 import sun.security.tools.KeyStoreUtil;
+import sun.security.validator.Validator;
+import sun.security.validator.ValidatorException;
 import sun.security.x509.*;
 import sun.security.util.*;
 
@@ -177,9 +179,7 @@
 
     private boolean seeWeak = false;
 
-    CertificateFactory certificateFactory;
-    CertPathValidator validator;
-    PKIXParameters pkixParameters;
+    PKIXBuilderParameters pkixParameters;
 
     public void run(String args[]) {
         try {
@@ -1623,19 +1623,10 @@
         try {
             validateCertChain(certs);
         } catch (Exception e) {
-            if (debug) {
-                e.printStackTrace();
-            }
-            if (e.getCause() != null &&
-                    (e.getCause() instanceof CertificateExpiredException ||
-                     e.getCause() instanceof CertificateNotYetValidException)) {
-                // No more warning, we alreay have hasExpiredCert or notYetValidCert
-            } else {
-                chainNotValidated = true;
-                chainNotValidatedReason = e;
-                sb.append(tab).append(rb.getString(".CertPath.not.validated."))
-                        .append(e.getLocalizedMessage()).append("]\n"); // TODO
-            }
+            chainNotValidated = true;
+            chainNotValidatedReason = e;
+            sb.append(tab).append(rb.getString(".CertPath.not.validated."))
+                    .append(e.getLocalizedMessage()).append("]\n"); // TODO
         }
         if (certs.size() == 1
                 && KeyStoreUtil.isSelfSigned((X509Certificate)certs.get(0))) {
@@ -1654,9 +1645,6 @@
         }
 
         try {
-
-            certificateFactory = CertificateFactory.getInstance("X.509");
-            validator = CertPathValidator.getInstance("PKIX");
             Set<TrustAnchor> tas = new HashSet<>();
             try {
                 KeyStore caks = KeyStoreUtil.getCacertsKeyStore();
@@ -1732,7 +1720,7 @@
                 }
             } finally {
                 try {
-                    pkixParameters = new PKIXParameters(tas);
+                    pkixParameters = new PKIXBuilderParameters(tas, null);
                     pkixParameters.setRevocationEnabled(false);
                 } catch (InvalidAlgorithmParameterException ex) {
                     // Only if tas is empty
@@ -1899,17 +1887,8 @@
             try {
                 validateCertChain(Arrays.asList(certChain));
             } catch (Exception e) {
-                if (debug) {
-                    e.printStackTrace();
-                }
-                if (e.getCause() != null &&
-                        (e.getCause() instanceof CertificateExpiredException ||
-                        e.getCause() instanceof CertificateNotYetValidException)) {
-                    // No more warning, we already have hasExpiredCert or notYetValidCert
-                } else {
-                    chainNotValidated = true;
-                    chainNotValidatedReason = e;
-                }
+                chainNotValidated = true;
+                chainNotValidatedReason = e;
             }
 
             if (KeyStoreUtil.isSelfSigned(certChain[0])) {
@@ -1966,18 +1945,40 @@
     }
 
     void validateCertChain(List<? extends Certificate> certs) throws Exception {
-        int cpLen = 0;
-        out: for (; cpLen<certs.size(); cpLen++) {
-            for (TrustAnchor ta: pkixParameters.getTrustAnchors()) {
-                if (ta.getTrustedCert().equals(certs.get(cpLen))) {
-                    break out;
+        try {
+            Validator.getInstance(Validator.TYPE_PKIX,
+                    Validator.VAR_CODE_SIGNING,
+                    pkixParameters)
+                    .validate(certs.toArray(new X509Certificate[certs.size()]));
+        } catch (Exception e) {
+            if (debug) {
+                e.printStackTrace();
+            }
+            if (e instanceof ValidatorException) {
+                // Throw cause if it's CertPathValidatorException,
+                if (e.getCause() != null &&
+                        e.getCause() instanceof CertPathValidatorException) {
+                    e = (Exception) e.getCause();
+                    Throwable t = e.getCause();
+                    if ((t instanceof CertificateExpiredException &&
+                                hasExpiredCert) ||
+                            (t instanceof CertificateNotYetValidException &&
+                                    notYetValidCert)) {
+                        // we already have hasExpiredCert and notYetValidCert
+                        return;
+                    }
+                }
+                if (e instanceof ValidatorException) {
+                    ValidatorException ve = (ValidatorException)e;
+                    if (ve.getErrorType() == ValidatorException.T_EE_EXTENSIONS &&
+                            (badKeyUsage || badExtendedKeyUsage || badNetscapeCertType)) {
+                        // We already have badKeyUsage, badExtendedKeyUsage
+                        // and badNetscapeCertType
+                        return;
+                    }
                 }
             }
-        }
-        if (cpLen > 0) {
-            CertPath cp = certificateFactory.generateCertPath(
-                    (cpLen == certs.size())? certs: certs.subList(0, cpLen));
-            validator.validate(cp, pkixParameters);
+            throw e;
         }
     }
 
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,8 @@
 import java.nio.file.Paths;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
+
+import jdk.internal.module.ModulePath;
 import jdk.internal.module.ModuleResolution;
 
 /**
@@ -155,8 +157,8 @@
                     for (String dir : dirs) {
                         paths[i++] = Paths.get(dir);
                     }
-                    jartool.moduleFinder = ModuleFinder.compose(jartool.moduleFinder,
-                                                                ModuleFinder.of(paths));
+                    jartool.moduleFinder =
+                        new ModulePath(Runtime.version(), true, paths);
                 }
             },
             new Option(false, OptionType.CREATE_UPDATE, "--do-not-resolve-by-default") {
@@ -169,9 +171,9 @@
             new Option(true, OptionType.CREATE_UPDATE, "--warn-if-resolved") {
                 void process(Main jartool, String opt, String arg) throws BadArgs {
                     ModuleResolution mres = ModuleResolution.empty();
-                    if (jartool.moduleResolution.doNotResolveByDefault())
+                    if (jartool.moduleResolution.doNotResolveByDefault()) {
                         mres.withDoNotResolveByDefault();
-
+                    }
                     if (arg.equals("deprecated")) {
                         jartool.moduleResolution = mres.withDeprecated();
                     } else if (arg.equals("deprecated-for-removal")) {
@@ -201,26 +203,27 @@
             // Other options
             new Option(true, true, OptionType.OTHER, "--help", "-h") {
                 void process(Main jartool, String opt, String arg) throws BadArgs {
-                    if (arg == null) {
-                        jartool.info = Main.Info.HELP;
-                        return;
+                    if (jartool.info == null) {
+                        if (arg == null) {
+                            jartool.info = GNUStyleOptions::printHelp;  //  Main.Info.HELP;
+                            return;
+                        }
+                        if (!arg.equals("compat"))
+                            throw new BadArgs("error.illegal.option", arg).showUsage(true);
+                        // jartool.info = Main.Info.COMPAT_HELP;
+                        jartool.info = GNUStyleOptions::printCompatHelp;
                     }
-
-                    if (!arg.equals("compat"))
-                        throw new BadArgs("error.illegal.option", arg).showUsage(true);
-
-                    jartool.info = Main.Info.COMPAT_HELP;
                 }
             },
             new Option(false, OptionType.OTHER, "--help-extra") {
                 void process(Main jartool, String opt, String arg) throws BadArgs {
-                    jartool.info = Main.Info.HELP_EXTRA;
+                    jartool.info = GNUStyleOptions::printHelpExtra;
                 }
             },
             new Option(false, OptionType.OTHER, "--version") {
                 void process(Main jartool, String opt, String arg) {
                     if (jartool.info == null)
-                        jartool.info = Main.Info.VERSION;
+                        jartool.info = GNUStyleOptions::printVersion;
                 }
             }
     };
@@ -279,14 +282,14 @@
     static int parseOptions(Main jartool, String[] args) throws BadArgs {
         int count = 0;
         if (args.length == 0) {
-            jartool.info = Main.Info.USAGE_TRYHELP;
+            jartool.info = GNUStyleOptions::printUsageTryHelp;  //  never be here
             return 0;
         }
 
         // process options
         for (; count < args.length; count++) {
-            if (args[count].charAt(0) != '-' || args[count].equals("-C")
-                || args[count].equals("--release"))
+            if (args[count].charAt(0) != '-' || args[count].equals("-C") ||
+                args[count].equals("--release"))
                 break;
 
             String name = args[count];
@@ -322,15 +325,15 @@
         throw new BadArgs("error.unrecognized.option", name).showUsage(true);
     }
 
-    static void printHelp(PrintWriter out) {
-        printHelp(out, false);
+    static void printHelpExtra(PrintWriter out) {
+        printHelp0(out, true);
     }
 
-    static void printHelpExtra(PrintWriter out) {
-        printHelp(out, true);
+    static void printHelp(PrintWriter out) {
+        printHelp0(out, false);
     }
 
-    private static void printHelp(PrintWriter out, boolean printExtra) {
+    private static void printHelp0(PrintWriter out, boolean printExtra) {
         out.format("%s%n", Main.getMsg("main.help.preopt"));
         for (OptionType type : OptionType.values()) {
             boolean typeHeadingWritten = false;
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 
 import java.io.*;
 import java.lang.module.Configuration;
+import java.lang.module.InvalidModuleDescriptorException;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Exports;
 import java.lang.module.ModuleDescriptor.Provides;
@@ -46,7 +47,7 @@
 import java.nio.file.StandardCopyOption;
 import java.util.*;
 import java.util.function.Consumer;
-import java.util.function.Function;
+import java.util.function.Supplier;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -58,6 +59,7 @@
 
 import jdk.internal.module.Checks;
 import jdk.internal.module.ModuleHashes;
+import jdk.internal.module.ModuleHashesBuilder;
 import jdk.internal.module.ModuleInfo;
 import jdk.internal.module.ModuleInfoExtender;
 import jdk.internal.module.ModuleResolution;
@@ -66,7 +68,6 @@
 import static jdk.internal.util.jar.JarIndex.INDEX_NAME;
 import static java.util.jar.JarFile.MANIFEST_NAME;
 import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toSet;
 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
 
 /**
@@ -74,58 +75,24 @@
  * (Java Archive) file format. The JAR format is based on the ZIP file
  * format, with optional meta-information stored in a MANIFEST entry.
  */
-public
-class Main {
+public class Main {
     String program;
     PrintWriter out, err;
     String fname, mname, ename;
     String zname = "";
     String rootjar = null;
-    Set<String> concealedPackages = new HashSet<>(); // used by Validator
 
     private static final int BASE_VERSION = 0;
 
-    class Entry {
-        final String basename;
-        final String entryname;
+    private static class Entry {
+        final String name;
         final File file;
         final boolean isDir;
 
-        Entry(File file, String basename, String entryname) {
-            this.file = file;
-            this.isDir = file.isDirectory();
-            this.basename = basename;
-            this.entryname = entryname;
-        }
-
-        Entry(int version, File file) {
+        Entry(File file, String name, boolean isDir) {
             this.file = file;
-            String path = file.getPath();
-            if (file.isDirectory()) {
-                isDir = true;
-                path = path.endsWith(File.separator) ? path :
-                            path + File.separator;
-            } else {
-                isDir = false;
-            }
-            EntryName en = new EntryName(path, version);
-            basename = en.baseName;
-            entryname = en.entryName;
-        }
-
-        /**
-         * Returns a new Entry that trims the versions directory.
-         *
-         * This entry should be a valid entry matching the given version.
-         */
-        Entry toVersionedEntry(int version) {
-            assert isValidVersionedEntry(this, version);
-
-            if (version == BASE_VERSION)
-                return this;
-
-            EntryName en = new EntryName(trimVersionsDir(basename, version), version);
-            return new Entry(this.file, en.baseName, en.entryName);
+            this.isDir = isDir;
+            this.name = name;
         }
 
         @Override
@@ -141,32 +108,6 @@
         }
     }
 
-    class EntryName {
-        final String baseName;
-        final String entryName;
-
-        EntryName(String name, int version) {
-            name = name.replace(File.separatorChar, '/');
-            String matchPath = "";
-            for (String path : pathsMap.get(version)) {
-                if (name.startsWith(path)
-                        && (path.length() > matchPath.length())) {
-                    matchPath = path;
-                }
-            }
-            name = safeName(name.substring(matchPath.length()));
-            // the old implementaton doesn't remove
-            // "./" if it was led by "/" (?)
-            if (name.startsWith("./")) {
-                name = name.substring(2);
-            }
-            baseName = name;
-            entryName = (version > BASE_VERSION)
-                    ? VERSIONS_DIR + version + "/" + baseName
-                    : baseName;
-        }
-    }
-
     // An entryName(path)->Entry map generated during "expand", it helps to
     // decide whether or not an existing entry in a jar file needs to be
     // replaced, during the "update" operation.
@@ -175,11 +116,8 @@
     // All entries need to be added/updated.
     Set<Entry> entries = new LinkedHashSet<>();
 
-    // All packages.
-    Set<String> packages = new HashSet<>();
-    // All actual entries added, or existing, in the jar file ( excl manifest
-    // and module-info.class ). Populated during create or update.
-    Set<String> jarEntries = new HashSet<>();
+    // module-info.class entries need to be added/updated.
+    Map<String,byte[]> moduleInfos = new HashMap<>();
 
     // A paths Set for each version, where each Set contains directories
     // specified by the "-C" operation.
@@ -208,19 +146,7 @@
     boolean cflag, uflag, xflag, tflag, vflag, flag0, Mflag, iflag, nflag, pflag, dflag;
 
     /* To support additional GNU Style informational options */
-    enum Info {
-        HELP(GNUStyleOptions::printHelp),
-        HELP_EXTRA(GNUStyleOptions::printHelpExtra),
-        COMPAT_HELP(GNUStyleOptions::printCompatHelp),
-        USAGE_TRYHELP(GNUStyleOptions::printUsageTryHelp),
-        VERSION(GNUStyleOptions::printVersion);
-
-        private Consumer<PrintWriter> printFunction;
-        Info(Consumer<PrintWriter> f) { this.printFunction = f; }
-        void print(PrintWriter out) { printFunction.accept(out); }
-    };
-    Info info;
-
+    Consumer<PrintWriter> info;
 
     /* Modular jar related options */
     Version moduleVersion;
@@ -228,8 +154,7 @@
     ModuleResolution moduleResolution = ModuleResolution.empty();
     ModuleFinder moduleFinder = ModuleFinder.of();
 
-    private static final String MODULE_INFO = "module-info.class";
-
+    static final String MODULE_INFO = "module-info.class";
     static final String MANIFEST_DIR = "META-INF/";
     static final String VERSIONS_DIR = MANIFEST_DIR + "versions/";
     static final String VERSION = "1.0";
@@ -324,7 +249,6 @@
                     }
                 }
             }
-
             if (cflag) {
                 Manifest manifest = null;
                 if (!Mflag) {
@@ -347,72 +271,60 @@
                         addMultiRelease(manifest);
                     }
                 }
-
-                Map<String,Path> moduleInfoPaths = new HashMap<>();
-                for (int version : filesMap.keySet()) {
-                    String[] files = filesMap.get(version);
-                    expand(null, files, false, moduleInfoPaths, version);
-                }
-
-                Map<String,byte[]> moduleInfos = new LinkedHashMap<>();
-                if (!moduleInfoPaths.isEmpty()) {
-                    if (!checkModuleInfos(moduleInfoPaths))
-                        return false;
-
-                    // root module-info first
-                    byte[] b = readModuleInfo(moduleInfoPaths.get(MODULE_INFO));
-                    moduleInfos.put(MODULE_INFO, b);
-                    for (Map.Entry<String,Path> e : moduleInfoPaths.entrySet())
-                        moduleInfos.putIfAbsent(e.getKey(), readModuleInfo(e.getValue()));
-
-                    if (!addExtendedModuleAttributes(moduleInfos))
-                        return false;
+                expand();
+                if (!moduleInfos.isEmpty()) {
+                    // All actual file entries (excl manifest and module-info.class)
+                    Set<String> jentries = new HashSet<>();
+                    // all packages if it's a class or resource
+                    Set<String> packages = new HashSet<>();
+                    entries.stream()
+                           .filter(e -> !e.isDir)
+                           .forEach( e -> {
+                               addPackageIfNamed(packages, e.name);
+                               jentries.add(e.name);
+                    });
+                    addExtendedModuleAttributes(moduleInfos, packages);
 
                     // Basic consistency checks for modular jars.
-                    if (!checkServices(moduleInfos.get(MODULE_INFO)))
+                    if (!checkModuleInfo(moduleInfos.get(MODULE_INFO), jentries))
                         return false;
 
                 } else if (moduleVersion != null || modulesToHash != null) {
                     error(getMsg("error.module.options.without.info"));
                     return false;
                 }
-
                 if (vflag && fname == null) {
                     // Disable verbose output so that it does not appear
                     // on stdout along with file data
                     // error("Warning: -v option ignored");
                     vflag = false;
                 }
-
                 final String tmpbase = (fname == null)
                         ? "tmpjar"
                         : fname.substring(fname.indexOf(File.separatorChar) + 1);
+
                 File tmpfile = createTemporaryFile(tmpbase, ".jar");
-
                 try (OutputStream out = new FileOutputStream(tmpfile)) {
-                    create(new BufferedOutputStream(out, 4096), manifest, moduleInfos);
+                    create(new BufferedOutputStream(out, 4096), manifest);
                 }
-
                 if (nflag) {
                     File packFile = createTemporaryFile(tmpbase, ".pack");
                     try {
                         Packer packer = Pack200.newPacker();
                         Map<String, String> p = packer.properties();
                         p.put(Packer.EFFORT, "1"); // Minimal effort to conserve CPU
-                        try (
-                                JarFile jarFile = new JarFile(tmpfile.getCanonicalPath());
-                                OutputStream pack = new FileOutputStream(packFile)
-                        ) {
+                        try (JarFile jarFile = new JarFile(tmpfile.getCanonicalPath());
+                             OutputStream pack = new FileOutputStream(packFile))
+                        {
                             packer.pack(jarFile, pack);
                         }
                         if (tmpfile.exists()) {
                             tmpfile.delete();
                         }
                         tmpfile = createTemporaryFile(tmpbase, ".jar");
-                        try (
-                                OutputStream out = new FileOutputStream(tmpfile);
-                                JarOutputStream jos = new JarOutputStream(out)
-                        ) {
+                        try (OutputStream out = new FileOutputStream(tmpfile);
+                             JarOutputStream jos = new JarOutputStream(out))
+                        {
                             Unpacker unpacker = Pack200.newUnpacker();
                             unpacker.unpack(packFile, jos);
                         }
@@ -420,9 +332,7 @@
                         Files.deleteIfExists(packFile.toPath());
                     }
                 }
-
                 validateAndClose(tmpfile);
-
             } else if (uflag) {
                 File inputFile = null, tmpFile = null;
                 if (fname != null) {
@@ -432,39 +342,20 @@
                     vflag = false;
                     tmpFile = createTemporaryFile("tmpjar", ".jar");
                 }
-
-                Map<String,Path> moduleInfoPaths = new HashMap<>();
-                for (int version : filesMap.keySet()) {
-                    String[] files = filesMap.get(version);
-                    expand(null, files, true, moduleInfoPaths, version);
+                expand();
+                try (FileInputStream in = (fname != null) ? new FileInputStream(inputFile)
+                        : new FileInputStream(FileDescriptor.in);
+                     FileOutputStream out = new FileOutputStream(tmpFile);
+                     InputStream manifest = (!Mflag && (mname != null)) ?
+                            (new FileInputStream(mname)) : null;
+                ) {
+                    boolean updateOk = update(in, new BufferedOutputStream(out),
+                        manifest, moduleInfos, null);
+                    if (ok) {
+                        ok = updateOk;
+                    }
                 }
-
-                Map<String,byte[]> moduleInfos = new HashMap<>();
-                for (Map.Entry<String,Path> e : moduleInfoPaths.entrySet())
-                    moduleInfos.put(e.getKey(), readModuleInfo(e.getValue()));
-
-                try (
-                        FileInputStream in = (fname != null) ? new FileInputStream(inputFile)
-                                : new FileInputStream(FileDescriptor.in);
-                        FileOutputStream out = new FileOutputStream(tmpFile);
-                        InputStream manifest = (!Mflag && (mname != null)) ?
-                                (new FileInputStream(mname)) : null;
-                ) {
-                        boolean updateOk = update(in, new BufferedOutputStream(out),
-                                manifest, moduleInfos, null);
-                        if (ok) {
-                            ok = updateOk;
-                        }
-                }
-
-                // Consistency checks for modular jars.
-                if (!moduleInfos.isEmpty()) {
-                    if(!checkServices(moduleInfos.get(MODULE_INFO)))
-                        return false;
-                }
-
                 validateAndClose(tmpFile);
-
             } else if (tflag) {
                 replaceFSC(filesMap);
                 // For the "list table contents" action, access using the
@@ -542,12 +433,15 @@
 
     private void validateAndClose(File tmpfile) throws IOException {
         if (ok && isMultiRelease) {
-            ok = validate(tmpfile.getCanonicalPath());
-            if (!ok) {
-                error(formatMsg("error.validator.jarfile.invalid", fname));
+            try (JarFile jf = new JarFile(tmpfile)) {
+                ok = Validator.validate(this, jf);
+                if (!ok) {
+                    error(formatMsg("error.validator.jarfile.invalid", fname));
+                }
+            } catch (IOException e) {
+                error(formatMsg2("error.validator.jarfile.exception", fname, e.getMessage()));
             }
         }
-
         Path path = tmpfile.toPath();
         try {
             if (ok) {
@@ -572,78 +466,9 @@
 
     Stream<String> filesToEntryNames(Map.Entry<Integer,String[]> fileEntries) {
         int version = fileEntries.getKey();
+        Set<String> cpaths = pathsMap.get(version);
         return Stream.of(fileEntries.getValue())
-                .map(f -> (new EntryName(f, version)).entryName);
-    }
-
-    // sort base entries before versioned entries, and sort entry classes with
-    // nested classes so that the top level class appears before the associated
-    // nested class
-    private Comparator<JarEntry> entryComparator = (je1, je2) ->  {
-        String s1 = je1.getName();
-        String s2 = je2.getName();
-        if (s1.equals(s2)) return 0;
-        boolean b1 = s1.startsWith(VERSIONS_DIR);
-        boolean b2 = s2.startsWith(VERSIONS_DIR);
-        if (b1 && !b2) return 1;
-        if (!b1 && b2) return -1;
-        int n = 0; // starting char for String compare
-        if (b1 && b2) {
-            // normally strings would be sorted so "10" goes before "9", but
-            // version number strings need to be sorted numerically
-            n = VERSIONS_DIR.length();   // skip the common prefix
-            int i1 = s1.indexOf('/', n);
-            int i2 = s1.indexOf('/', n);
-            if (i1 == -1) throw new InvalidJarException(s1);
-            if (i2 == -1) throw new InvalidJarException(s2);
-            // shorter version numbers go first
-            if (i1 != i2) return i1 - i2;
-            // otherwise, handle equal length numbers below
-        }
-        int l1 = s1.length();
-        int l2 = s2.length();
-        int lim = Math.min(l1, l2);
-        for (int k = n; k < lim; k++) {
-            char c1 = s1.charAt(k);
-            char c2 = s2.charAt(k);
-            if (c1 != c2) {
-                // change natural ordering so '.' comes before '$'
-                // i.e. top level classes come before nested classes
-                if (c1 == '$' && c2 == '.') return 1;
-                if (c1 == '.' && c2 == '$') return -1;
-                return c1 - c2;
-            }
-        }
-        return l1 - l2;
-    };
-
-    private boolean validate(String fname) {
-        boolean valid;
-
-        try (JarFile jf = new JarFile(fname)) {
-            Validator validator = new Validator(this, jf);
-            jf.stream()
-                    .filter(e -> !e.isDirectory())
-                    .filter(e -> !e.getName().equals(MANIFEST_NAME))
-                    .filter(e -> !e.getName().endsWith(MODULE_INFO))
-                    .sorted(entryComparator)
-                    .forEachOrdered(validator);
-             valid = validator.isValid();
-        } catch (IOException e) {
-            error(formatMsg2("error.validator.jarfile.exception", fname, e.getMessage()));
-            valid = false;
-        } catch (InvalidJarException e) {
-            error(formatMsg("error.validator.bad.entry.name", e.getMessage()));
-            valid = false;
-        }
-        return valid;
-    }
-
-    private static class InvalidJarException extends RuntimeException {
-        private static final long serialVersionUID = -3642329147299217726L;
-        InvalidJarException(String msg) {
-            super(msg);
-        }
+            .map(f -> toVersionedName(toEntryName(f, cpaths, false), version));
     }
 
     /**
@@ -668,20 +493,22 @@
             // Note: flags.length == 2 can be treated as the short version of
             // the GNU option since the there cannot be any other options,
             // excluding -C, as per the old way.
-            if (flags.startsWith("--")
-                || (flags.startsWith("-") && flags.length() == 2)) {
+            if (flags.startsWith("--") ||
+                (flags.startsWith("-") && flags.length() == 2)) {
                 try {
                     count = GNUStyleOptions.parseOptions(this, args);
                 } catch (GNUStyleOptions.BadArgs x) {
                     if (info == null) {
-                        error(x.getMessage());
-                        if (x.showUsage)
-                            Info.USAGE_TRYHELP.print(err);
+                        if (x.showUsage) {
+                            usageError(x.getMessage());
+                        } else {
+                            error(x.getMessage());
+                        }
                         return false;
                     }
                 }
                 if (info != null) {
-                    info.print(out);
+                    info.accept(out);
                     return true;
                 }
             } else {
@@ -851,19 +678,55 @@
      * Add the package of the given resource name if it's a .class
      * or a resource in a named package.
      */
-    boolean addPackageIfNamed(String name) {
+    void addPackageIfNamed(Set<String> packages, String name) {
         if (name.startsWith(VERSIONS_DIR)) {
-            throw new InternalError(name);
+            // trim the version dir prefix
+            int i0 = VERSIONS_DIR.length();
+            int i = name.indexOf('/', i0);
+            if (i <= 0) {
+                warn(formatMsg("warn.release.unexpected.versioned.entry", name));
+                return;
+            }
+            while (i0 < i) {
+                char c = name.charAt(i0);
+                if (c < '0' || c > '9') {
+                    warn(formatMsg("warn.release.unexpected.versioned.entry", name));
+                    return;
+                }
+                i0++;
+            }
+            name = name.substring(i + 1, name.length());
         }
-
         String pn = toPackageName(name);
         // add if this is a class or resource in a package
         if (Checks.isJavaIdentifier(pn)) {
             packages.add(pn);
-            return true;
+        }
+    }
+
+    private String toEntryName(String name, Set<String> cpaths, boolean isDir) {
+        name = name.replace(File.separatorChar, '/');
+        if (isDir) {
+            name = name.endsWith("/") ? name : name + "/";
         }
+        String matchPath = "";
+        for (String path : cpaths) {
+            if (name.startsWith(path) && path.length() > matchPath.length()) {
+                matchPath = path;
+            }
+        }
+        name = safeName(name.substring(matchPath.length()));
+        // the old implementaton doesn't remove
+        // "./" if it was led by "/" (?)
+        if (name.startsWith("./")) {
+            name = name.substring(2);
+        }
+        return name;
+    }
 
-        return false;
+    private static String toVersionedName(String name, int version) {
+        return version > BASE_VERSION
+                ? VERSIONS_DIR + version + "/" + name : name;
     }
 
     private static String toPackageName(String path) {
@@ -875,57 +738,23 @@
         }
     }
 
-    /*
-     * Returns true if the given entry is a valid entry of the given version.
-     */
-    private boolean isValidVersionedEntry(Entry entry, int version) {
-        String name = entry.basename;
-        if (name.startsWith(VERSIONS_DIR) && version != BASE_VERSION) {
-            int i = name.indexOf('/', VERSIONS_DIR.length());
-            // name == -1 -> not a versioned directory, something else
-            if (i == -1)
-                return false;
-            try {
-                String v = name.substring(VERSIONS_DIR.length(), i);
-                return Integer.valueOf(v) == version;
-            } catch (NumberFormatException x) {
-                return false;
-            }
+    private void expand() throws IOException {
+        for (int version : filesMap.keySet()) {
+            String[] files = filesMap.get(version);
+            expand(null, files, pathsMap.get(version), version);
         }
-        return true;
-    }
-
-    /*
-     * Trim META-INF/versions/$version/ from the given name if the
-     * given name is a versioned entry of the given version; or
-     * of any version if the given version is BASE_VERSION
-     */
-    private String trimVersionsDir(String name, int version) {
-        if (name.startsWith(VERSIONS_DIR)) {
-            int i = name.indexOf('/', VERSIONS_DIR.length());
-            if (i >= 0) {
-                try {
-                    String v = name.substring(VERSIONS_DIR.length(), i);
-                    if (version == BASE_VERSION || Integer.valueOf(v) == version) {
-                        return name.substring(i + 1, name.length());
-                    }
-                } catch (NumberFormatException x) {}
-            }
-            throw new InternalError("unexpected versioned entry: " +
-                    name + " version " + version);
-        }
-        return name;
     }
 
     /**
      * Expands list of files to process into full list of all files that
      * can be found by recursively descending directories.
+     *
+     * @param dir    parent directory
+     * @param file s list of files to expand
+     * @param cpaths set of directories specified by -C option for the files
+     * @throws IOException if an I/O error occurs
      */
-    void expand(File dir,
-                String[] files,
-                boolean isUpdate,
-                Map<String,Path> moduleInfoPaths,
-                int version)
+    private void expand(File dir, String[] files, Set<String> cpaths, int version)
         throws IOException
     {
         if (files == null)
@@ -938,47 +767,48 @@
             else
                 f = new File(dir, files[i]);
 
-            Entry e = new Entry(version, f);
-            String entryName = e.entryname;
-            Entry entry = e;
-            if (e.basename.startsWith(VERSIONS_DIR) && isValidVersionedEntry(e, version)) {
-                entry = e.toVersionedEntry(version);
-            }
-            if (f.isFile()) {
-                if (entryName.endsWith(MODULE_INFO)) {
-                    moduleInfoPaths.put(entryName, f.toPath());
-                    if (isUpdate)
-                        entryMap.put(entryName, entry);
-                } else if (isValidVersionedEntry(entry, version)) {
-                    if (entries.add(entry)) {
-                        jarEntries.add(entryName);
-                        // add the package if it's a class or resource
-                        addPackageIfNamed(trimVersionsDir(entry.basename, version));
-                        if (isUpdate)
-                            entryMap.put(entryName, entry);
-                    }
-                } else {
+            boolean isDir = f.isDirectory();
+            String name = toEntryName(f.getPath(), cpaths, isDir);
+
+            if (version != BASE_VERSION) {
+                if (name.startsWith(VERSIONS_DIR)) {
+                    // the entry starts with VERSIONS_DIR and version != BASE_VERSION,
+                    // which means the "[dirs|files]" in --release v [dirs|files]
+                    // includes VERSIONS_DIR-ed entries --> warning and skip (?)
                     error(formatMsg2("error.release.unexpected.versioned.entry",
-                                      entry.basename, String.valueOf(version)));
+                                     name, String.valueOf(version)));
                     ok = false;
+                    return;
                 }
-            } else if (f.isDirectory()) {
-                if (isValidVersionedEntry(entry, version)) {
-                    if (entries.add(entry)) {
-                        if (isUpdate) {
-                            entryMap.put(entryName, entry);
-                        }
+                name = toVersionedName(name, version);
+            }
+
+            if (f.isFile()) {
+                Entry e = new Entry(f, name, false);
+                if (isModuleInfoEntry(name)) {
+                    moduleInfos.putIfAbsent(name, Files.readAllBytes(f.toPath()));
+                    if (uflag)
+                        entryMap.put(name, e);
+                } else if (entries.add(e)) {
+                    if (uflag)
+                        entryMap.put(name, e);
+                }
+            } else if (isDir) {
+                Entry e = new Entry(f, name, true);
+                if (entries.add(e)) {
+                    // utilize entryMap for the duplicate dir check even in
+                    // case of cflag == true.
+                    // dir name confilict/duplicate could happen with -C option.
+                    // just remove the last "e" from the "entries" (zos will fail
+                    // with "duplicated" entries), but continue expanding the
+                    // sub tree
+                    if (entryMap.containsKey(name)) {
+                        entries.remove(e);
+                    } else {
+                        entryMap.put(name, e);
                     }
-                } else if (entry.basename.equals(VERSIONS_DIR)) {
-                    if (vflag) {
-                        output(formatMsg("out.ignore.entry", entry.basename));
-                    }
-                } else {
-                    error(formatMsg2("error.release.unexpected.versioned.entry",
-                                      entry.basename, String.valueOf(version)));
-                    ok = false;
+                    expand(f, f.list(), cpaths, version);
                 }
-                expand(f, f.list(), isUpdate, moduleInfoPaths, version);
             } else {
                 error(formatMsg("error.nosuch.fileordir", String.valueOf(f)));
                 ok = false;
@@ -989,52 +819,36 @@
     /**
      * Creates a new JAR file.
      */
-    void create(OutputStream out, Manifest manifest, Map<String,byte[]> moduleInfos)
-        throws IOException
+    void create(OutputStream out, Manifest manifest) throws IOException
     {
-        ZipOutputStream zos = new JarOutputStream(out);
-        if (flag0) {
-            zos.setMethod(ZipOutputStream.STORED);
-        }
-        // TODO: check module-info attributes against manifest ??
-        if (manifest != null) {
-            if (vflag) {
-                output(getMsg("out.added.manifest"));
-            }
-            ZipEntry e = new ZipEntry(MANIFEST_DIR);
-            e.setTime(System.currentTimeMillis());
-            e.setSize(0);
-            e.setCrc(0);
-            zos.putNextEntry(e);
-            e = new ZipEntry(MANIFEST_NAME);
-            e.setTime(System.currentTimeMillis());
+        try (ZipOutputStream zos = new JarOutputStream(out)) {
             if (flag0) {
-                crc32Manifest(e, manifest);
+                zos.setMethod(ZipOutputStream.STORED);
             }
-            zos.putNextEntry(e);
-            manifest.write(zos);
-            zos.closeEntry();
-        }
-        for (Map.Entry<String,byte[]> mi : moduleInfos.entrySet()) {
-            String entryName = mi.getKey();
-            byte[] miBytes = mi.getValue();
-            if (vflag) {
-                output(formatMsg("out.added.module-info", entryName));
+            // TODO: check module-info attributes against manifest ??
+            if (manifest != null) {
+                if (vflag) {
+                    output(getMsg("out.added.manifest"));
+                }
+                ZipEntry e = new ZipEntry(MANIFEST_DIR);
+                e.setTime(System.currentTimeMillis());
+                e.setSize(0);
+                e.setCrc(0);
+                zos.putNextEntry(e);
+                e = new ZipEntry(MANIFEST_NAME);
+                e.setTime(System.currentTimeMillis());
+                if (flag0) {
+                    crc32Manifest(e, manifest);
+                }
+                zos.putNextEntry(e);
+                manifest.write(zos);
+                zos.closeEntry();
             }
-            ZipEntry e = new ZipEntry(mi.getKey());
-            e.setTime(System.currentTimeMillis());
-            if (flag0) {
-                crc32ModuleInfo(e, miBytes);
+            updateModuleInfo(moduleInfos, zos);
+            for (Entry entry : entries) {
+                addFile(zos, entry);
             }
-            zos.putNextEntry(e);
-            ByteArrayInputStream in = new ByteArrayInputStream(miBytes);
-            in.transferTo(zos);
-            zos.closeEntry();
         }
-        for (Entry entry : entries) {
-            addFile(zos, entry);
-        }
-        zos.close();
     }
 
     private char toUpperCaseASCII(char c) {
@@ -1062,30 +876,6 @@
     }
 
     /**
-     * Returns true of the given module-info's are located in acceptable
-     * locations.  Otherwise, outputs an appropriate message and returns false.
-     */
-    private boolean checkModuleInfos(Map<String,?> moduleInfos) {
-        // there must always be, at least, a root module-info
-        if (!moduleInfos.containsKey(MODULE_INFO)) {
-            error(getMsg("error.versioned.info.without.root"));
-            return false;
-        }
-
-        // module-info can only appear in the root, or a versioned section
-        Optional<String> other = moduleInfos.keySet().stream()
-                .filter(x -> !x.equals(MODULE_INFO))
-                .filter(x -> !x.startsWith(VERSIONS_DIR))
-                .findFirst();
-
-        if (other.isPresent()) {
-            error(formatMsg("error.unexpected.module-info", other.get()));
-            return false;
-        }
-        return true;
-    }
-
-    /**
      * Updates an existing jar file.
      */
     boolean update(InputStream in, OutputStream out,
@@ -1099,6 +889,10 @@
         boolean foundManifest = false;
         boolean updateOk = true;
 
+        // All actual entries added/updated/existing, in the jar file (excl manifest
+        // and module-info.class ).
+        Set<String> jentries = new HashSet<>();
+
         if (jarIndex != null) {
             addIndex(jarIndex, zos);
         }
@@ -1108,7 +902,7 @@
             String name = e.getName();
 
             boolean isManifestEntry = equalsIgnoreCase(name, MANIFEST_NAME);
-            boolean isModuleInfoEntry = name.endsWith(MODULE_INFO);
+            boolean isModuleInfoEntry = isModuleInfoEntry(name);
 
             if ((jarIndex != null && equalsIgnoreCase(name, INDEX_NAME))
                 || (Mflag && isManifestEntry)) {
@@ -1127,7 +921,6 @@
                         return false;
                     }
                 }
-
                 // Update the manifest.
                 Manifest old = new Manifest(zis);
                 if (newManifest != null) {
@@ -1137,7 +930,7 @@
                     return false;
                 }
             } else if (moduleInfos != null && isModuleInfoEntry) {
-                moduleInfos.putIfAbsent(name, readModuleInfo(zis));
+                moduleInfos.putIfAbsent(name, zis.readAllBytes());
             } else {
                 boolean isDir = e.isDirectory();
                 if (!entryMap.containsKey(name)) { // copy the old stuff
@@ -1160,11 +953,8 @@
                     entries.remove(ent);
                     isDir = ent.isDir;
                 }
-
-                jarEntries.add(name);
                 if (!isDir) {
-                    // add the package if it's a class or resource
-                    addPackageIfNamed(trimVersionsDir(name, BASE_VERSION));
+                    jentries.add(name);
                 }
             }
         }
@@ -1172,6 +962,9 @@
         // add the remaining new files
         for (Entry entry : entries) {
             addFile(zos, entry);
+            if (!entry.isDir) {
+                jentries.add(entry.name);
+            }
         }
         if (!foundManifest) {
             if (newManifest != null) {
@@ -1188,35 +981,24 @@
                 }
             }
         }
-
-        if (moduleInfos != null && !moduleInfos.isEmpty()) {
-            if (!checkModuleInfos(moduleInfos))
+        if (updateOk) {
+            if (moduleInfos != null && !moduleInfos.isEmpty()) {
+                Set<String> pkgs = new HashSet<>();
+                jentries.forEach( je -> addPackageIfNamed(pkgs, je));
+                addExtendedModuleAttributes(moduleInfos, pkgs);
+                updateOk = checkModuleInfo(moduleInfos.get(MODULE_INFO), jentries);
+                updateModuleInfo(moduleInfos, zos);
+                // TODO: check manifest main classes, etc
+            } else if (moduleVersion != null || modulesToHash != null) {
+                error(getMsg("error.module.options.without.info"));
                 updateOk = false;
-
-            if (updateOk) {
-                if (!addExtendedModuleAttributes(moduleInfos))
-                    updateOk = false;
             }
-
-            // TODO: check manifest main classes, etc
-
-            if (updateOk) {
-                for (Map.Entry<String,byte[]> mi : moduleInfos.entrySet()) {
-                    if (!updateModuleInfo(mi.getValue(), zos, mi.getKey()))
-                        updateOk = false;
-                }
-            }
-        } else if (moduleVersion != null || modulesToHash != null) {
-            error(getMsg("error.module.options.without.info"));
-            updateOk = false;
         }
-
         zis.close();
         zos.close();
         return updateOk;
     }
 
-
     private void addIndex(JarIndex index, ZipOutputStream zos)
         throws IOException
     {
@@ -1232,20 +1014,25 @@
         zos.closeEntry();
     }
 
-    private boolean updateModuleInfo(byte[] moduleInfoBytes, ZipOutputStream zos, String entryName)
+    private void updateModuleInfo(Map<String,byte[]> moduleInfos, ZipOutputStream zos)
         throws IOException
     {
-        ZipEntry e = new ZipEntry(entryName);
-        e.setTime(System.currentTimeMillis());
-        if (flag0) {
-            crc32ModuleInfo(e, moduleInfoBytes);
+        String fmt = uflag ? "out.update.module-info": "out.added.module-info";
+        for (Map.Entry<String,byte[]> mi : moduleInfos.entrySet()) {
+            String name = mi.getKey();
+            byte[] bytes = mi.getValue();
+            ZipEntry e = new ZipEntry(name);
+            e.setTime(System.currentTimeMillis());
+            if (flag0) {
+                crc32ModuleInfo(e, bytes);
+            }
+            zos.putNextEntry(e);
+            zos.write(bytes);
+            zos.closeEntry();
+            if (vflag) {
+                output(formatMsg(fmt, name));
+            }
         }
-        zos.putNextEntry(e);
-        zos.write(moduleInfoBytes);
-        if (vflag) {
-            output(formatMsg("out.update.module-info", entryName));
-        }
-        return true;
     }
 
     private boolean updateManifest(Manifest m, ZipOutputStream zos)
@@ -1358,11 +1145,9 @@
      * Adds a new file entry to the ZIP output stream.
      */
     void addFile(ZipOutputStream zos, Entry entry) throws IOException {
-        // skip the generation of directory entries for META-INF/versions/*/
-        if (entry.basename.isEmpty()) return;
 
         File file = entry.file;
-        String name = entry.entryname;
+        String name = entry.name;
         boolean isDir = entry.isDir;
 
         if (name.equals("") || name.equals(".") || name.equals(zname)) {
@@ -1444,11 +1229,8 @@
      * @throws IOException if an I/O error occurs
      */
     private void copy(File from, OutputStream to) throws IOException {
-        InputStream in = new FileInputStream(from);
-        try {
+        try (InputStream in = new FileInputStream(from)) {
             copy(in, to);
-        } finally {
-            in.close();
         }
     }
 
@@ -1461,11 +1243,8 @@
      * @throws IOException if an I/O error occurs
      */
     private void copy(InputStream from, File to) throws IOException {
-        OutputStream out = new FileOutputStream(to);
-        try {
+        try (OutputStream out = new FileOutputStream(to)) {
             copy(from, out);
-        } finally {
-            out.close();
         }
     }
 
@@ -1825,7 +1604,7 @@
      */
     void usageError(String s) {
         err.println(s);
-        Info.USAGE_TRYHELP.print(err);
+        err.println(getMsg("main.usage.summary.try"));
     }
 
     /**
@@ -1934,16 +1713,6 @@
         return tmpfile;
     }
 
-    private static byte[] readModuleInfo(InputStream zis) throws IOException {
-        return zis.readAllBytes();
-    }
-
-    private static byte[] readModuleInfo(Path path) throws IOException {
-        try (InputStream is = Files.newInputStream(path)) {
-            return is.readAllBytes();
-        }
-    }
-
     // Modular jar support
 
     static <T> String toString(Collection<T> c,
@@ -1951,7 +1720,6 @@
                                CharSequence suffix ) {
         if (c.isEmpty())
             return "";
-
         return c.stream().map(e -> e.toString())
                            .collect(joining(", ", prefix, suffix));
     }
@@ -2045,136 +1813,84 @@
 
         md.osVersion().ifPresent(v -> sb.append("\n  operating-system-version " + v));
 
-        if (hashes != null) {
-            hashes.names().stream().sorted().forEach(
-                    mod -> sb.append("\n  hashes ").append(mod).append(" ")
-                             .append(hashes.algorithm()).append(" ")
-                             .append(toHex(hashes.hashFor(mod))));
+       if (hashes != null) {
+           hashes.names().stream().sorted().forEach(
+                   mod -> sb.append("\n  hashes ").append(mod).append(" ")
+                            .append(hashes.algorithm()).append(" ")
+                            .append(toHex(hashes.hashFor(mod))));
         }
 
         output(sb.toString());
     }
 
     private static String toHex(byte[] ba) {
-        StringBuilder sb = new StringBuilder(ba.length);
+        StringBuilder sb = new StringBuilder(ba.length << 1);
         for (byte b: ba) {
             sb.append(String.format("%02x", b & 0xff));
         }
         return sb.toString();
     }
 
-    private static String toBinaryName(String classname) {
+    static String toBinaryName(String classname) {
         return (classname.replace('.', '/')) + ".class";
     }
 
-    /* A module must have the implementation class of the services it 'provides'. */
-    private boolean checkServices(byte[] moduleInfoBytes)
+    private boolean checkModuleInfo(byte[] moduleInfoBytes, Set<String> entries)
         throws IOException
     {
-        ModuleDescriptor md = ModuleDescriptor.read(ByteBuffer.wrap(moduleInfoBytes));
-        Set<String> missing = md.provides()
-                                .stream()
-                                .map(Provides::providers)
-                                .flatMap(List::stream)
-                                .filter(p -> !jarEntries.contains(toBinaryName(p)))
-                                .collect(Collectors.toSet());
-        if (missing.size() > 0) {
-            missing.stream().forEach(s -> fatalError(formatMsg("error.missing.provider", s)));
-            return false;
+        boolean ok = true;
+        if (moduleInfoBytes != null) {  // no root module-info.class if null
+            try {
+                // ModuleDescriptor.read() checks open/exported pkgs vs packages
+                ModuleDescriptor md = ModuleDescriptor.read(ByteBuffer.wrap(moduleInfoBytes));
+                // A module must have the implementation class of the services it 'provides'.
+                if (md.provides().stream().map(Provides::providers).flatMap(List::stream)
+                      .filter(p -> !entries.contains(toBinaryName(p)))
+                      .peek(p -> fatalError(formatMsg("error.missing.provider", p)))
+                      .count() != 0) {
+                    ok = false;
+                }
+            } catch (InvalidModuleDescriptorException x) {
+                fatalError(x.getMessage());
+                ok = false;
+            }
         }
-        return true;
+        return ok;
     }
 
     /**
      * Adds extended modules attributes to the given module-info's.  The given
      * Map values are updated in-place. Returns false if an error occurs.
      */
-    private boolean addExtendedModuleAttributes(Map<String,byte[]> moduleInfos)
+    private void addExtendedModuleAttributes(Map<String,byte[]> moduleInfos,
+                                                Set<String> packages)
         throws IOException
     {
-        assert !moduleInfos.isEmpty() && moduleInfos.get(MODULE_INFO) != null;
-
-        ByteBuffer bb = ByteBuffer.wrap(moduleInfos.get(MODULE_INFO));
-        ModuleDescriptor rd = ModuleDescriptor.read(bb);
-
-        concealedPackages = findConcealedPackages(rd);
-
         for (Map.Entry<String,byte[]> e: moduleInfos.entrySet()) {
-            ModuleDescriptor vd = ModuleDescriptor.read(ByteBuffer.wrap(e.getValue()));
-            if (!(isValidVersionedDescriptor(vd, rd)))
-                return false;
-            e.setValue(extendedInfoBytes(rd, vd, e.getValue(), packages));
+            ModuleDescriptor md = ModuleDescriptor.read(ByteBuffer.wrap(e.getValue()));
+            e.setValue(extendedInfoBytes(md, e.getValue(), packages));
         }
-        return true;
-    }
-
-    private Set<String> findConcealedPackages(ModuleDescriptor md) {
-        Objects.requireNonNull(md);
-        Set<String> concealed = new HashSet<>(packages);
-        md.exports().stream().map(Exports::source).forEach(concealed::remove);
-        md.opens().stream().map(Opens::source).forEach(concealed::remove);
-        return concealed;
-    }
-
-    private static boolean isPlatformModule(String name) {
-        return name.startsWith("java.") || name.startsWith("jdk.");
     }
 
-    /**
-     * Tells whether or not the given versioned module descriptor's attributes
-     * are valid when compared against the given root module descriptor.
-     *
-     * A versioned module descriptor must be identical to the root module
-     * descriptor, with two exceptions:
-     *  - A versioned descriptor can have different non-public `requires`
-     *    clauses of platform ( `java.*` and `jdk.*` ) modules, and
-     *  - A versioned descriptor can have different `uses` clauses, even of
-     *    service types defined outside of the platform modules.
-     */
-    private boolean isValidVersionedDescriptor(ModuleDescriptor vd,
-                                               ModuleDescriptor rd)
-        throws IOException
-    {
-        if (!rd.name().equals(vd.name())) {
-            fatalError(getMsg("error.versioned.info.name.notequal"));
-            return false;
-        }
-        if (!rd.requires().equals(vd.requires())) {
-            Set<Requires> rootRequires = rd.requires();
-            for (Requires r : vd.requires()) {
-                if (rootRequires.contains(r)) {
-                    continue;
-                } else if (r.modifiers().contains(Requires.Modifier.TRANSITIVE)) {
-                    fatalError(getMsg("error.versioned.info.requires.transitive"));
+    static boolean isModuleInfoEntry(String name) {
+        // root or versioned module-info.class
+        if (name.endsWith(MODULE_INFO)) {
+            int end = name.length() - MODULE_INFO.length();
+            if (end == 0)
+                return true;
+            if (name.startsWith(VERSIONS_DIR)) {
+                int off = VERSIONS_DIR.length();
+                if (off == end)      // meta-inf/versions/module-info.class
                     return false;
-                } else if (!isPlatformModule(r.name())) {
-                    fatalError(getMsg("error.versioned.info.requires.added"));
-                    return false;
+                while (off < end - 1) {
+                    char c = name.charAt(off++);
+                    if (c < '0' || c > '9')
+                        return false;
                 }
-            }
-            for (Requires r : rootRequires) {
-                Set<Requires> mdRequires = vd.requires();
-                if (mdRequires.contains(r)) {
-                    continue;
-                } else if (!isPlatformModule(r.name())) {
-                    fatalError(getMsg("error.versioned.info.requires.dropped"));
-                    return false;
-                }
+                return name.charAt(off) == '/';
             }
         }
-        if (!rd.exports().equals(vd.exports())) {
-            fatalError(getMsg("error.versioned.info.exports.notequal"));
-            return false;
-        }
-        if (!rd.opens().equals(vd.opens())) {
-            fatalError(getMsg("error.versioned.info.opens.notequal"));
-            return false;
-        }
-        if (!rd.provides().equals(vd.provides())) {
-            fatalError(getMsg("error.versioned.info.provides.notequal"));
-            return false;
-        }
-        return true;
+        return false;
     }
 
     /**
@@ -2185,8 +1901,7 @@
      * then the corresponding class file attributes are added to the
      * module-info here.
      */
-    private byte[] extendedInfoBytes(ModuleDescriptor rootDescriptor,
-                                     ModuleDescriptor md,
+    private byte[] extendedInfoBytes(ModuleDescriptor md,
                                      byte[] miBytes,
                                      Set<String> packages)
         throws IOException
@@ -2201,14 +1916,10 @@
         // --main-class
         if (ename != null)
             extender.mainClass(ename);
-        else if (rootDescriptor.mainClass().isPresent())
-            extender.mainClass(rootDescriptor.mainClass().get());
 
         // --module-version
         if (moduleVersion != null)
             extender.version(moduleVersion);
-        else if (rootDescriptor.version().isPresent())
-            extender.version(rootDescriptor.version().get());
 
         // --hash-modules
         if (modulesToHash != null) {
@@ -2218,8 +1929,7 @@
             if (moduleHashes != null) {
                 extender.hashes(moduleHashes);
             } else {
-                // should it issue warning or silent?
-                System.out.println("warning: no module is recorded in hash in " + mn);
+                warn("warning: no module is recorded in hash in " + mn);
             }
         }
 
@@ -2235,10 +1945,9 @@
      * Compute and record hashes
      */
     private class Hasher {
+        final ModuleHashesBuilder hashesBuilder;
         final ModuleFinder finder;
-        final Map<String, Path> moduleNameToPath;
         final Set<String> modules;
-        final Configuration configuration;
         Hasher(ModuleDescriptor descriptor, String fname) throws IOException {
             // Create a module finder that finds the modular JAR
             // being created/updated
@@ -2268,119 +1977,46 @@
                     }
                 });
 
-            // Determine the modules that matches the modulesToHash pattern
-            this.modules = moduleFinder.findAll().stream()
-                .map(moduleReference -> moduleReference.descriptor().name())
+            // Determine the modules that matches the pattern {@code modulesToHash}
+            Set<String> roots = finder.findAll().stream()
+                .map(ref -> ref.descriptor().name())
                 .filter(mn -> modulesToHash.matcher(mn).find())
                 .collect(Collectors.toSet());
 
-            // a map from a module name to Path of the modular JAR
-            this.moduleNameToPath = moduleFinder.findAll().stream()
-                .map(ModuleReference::descriptor)
-                .map(ModuleDescriptor::name)
-                .collect(Collectors.toMap(Function.identity(), mn -> moduleToPath(mn)));
-
-            Configuration config = null;
-            try {
-                config = Configuration.empty()
-                    .resolveRequires(ModuleFinder.ofSystem(), finder, modules);
-            } catch (ResolutionException e) {
-                // should it throw an error?  or emit a warning
-                System.out.println("warning: " + e.getMessage());
+            // use system module path unless it creates a modular JAR for
+            // a module that is present in the system image e.g. upgradeable
+            // module
+            ModuleFinder system;
+            String name = descriptor.name();
+            if (name != null && ModuleFinder.ofSystem().find(name).isPresent()) {
+                system = ModuleFinder.of();
+            } else {
+                system = ModuleFinder.ofSystem();
             }
-            this.configuration = config;
-        }
+            // get a resolved module graph
+            Configuration config =
+                Configuration.empty().resolveRequires(system, finder, roots);
 
-        /**
-         * Compute hashes of the modules that depend upon the specified
-         * module directly or indirectly.
-         */
-        ModuleHashes computeHashes(String name) {
-            // the transposed graph includes all modules in the resolved graph
-            Map<String, Set<String>> graph = transpose();
+            // filter modules resolved from the system module finder
+            this.modules = config.modules().stream()
+                .map(ResolvedModule::name)
+                .filter(mn -> roots.contains(mn) && !system.find(mn).isPresent())
+                .collect(Collectors.toSet());
 
-            // find the modules that transitively depend upon the specified name
-            Deque<String> deque = new ArrayDeque<>();
-            deque.add(name);
-            Set<String> mods = visitNodes(graph, deque);
-
-            // filter modules matching the pattern specified in --hash-modules,
-            // as well as the modular jar file that is being created / updated
-            Map<String, Path> modulesForHash = mods.stream()
-                .filter(mn -> !mn.equals(name) && modules.contains(mn))
-                .collect(Collectors.toMap(Function.identity(), moduleNameToPath::get));
-
-            if (modulesForHash.isEmpty())
-                return null;
-
-            return ModuleHashes.generate(modulesForHash, "SHA-256");
+            this.hashesBuilder = new ModuleHashesBuilder(config, modules);
         }
 
         /**
-         * Returns all nodes traversed from the given roots.
+         * Compute hashes of the specified module.
+         *
+         * It records the hashing modules that depend upon the specified
+         * module directly or indirectly.
          */
-        private Set<String> visitNodes(Map<String, Set<String>> graph,
-                                       Deque<String> roots) {
-            Set<String> visited = new HashSet<>();
-            while (!roots.isEmpty()) {
-                String mn = roots.pop();
-                if (!visited.contains(mn)) {
-                    visited.add(mn);
-
-                    // the given roots may not be part of the graph
-                    if (graph.containsKey(mn)) {
-                        for (String dm : graph.get(mn)) {
-                            if (!visited.contains(dm))
-                                roots.push(dm);
-                        }
-                    }
-                }
-            }
-            return visited;
-        }
-
-        /**
-         * Returns a transposed graph from the resolved module graph.
-         */
-        private Map<String, Set<String>> transpose() {
-            Map<String, Set<String>> transposedGraph = new HashMap<>();
-            Deque<String> deque = new ArrayDeque<>(modules);
+        ModuleHashes computeHashes(String name) {
+            if (hashesBuilder == null)
+                return null;
 
-            Set<String> visited = new HashSet<>();
-            while (!deque.isEmpty()) {
-                String mn = deque.pop();
-                if (!visited.contains(mn)) {
-                    visited.add(mn);
-
-                    // add an empty set
-                    transposedGraph.computeIfAbsent(mn, _k -> new HashSet<>());
-
-                    ResolvedModule resolvedModule = configuration.findModule(mn).get();
-                    for (ResolvedModule dm : resolvedModule.reads()) {
-                        String name = dm.name();
-                        if (!visited.contains(name)) {
-                            deque.push(name);
-                        }
-                        // reverse edge
-                        transposedGraph.computeIfAbsent(name, _k -> new HashSet<>())
-                                       .add(mn);
-                    }
-                }
-            }
-            return transposedGraph;
-        }
-
-        private Path moduleToPath(String name) {
-            ModuleReference mref = moduleFinder.find(name).orElseThrow(
-                () -> new InternalError(formatMsg2("error.hash.dep",name , name)));
-
-            URI uri = mref.location().get();
-            Path path = Paths.get(uri);
-            String fn = path.getFileName().toString();
-            if (!fn.endsWith(".jar")) {
-                throw new UnsupportedOperationException(path + " is not a modular JAR");
-            }
-            return path;
+            return hashesBuilder.computeHashes(Set.of(name)).get(name);
         }
     }
 }
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,32 +25,120 @@
 
 package sun.tools.jar;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.module.InvalidModuleDescriptorException;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.InvalidModuleDescriptorException;
+import java.lang.module.ModuleDescriptor.Opens;
+import java.lang.module.ModuleDescriptor.Provides;
+import java.lang.module.ModuleDescriptor.Requires;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.function.Consumer;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
 
-final class Validator implements Consumer<JarEntry> {
+import static java.util.jar.JarFile.MANIFEST_NAME;
+import static sun.tools.jar.Main.VERSIONS_DIR;
+import static sun.tools.jar.Main.MODULE_INFO;
+import static sun.tools.jar.Main.getMsg;
+import static sun.tools.jar.Main.formatMsg;
+import static sun.tools.jar.Main.formatMsg2;
+import static sun.tools.jar.Main.toBinaryName;
+import static sun.tools.jar.Main.isModuleInfoEntry;
+
+final class Validator {
     private final static boolean DEBUG = Boolean.getBoolean("jar.debug");
     private final  Map<String,FingerPrint> fps = new HashMap<>();
-    private final int vdlen = Main.VERSIONS_DIR.length();
+    private static final int vdlen = VERSIONS_DIR.length();
     private final Main main;
     private final JarFile jf;
     private int oldVersion = -1;
     private String currentTopLevelName;
     private boolean isValid = true;
+    private Set<String> concealedPkgs;
+    private ModuleDescriptor md;
 
-    Validator(Main main, JarFile jf) {
+    private Validator(Main main, JarFile jf) {
         this.main = main;
         this.jf = jf;
+        loadModuleDescriptor();
+    }
+
+    static boolean validate(Main main, JarFile jf) throws IOException {
+        return new Validator(main, jf).validate();
+    }
+
+    private boolean validate() {
+        try {
+            jf.stream()
+              .filter(e -> !e.isDirectory() &&
+                      !e.getName().equals(MANIFEST_NAME))
+              .sorted(entryComparator)
+              .forEachOrdered(e -> validate(e));
+            return isValid;
+        } catch (InvalidJarException e) {
+            error(formatMsg("error.validator.bad.entry.name", e.getMessage()));
+        }
+        return false;
+    }
+
+    private static class InvalidJarException extends RuntimeException {
+        private static final long serialVersionUID = -3642329147299217726L;
+        InvalidJarException(String msg) {
+            super(msg);
+        }
     }
 
-    boolean isValid() {
-        return isValid;
-    }
+    // sort base entries before versioned entries, and sort entry classes with
+    // nested classes so that the top level class appears before the associated
+    // nested class
+    private static Comparator<JarEntry> entryComparator = (je1, je2) ->  {
+        String s1 = je1.getName();
+        String s2 = je2.getName();
+        if (s1.equals(s2)) return 0;
+        boolean b1 = s1.startsWith(VERSIONS_DIR);
+        boolean b2 = s2.startsWith(VERSIONS_DIR);
+        if (b1 && !b2) return 1;
+        if (!b1 && b2) return -1;
+        int n = 0; // starting char for String compare
+        if (b1 && b2) {
+            // normally strings would be sorted so "10" goes before "9", but
+            // version number strings need to be sorted numerically
+            n = VERSIONS_DIR.length();   // skip the common prefix
+            int i1 = s1.indexOf('/', n);
+            int i2 = s1.indexOf('/', n);
+            if (i1 == -1) throw new InvalidJarException(s1);
+            if (i2 == -1) throw new InvalidJarException(s2);
+            // shorter version numbers go first
+            if (i1 != i2) return i1 - i2;
+            // otherwise, handle equal length numbers below
+        }
+        int l1 = s1.length();
+        int l2 = s2.length();
+        int lim = Math.min(l1, l2);
+        for (int k = n; k < lim; k++) {
+            char c1 = s1.charAt(k);
+            char c2 = s2.charAt(k);
+            if (c1 != c2) {
+                // change natural ordering so '.' comes before '$'
+                // i.e. top level classes come before nested classes
+                if (c1 == '$' && c2 == '.') return 1;
+                if (c1 == '.' && c2 == '$') return -1;
+                return c1 - c2;
+            }
+        }
+        return l1 - l2;
+    };
 
     /*
      *  Validator has state and assumes entries provided to accept are ordered
@@ -59,7 +147,7 @@
      *  classes must be ordered so that the top level class is before the associated
      *  nested class(es).
     */
-    public void accept(JarEntry je) {
+    public void validate(JarEntry je) {
         String entryName = je.getName();
 
         // directories are always accepted
@@ -68,13 +156,20 @@
             return;
         }
 
+        // validate the versioned module-info
+        if (isModuleInfoEntry(entryName)) {
+            if (entryName.length() != MODULE_INFO.length())
+                checkModuleDescriptor(je);
+            return;
+        }
+
         // figure out the version and basename from the JarEntry
         int version;
         String basename;
-        if (entryName.startsWith(Main.VERSIONS_DIR)) {
+        if (entryName.startsWith(VERSIONS_DIR)) {
             int n = entryName.indexOf("/", vdlen);
             if (n == -1) {
-                main.error(Main.formatMsg("error.validator.version.notnumber", entryName));
+                error(formatMsg("error.validator.version.notnumber", entryName));
                 isValid = false;
                 return;
             }
@@ -82,12 +177,12 @@
             try {
                 version = Integer.parseInt(v);
             } catch (NumberFormatException x) {
-                main.error(Main.formatMsg("error.validator.version.notnumber", entryName));
+                error(formatMsg("error.validator.version.notnumber", entryName));
                 isValid = false;
                 return;
             }
             if (n == entryName.length()) {
-                main.error(Main.formatMsg("error.validator.entryname.tooshort", entryName));
+                error(formatMsg("error.validator.entryname.tooshort", entryName));
                 isValid = false;
                 return;
             }
@@ -108,7 +203,7 @@
         try (InputStream is = jf.getInputStream(je)) {
             fp = new FingerPrint(basename, is.readAllBytes());
         } catch (IOException x) {
-            main.error(x.getMessage());
+            error(x.getMessage());
             isValid = false;
             return;
         }
@@ -123,7 +218,7 @@
                     fps.put(internalName, fp);
                     return;
                 }
-                main.error(Main.formatMsg("error.validator.isolated.nested.class", entryName));
+                error(formatMsg("error.validator.isolated.nested.class", entryName));
                 isValid = false;
                 return;
             }
@@ -153,11 +248,11 @@
                 }
                 if (fp.isPublicClass()) {
                     if (!isConcealed(internalName)) {
-                        main.error(Main.formatMsg("error.validator.new.public.class", entryName));
+                        error(Main.formatMsg("error.validator.new.public.class", entryName));
                         isValid = false;
                         return;
                     }
-                    main.warn(Main.formatMsg("warn.validator.concealed.public.class", entryName));
+                    warn(formatMsg("warn.validator.concealed.public.class", entryName));
                     debug("%s is a public class entry in a concealed package", entryName);
                 }
                 debug("%s is a non-public class entry", entryName);
@@ -173,7 +268,7 @@
 
         // are the two classes/resources identical?
         if (fp.isIdentical(matchFp)) {
-            main.warn(Main.formatMsg("warn.validator.identical.entry", entryName));
+            warn(formatMsg("warn.validator.identical.entry", entryName));
             return;  // it's okay, just takes up room
         }
         debug("sha1 not equal -- different bytes");
@@ -188,12 +283,12 @@
             }
             debug("%s is a class entry", entryName);
             if (!fp.isCompatibleVersion(matchFp)) {
-                main.error(Main.formatMsg("error.validator.incompatible.class.version", entryName));
+                error(formatMsg("error.validator.incompatible.class.version", entryName));
                 isValid = false;
                 return;
             }
             if (!fp.isSameAPI(matchFp)) {
-                main.error(Main.formatMsg("error.validator.different.api", entryName));
+                error(formatMsg("error.validator.different.api", entryName));
                 isValid = false;
                 return;
             }
@@ -208,17 +303,118 @@
         }
         debug("%s is a resource", entryName);
 
-        main.warn(Main.formatMsg("warn.validator.resources.with.same.name", entryName));
+        warn(formatMsg("warn.validator.resources.with.same.name", entryName));
         fps.put(internalName, fp);
         return;
     }
 
+    private void loadModuleDescriptor() {
+        ZipEntry je = jf.getEntry(MODULE_INFO);
+        if (je != null) {
+            try (InputStream jis = jf.getInputStream(je)) {
+                md = ModuleDescriptor.read(jis);
+                concealedPkgs = new HashSet<>(md.packages());
+                md.exports().stream().map(Exports::source).forEach(concealedPkgs::remove);
+                md.opens().stream().map(Opens::source).forEach(concealedPkgs::remove);
+                return;
+            } catch (Exception x) {
+                error(x.getMessage() + " : " + je.getName());
+                this.isValid = false;
+            }
+        }
+        md = null;
+        concealedPkgs = Collections.emptySet();
+    }
+
+    private static boolean isPlatformModule(String name) {
+        return name.startsWith("java.") || name.startsWith("jdk.");
+    }
+
+    /**
+     * Checks whether or not the given versioned module descriptor's attributes
+     * are valid when compared against the root module descriptor.
+     *
+     * A versioned module descriptor must be identical to the root module
+     * descriptor, with two exceptions:
+     *  - A versioned descriptor can have different non-public `requires`
+     *    clauses of platform ( `java.*` and `jdk.*` ) modules, and
+     *  - A versioned descriptor can have different `uses` clauses, even of
+     *    service types defined outside of the platform modules.
+     */
+    private void checkModuleDescriptor(JarEntry je) {
+        try (InputStream is = jf.getInputStream(je)) {
+            ModuleDescriptor root = this.md;
+            ModuleDescriptor md = null;
+            try {
+                md = ModuleDescriptor.read(is);
+            } catch (InvalidModuleDescriptorException x) {
+                error(x.getMessage());
+                isValid = false;
+                return;
+            }
+            if (root == null) {
+                this.md = md;
+            } else {
+                if (!root.name().equals(md.name())) {
+                    error(getMsg("error.versioned.info.name.notequal"));
+                    isValid = false;
+                }
+                if (!root.requires().equals(md.requires())) {
+                    Set<Requires> rootRequires = root.requires();
+                    for (Requires r : md.requires()) {
+                        if (rootRequires.contains(r))
+                            continue;
+                        if (r.modifiers().contains(Requires.Modifier.TRANSITIVE)) {
+                            error(getMsg("error.versioned.info.requires.transitive"));
+                            isValid = false;
+                        } else if (!isPlatformModule(r.name())) {
+                            error(getMsg("error.versioned.info.requires.added"));
+                            isValid = false;
+                        }
+                    }
+                    for (Requires r : rootRequires) {
+                        Set<Requires> mdRequires = md.requires();
+                        if (mdRequires.contains(r))
+                            continue;
+                        if (!isPlatformModule(r.name())) {
+                            error(getMsg("error.versioned.info.requires.dropped"));
+                            isValid = false;
+                        }
+                    }
+                }
+                if (!root.exports().equals(md.exports())) {
+                    error(getMsg("error.versioned.info.exports.notequal"));
+                    isValid = false;
+                }
+                if (!root.opens().equals(md.opens())) {
+                    error(getMsg("error.versioned.info.opens.notequal"));
+                    isValid = false;
+                }
+                if (!root.provides().equals(md.provides())) {
+                    error(getMsg("error.versioned.info.provides.notequal"));
+                    isValid = false;
+                }
+                if (!root.mainClass().equals(md.mainClass())) {
+                    error(formatMsg("error.validator.info.manclass.notequal", je.getName()));
+                    isValid = false;
+                }
+                if (!root.version().equals(md.version())) {
+                    error(formatMsg("error.validator.info.version.notequal", je.getName()));
+                    isValid = false;
+                }
+            }
+        } catch (IOException x) {
+            error(x.getMessage());
+            isValid = false;
+        }
+    }
+
     private boolean checkInternalName(String entryName, String basename, String internalName) {
         String className = className(basename);
         if (internalName.equals(className)) {
             return true;
         }
-        main.error(Main.formatMsg2("error.validator.names.mismatch",
+        error(formatMsg2("error.validator.names.mismatch",
                 entryName, internalName.replace("/", ".")));
         return false;
     }
@@ -231,7 +427,7 @@
             return true;
         }
         debug("top level class was not accepted");
-        main.error(Main.formatMsg("error.validator.isolated.nested.class", entryName));
+        error(formatMsg("error.validator.isolated.nested.class", entryName));
         return false;
     }
 
@@ -240,16 +436,24 @@
     }
 
     private boolean isConcealed(String internalName) {
-        if (main.concealedPackages.isEmpty()) {
+        if (concealedPkgs.isEmpty()) {
             return false;
         }
         int idx = internalName.lastIndexOf('/');
         String pkgName = idx != -1 ? internalName.substring(0, idx).replace('/', '.') : "";
-        return main.concealedPackages.contains(pkgName);
+        return concealedPkgs.contains(pkgName);
     }
 
     private void debug(String fmt, Object... args) {
         if (DEBUG) System.err.format(fmt, args);
     }
+
+    private void error(String msg) {
+        main.error(msg);
+    }
+
+    private void warn(String msg) {
+        main.warn(msg);
+    }
+
 }
-
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -66,23 +66,6 @@
         Unexpected module descriptor {0}
 error.module.descriptor.not.found=\
         Module descriptor not found
-error.versioned.info.without.root=\
-        module-info.class found in a versioned directory without module-info.class \
-        in the root
-error.versioned.info.name.notequal=\
-        module-info.class in a versioned directory contains incorrect name
-error.versioned.info.requires.transitive=\
-        module-info.class in a versioned directory contains additional "requires transitive"
-error.versioned.info.requires.added=\
-        module-info.class in a versioned directory contains additional "requires"
-error.versioned.info.requires.dropped=\
-        module-info.class in a versioned directory contains missing "requires"
-error.versioned.info.exports.notequal=\
-        module-info.class in a versioned directory contains different "exports"
-error.versioned.info.opens.notequal=\
-        module-info.class in a versioned directory contains different "opens"
-error.versioned.info.provides.notequal=\
-        module-info.class in a versioned directory contains different "provides"
 error.invalid.versioned.module.attribute=\
         Invalid module descriptor attribute {0}
 error.missing.provider=\
@@ -113,6 +96,24 @@
         entry: {0}, contains a class with different api from earlier version
 error.validator.names.mismatch=\
         entry: {0}, contains a class with internal name {1}, names do not match
+error.validator.info.name.notequal=\
+        module-info.class in a versioned directory contains incorrect name
+error.validator.info.requires.transitive=\
+        module-info.class in a versioned directory contains additional "requires transitive"
+error.validator.info.requires.added=\
+        module-info.class in a versioned directory contains additional "requires"
+error.validator.info.requires.dropped=\
+        module-info.class in a versioned directory contains missing "requires"
+error.validator.info.exports.notequal=\
+        module-info.class in a versioned directory contains different "exports"
+error.validator.info.opens.notequal=\
+        module-info.class in a versioned directory contains different "opens"
+error.validator.info.provides.notequal=\
+        module-info.class in a versioned directory contains different "provides"
+error.validator.info.version.notequal=\
+        {0}: module-info.class in a versioned directory contains different "version"
+error.validator.info.manclass.notequal=\
+        {0}: module-info.class in a versioned directory contains different "main-class"
 warn.validator.identical.entry=\
         Warning: entry {0} contains a class that\n\
         is identical to an entry already in the jar
@@ -122,6 +123,8 @@
         Warning: entry {0} is a public class\n\
         in a concealed package, placing this jar on the class path will result\n\
         in incompatible public interfaces
+warn.release.unexpected.versioned.entry=\
+        unexpected versioned entry {0}
 out.added.manifest=\
         added manifest
 out.added.module-info=\
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_de.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_de.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=--module-version oder --hash-modules ohne module-info.class
 error.unexpected.module-info=Unerwarteter Moduldeskriptor {0}
 error.module.descriptor.not.found=Moduldeskriptor nicht gefunden
-error.versioned.info.without.root=module-info.class in einem versionierten Verzeichnis gefunden, in der Root ist module-info.class jedoch nicht vorhanden
-error.versioned.info.name.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt falschen Namen
-error.versioned.info.requires.public=module-info.class in einem versionierten Verzeichnis enth\u00E4lt zus\u00E4tzlichen "requires public"
-error.versioned.info.requires.added=module-info.class in einem versionierten Verzeichnis enth\u00E4lt zus\u00E4tzlichen "requires"
-error.versioned.info.requires.dropped=module-info.class in einem versionierten Verzeichnis enth\u00E4lt fehlenden "requires"
-error.versioned.info.exports.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt unterschiedliche "exports"
-error.versioned.info.provides.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt unterschiedliche "provides"
+error.validator.info.without.root=module-info.class in einem versionierten Verzeichnis gefunden, in der Root ist module-info.class jedoch nicht vorhanden
+error.validator.info.name.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt falschen Namen
+error.validator.info.requires.public=module-info.class in einem versionierten Verzeichnis enth\u00E4lt zus\u00E4tzlichen "requires public"
+error.validator.info.requires.added=module-info.class in einem versionierten Verzeichnis enth\u00E4lt zus\u00E4tzlichen "requires"
+error.validator.info.requires.dropped=module-info.class in einem versionierten Verzeichnis enth\u00E4lt fehlenden "requires"
+error.validator.info.exports.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt unterschiedliche "exports"
+error.validator.info.provides.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt unterschiedliche "provides"
 error.invalid.versioned.module.attribute=Ung\u00FCltiges Moduldeskriptorattribut {0}
 error.missing.provider=Serviceprovider nicht gefunden: {0}
 error.release.value.notnumber=Release {0} nicht g\u00FCltig
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_es.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_es.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=Uno de --module-version o -hash-modules sin module-info.class
 error.unexpected.module-info=Descriptor de m\u00F3dulo inesperado {0}
 error.module.descriptor.not.found=No se ha encontrado el descriptor de m\u00F3dulo
-error.versioned.info.without.root=Se ha encontrado module-info.class en un directorio con versi\u00F3n sin module-info.class en la ra\u00EDz
-error.versioned.info.name.notequal=module-info.class en un directorio con versi\u00F3n contiene un nombre incorrecto
-error.versioned.info.requires.public=module-info.class en un directorio con versiones contiene "requires public" adicionales
-error.versioned.info.requires.added=module-info.class en un directorio con versi\u00F3n contiene "requires" adicionales
-error.versioned.info.requires.dropped=module-info.class en un directorio con versiones contiene "requires" que faltan
-error.versioned.info.exports.notequal=module-info.class en un directorio con versiones contiene "exports" diferentes
-error.versioned.info.provides.notequal=module-info.class en un directorio con versiones contiene "provides" diferentes
+error.validator.info.without.root=Se ha encontrado module-info.class en un directorio con versi\u00F3n sin module-info.class en la ra\u00EDz
+error.validator.info.name.notequal=module-info.class en un directorio con versi\u00F3n contiene un nombre incorrecto
+error.validator.info.requires.public=module-info.class en un directorio con versiones contiene "requires public" adicionales
+error.validator.info.requires.added=module-info.class en un directorio con versi\u00F3n contiene "requires" adicionales
+error.validator.info.requires.dropped=module-info.class en un directorio con versiones contiene "requires" que faltan
+error.validator.info.exports.notequal=module-info.class en un directorio con versiones contiene "exports" diferentes
+error.validator.info.provides.notequal=module-info.class en un directorio con versiones contiene "provides" diferentes
 error.invalid.versioned.module.attribute=Atributo de descriptor de m\u00F3dulo no v\u00E1lido {0}
 error.missing.provider=No se ha encontrado el proveedor de servicios: {0}
 error.release.value.notnumber=versi\u00F3n {0} no v\u00E1lida
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_fr.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_fr.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=Une des options --module-version ou --hash-modules sans module-info.class
 error.unexpected.module-info=Descripteur de module {0} inattendu
 error.module.descriptor.not.found=Descripteur de module introuvable
-error.versioned.info.without.root=module-info.class a \u00E9t\u00E9 d\u00E9tect\u00E9 dans un r\u00E9pertoire avec num\u00E9ro de version sans module-info.class dans la racine
-error.versioned.info.name.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient un nom incorrect
-error.versioned.info.requires.public=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires public" suppl\u00E9mentaires
-error.versioned.info.requires.added=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires" suppl\u00E9mentaires
-error.versioned.info.requires.dropped=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires" manquants
-error.versioned.info.exports.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "exports" diff\u00E9rents
-error.versioned.info.provides.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "provides" diff\u00E9rents
+error.validator.info.without.root=module-info.class a \u00E9t\u00E9 d\u00E9tect\u00E9 dans un r\u00E9pertoire avec num\u00E9ro de version sans module-info.class dans la racine
+error.validator.info.name.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient un nom incorrect
+error.validator.info.requires.public=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires public" suppl\u00E9mentaires
+error.validator.info.requires.added=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires" suppl\u00E9mentaires
+error.validator.info.requires.dropped=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires" manquants
+error.validator.info.exports.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "exports" diff\u00E9rents
+error.validator.info.provides.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "provides" diff\u00E9rents
 error.invalid.versioned.module.attribute=Attribut de descripteur de module non valide {0}
 error.missing.provider=Fournisseur de services introuvable : {0}
 error.release.value.notnumber=version {0} non valide
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_it.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_it.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=Una delle opzioni --module-version o --hash-modules non contiene module-info.class
 error.unexpected.module-info=Descrittore di modulo {0} imprevisto
 error.module.descriptor.not.found=Descrittore di modulo non trovato
-error.versioned.info.without.root=module-info.class trovato in una directory con controllo delle versioni senza module-info.class nella radice
-error.versioned.info.name.notequal=module-info.class in una directory con controllo delle versioni contiene un nome errato
-error.versioned.info.requires.public=module-info.class in una directory con controllo delle versioni contiene valori "requires public" aggiuntivi
-error.versioned.info.requires.added=module-info.class in una directory con controllo delle versioni contiene valori "requires" aggiuntivi
-error.versioned.info.requires.dropped=module-info.class in una directory con controllo delle versioni contiene valori "requires" mancanti
-error.versioned.info.exports.notequal=module-info.class in una directory con controllo delle versioni contiene "exports" differenti
-error.versioned.info.provides.notequal=module-info.class in una directory con controllo delle versioni contiene valori "provides" differenti
+error.validator.info.without.root=module-info.class trovato in una directory con controllo delle versioni senza module-info.class nella radice
+error.validator.info.name.notequal=module-info.class in una directory con controllo delle versioni contiene un nome errato
+error.validator.info.requires.public=module-info.class in una directory con controllo delle versioni contiene valori "requires public" aggiuntivi
+error.validator.info.requires.added=module-info.class in una directory con controllo delle versioni contiene valori "requires" aggiuntivi
+error.validator.info.requires.dropped=module-info.class in una directory con controllo delle versioni contiene valori "requires" mancanti
+error.validator.info.exports.notequal=module-info.class in una directory con controllo delle versioni contiene "exports" differenti
+error.validator.info.provides.notequal=module-info.class in una directory con controllo delle versioni contiene valori "provides" differenti
 error.invalid.versioned.module.attribute=Attributo descrittore del modulo {0} non valido.
 error.missing.provider=Provider di servizi non trovato: {0}
 error.release.value.notnumber=release {0} non valida
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ja.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ja.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=--module-version\u307E\u305F\u306F--hash-modules\u306E\u3044\u305A\u308C\u304B\u3067module-info.class\u304C\u3042\u308A\u307E\u305B\u3093
 error.unexpected.module-info=\u4E88\u671F\u3057\u306A\u3044\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF{0}
 error.module.descriptor.not.found=\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
-error.versioned.info.without.root=module-info.class\u304C\u3001\u30EB\u30FC\u30C8\u306Bmodule-info.class\u306E\u306A\u3044\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u898B\u3064\u304B\u308A\u307E\u3057\u305F
-error.versioned.info.name.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u6B63\u3057\u304F\u306A\u3044\u540D\u524D\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
-error.versioned.info.requires.public=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u8FFD\u52A0\u306E"requires public"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
-error.versioned.info.requires.added=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u8FFD\u52A0\u306E"requires"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
-error.versioned.info.requires.dropped=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u6B20\u843D\u3057\u3066\u3044\u308B"requires"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
-error.versioned.info.exports.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u7570\u306A\u308B"exports"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
-error.versioned.info.provides.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u7570\u306A\u308B"provides"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
+error.validator.info.without.root=module-info.class\u304C\u3001\u30EB\u30FC\u30C8\u306Bmodule-info.class\u306E\u306A\u3044\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u898B\u3064\u304B\u308A\u307E\u3057\u305F
+error.validator.info.name.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u6B63\u3057\u304F\u306A\u3044\u540D\u524D\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
+error.validator.info.requires.public=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u8FFD\u52A0\u306E"requires public"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
+error.validator.info.requires.added=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u8FFD\u52A0\u306E"requires"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
+error.validator.info.requires.dropped=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u6B20\u843D\u3057\u3066\u3044\u308B"requires"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
+error.validator.info.exports.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u7570\u306A\u308B"exports"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
+error.validator.info.provides.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u7570\u306A\u308B"provides"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
 error.invalid.versioned.module.attribute=\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u5C5E\u6027{0}\u304C\u7121\u52B9\u3067\u3059
 error.missing.provider=\u30B5\u30FC\u30D3\u30B9\u30FB\u30D7\u30ED\u30D0\u30A4\u30C0\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0}
 error.release.value.notnumber=\u30EA\u30EA\u30FC\u30B9{0}\u306F\u6709\u52B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ko.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ko.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=module-info.class \uC5C6\uC774 --module-version \uB610\uB294 --hash-modules \uC911 \uD558\uB098
 error.unexpected.module-info=\uC608\uC0C1\uCE58 \uC54A\uC740 \uBAA8\uB4C8 \uAE30\uC220\uC790 {0}
 error.module.descriptor.not.found=\uBAA8\uB4C8 \uAE30\uC220\uC790\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C
-error.versioned.info.without.root=\uB8E8\uD2B8\uC5D0\uC11C module-info.class \uC5C6\uC774 \uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC5D0\uC11C module-info.class\uAC00 \uBC1C\uACAC\uB428
-error.versioned.info.name.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uC798\uBABB\uB41C \uC774\uB984\uC774 \uD3EC\uD568\uB428
-error.versioned.info.requires.public=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uCD94\uAC00 "requires public" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
-error.versioned.info.requires.added=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uCD94\uAC00 "requires" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
-error.versioned.info.requires.dropped=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB204\uB77D\uB41C "requires" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
-error.versioned.info.exports.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB2E4\uB978 "exports" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
-error.versioned.info.provides.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB2E4\uB978 "provides" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
+error.validator.info.without.root=\uB8E8\uD2B8\uC5D0\uC11C module-info.class \uC5C6\uC774 \uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC5D0\uC11C module-info.class\uAC00 \uBC1C\uACAC\uB428
+error.validator.info.name.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uC798\uBABB\uB41C \uC774\uB984\uC774 \uD3EC\uD568\uB428
+error.validator.info.requires.public=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uCD94\uAC00 "requires public" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
+error.validator.info.requires.added=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uCD94\uAC00 "requires" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
+error.validator.info.requires.dropped=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB204\uB77D\uB41C "requires" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
+error.validator.info.exports.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB2E4\uB978 "exports" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
+error.validator.info.provides.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB2E4\uB978 "provides" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428
 error.invalid.versioned.module.attribute=\uBD80\uC801\uD569\uD55C \uBAA8\uB4C8 \uAE30\uC220\uC790 \uC18D\uC131 {0}
 error.missing.provider=\uC11C\uBE44\uC2A4 \uC81C\uACF5\uC790\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}
 error.release.value.notnumber=\uB9B4\uB9AC\uC2A4 {0}\uC774(\uAC00) \uBD80\uC801\uD569\uD568
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_pt_BR.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_pt_BR.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=Um dentre --module-version ou --hash-modules est\u00E1 sem module-info.class
 error.unexpected.module-info=Descritor de m\u00F3dulo inesperado {0}
 error.module.descriptor.not.found=Descritor de m\u00F3dulo n\u00E3o encontrado
-error.versioned.info.without.root=module-info.class encontrado em um diret\u00F3rio com controle de vers\u00E3o sem module-info.class na raiz
-error.versioned.info.name.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m nome incorreto
-error.versioned.info.requires.public=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "requires public" adicional
-error.versioned.info.requires.added=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "requires" adicional
-error.versioned.info.requires.dropped=module-info.class em um diret\u00F3rio com controle de vers\u00E3o falta "requires"
-error.versioned.info.exports.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "exports" diferente
-error.versioned.info.provides.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "provides" diferente
+error.validator.info.without.root=module-info.class encontrado em um diret\u00F3rio com controle de vers\u00E3o sem module-info.class na raiz
+error.validator.info.name.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m nome incorreto
+error.validator.info.requires.public=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "requires public" adicional
+error.validator.info.requires.added=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "requires" adicional
+error.validator.info.requires.dropped=module-info.class em um diret\u00F3rio com controle de vers\u00E3o falta "requires"
+error.validator.info.exports.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "exports" diferente
+error.validator.info.provides.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "provides" diferente
 error.invalid.versioned.module.attribute=Atributo {0} de descritor de m\u00F3dulo inv\u00E1lido
 error.missing.provider=Prestador de servi\u00E7os  n\u00E3o encontrado: {0}
 error.release.value.notnumber=release {0} n\u00E3o v\u00E1lida
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_sv.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_sv.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=--module-version eller --hash-modules utan module-info.class
 error.unexpected.module-info=Ov\u00E4ntad moduldeskriptor, {0}
 error.module.descriptor.not.found=Moduldeskriptorn hittades inte
-error.versioned.info.without.root=module-info.class hittades i en versionshanterad katalog utan module-info.class i roten
-error.versioned.info.name.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller ett felaktigt namn
-error.versioned.info.requires.public=module-info.class i en versionshanterad katalog inneh\u00E5ller fler "requires public"
-error.versioned.info.requires.added=module-info.class i en versionshanterad katalog inneh\u00E5ller fler "requires"
-error.versioned.info.requires.dropped=module-info.class i en versionshanterad katalog inneh\u00E5ller saknade "requires"
-error.versioned.info.exports.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller olika "exports"
-error.versioned.info.provides.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller olika "provides"
+error.validator.info.without.root=module-info.class hittades i en versionshanterad katalog utan module-info.class i roten
+error.validator.info.name.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller ett felaktigt namn
+error.validator.info.requires.public=module-info.class i en versionshanterad katalog inneh\u00E5ller fler "requires public"
+error.validator.info.requires.added=module-info.class i en versionshanterad katalog inneh\u00E5ller fler "requires"
+error.validator.info.requires.dropped=module-info.class i en versionshanterad katalog inneh\u00E5ller saknade "requires"
+error.validator.info.exports.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller olika "exports"
+error.validator.info.provides.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller olika "provides"
 error.invalid.versioned.module.attribute=Ogiltigt attribut f\u00F6r moduldeskriptor, {0}
 error.missing.provider=Tj\u00E4nsteleverant\u00F6ren hittades inte: {0}
 error.release.value.notnumber=utg\u00E5va {0} \u00E4r inte giltig
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_CN.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_CN.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=--module-version \u6216 --hash-modules \u4E4B\u4E00\u6CA1\u6709 module-info.class
 error.unexpected.module-info=\u610F\u5916\u7684\u6A21\u5757\u63CF\u8FF0\u7B26 {0}
 error.module.descriptor.not.found=\u627E\u4E0D\u5230\u6A21\u5757\u63CF\u8FF0\u7B26
-error.versioned.info.without.root=\u5728\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u627E\u5230\u4E86 module-info.class, \u4F46\u6839\u4E2D\u6CA1\u6709 module-info.class
-error.versioned.info.name.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u6B63\u786E\u7684\u540D\u79F0
-error.versioned.info.requires.public=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u989D\u5916\u7684 "requires public"
-error.versioned.info.requires.added=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u989D\u5916\u7684 "requires"
-error.versioned.info.requires.dropped=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u7F3A\u5C11\u7684 "requires"
-error.versioned.info.exports.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "exports"
-error.versioned.info.provides.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "provides"
+error.validator.info.without.root=\u5728\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u627E\u5230\u4E86 module-info.class, \u4F46\u6839\u4E2D\u6CA1\u6709 module-info.class
+error.validator.info.name.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u6B63\u786E\u7684\u540D\u79F0
+error.validator.info.requires.public=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u989D\u5916\u7684 "requires public"
+error.validator.info.requires.added=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u989D\u5916\u7684 "requires"
+error.validator.info.requires.dropped=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u7F3A\u5C11\u7684 "requires"
+error.validator.info.exports.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "exports"
+error.validator.info.provides.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "provides"
 error.invalid.versioned.module.attribute=\u65E0\u6548\u7684\u6A21\u5757\u63CF\u8FF0\u7B26\u5C5E\u6027 {0}
 error.missing.provider=\u672A\u627E\u5230\u670D\u52A1\u63D0\u4F9B\u65B9: {0}
 error.release.value.notnumber=\u53D1\u884C\u7248 {0} \u65E0\u6548
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_TW.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_TW.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -42,13 +42,13 @@
 error.module.options.without.info=--module-version \u6216 --hash-modules \u5176\u4E2D\u4E00\u500B\u6C92\u6709 module-info.class
 error.unexpected.module-info=\u672A\u9810\u671F\u7684\u6A21\u7D44\u63CF\u8FF0\u5340 {0}
 error.module.descriptor.not.found=\u627E\u4E0D\u5230\u6A21\u7D44\u63CF\u8FF0\u5340
-error.versioned.info.without.root=\u5728\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u767C\u73FE module-info.class\uFF0C\u4F46\u662F\u6839\u4E2D\u6C92\u6709 module-info.class
-error.versioned.info.name.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u6B63\u78BA\u7684\u540D\u7A31
-error.versioned.info.requires.public=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u984D\u5916\u7684 "requires public"
-error.versioned.info.requires.added=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u984D\u5916\u7684 "requires"
-error.versioned.info.requires.dropped=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u907A\u6F0F\u7684 "requires"
-error.versioned.info.exports.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "exports"
-error.versioned.info.provides.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "provides"
+error.validator.info.without.root=\u5728\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u767C\u73FE module-info.class\uFF0C\u4F46\u662F\u6839\u4E2D\u6C92\u6709 module-info.class
+error.validator.info.name.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u6B63\u78BA\u7684\u540D\u7A31
+error.validator.info.requires.public=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u984D\u5916\u7684 "requires public"
+error.validator.info.requires.added=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u984D\u5916\u7684 "requires"
+error.validator.info.requires.dropped=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u907A\u6F0F\u7684 "requires"
+error.validator.info.exports.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "exports"
+error.validator.info.provides.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "provides"
 error.invalid.versioned.module.attribute=\u6A21\u7D44\u63CF\u8FF0\u5340\u5C6C\u6027 {0} \u7121\u6548
 error.missing.provider=\u627E\u4E0D\u5230\u670D\u52D9\u63D0\u4F9B\u8005: {0}
 error.release.value.notnumber=\u7248\u672C {0} \u7121\u6548
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Tue Jan 24 00:30:25 2017 +0100
@@ -162,22 +162,13 @@
             });
 
             if (this.targetOsName == null) {
-                throw new PluginException("TargetPlatform attribute is missing for java.base module");
+                throw new PluginException("ModuleTarget attribute is missing for java.base module");
             }
 
+            checkResourcePool(files);
+
             Path bin = root.resolve(BIN_DIRNAME);
 
-            // check any duplicated resource files
-            Map<Path, Set<String>> duplicates = new HashMap<>();
-            files.entries()
-                .filter(f -> f.type() != ResourcePoolEntry.Type.CLASS_OR_RESOURCE)
-                .collect(groupingBy(this::entryToImagePath,
-                         mapping(ResourcePoolEntry::moduleName, toSet())))
-                .entrySet()
-                .stream()
-                .filter(e -> e.getValue().size() > 1)
-                .forEach(e -> duplicates.put(e.getKey(), e.getValue()));
-
             // write non-classes resource files to the image
             files.entries()
                 .filter(f -> f.type() != ResourcePoolEntry.Type.CLASS_OR_RESOURCE)
@@ -185,13 +176,8 @@
                     try {
                         accept(f);
                     } catch (FileAlreadyExistsException e) {
-                        // error for duplicated entries
-                        Path path = entryToImagePath(f);
-                        UncheckedIOException x =
-                            new UncheckedIOException(path + " duplicated in " +
-                                    duplicates.get(path), e);
-                        x.addSuppressed(e);
-                        throw x;
+                        // Should not happen! Duplicates checking already done!
+                        throw new AssertionError("Duplicate entry!", e);
                     } catch (IOException ioExp) {
                         throw new UncheckedIOException(ioExp);
                     }
@@ -242,6 +228,27 @@
         }
     }
 
+    private void checkResourcePool(ResourcePool pool) {
+        // For now, only duplicate resources check. Add more checks here (if any)
+        checkDuplicateResources(pool);
+    }
+
+    private void checkDuplicateResources(ResourcePool pool) {
+        // check any duplicated resources
+        Map<Path, Set<String>> duplicates = new HashMap<>();
+        pool.entries()
+             .filter(f -> f.type() != ResourcePoolEntry.Type.CLASS_OR_RESOURCE)
+             .collect(groupingBy(this::entryToImagePath,
+                      mapping(ResourcePoolEntry::moduleName, toSet())))
+             .entrySet()
+             .stream()
+             .filter(e -> e.getValue().size() > 1)
+             .forEach(e -> duplicates.put(e.getKey(), e.getValue()));
+        if (!duplicates.isEmpty()) {
+            throw new PluginException("Duplicate resources: " + duplicates);
+        }
+    }
+
     /**
      * Generates launcher scripts.
      *
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,13 +58,10 @@
 import java.nio.file.StandardCopyOption;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.text.MessageFormat;
-import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Deque;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -76,7 +73,6 @@
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.function.Consumer;
-import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
 import java.util.jar.JarEntry;
@@ -101,6 +97,7 @@
 import jdk.internal.joptsimple.ValueConverter;
 import jdk.internal.loader.ResourceHelper;
 import jdk.internal.module.ModuleHashes;
+import jdk.internal.module.ModuleHashesBuilder;
 import jdk.internal.module.ModuleInfo;
 import jdk.internal.module.ModuleInfoExtender;
 import jdk.internal.module.ModulePath;
@@ -286,7 +283,27 @@
     }
 
     private boolean hashModules() {
-        return new Hasher(options.moduleFinder).run();
+        if (options.dryrun) {
+            out.println("Dry run:");
+        }
+
+        Hasher hasher = new Hasher(options.moduleFinder);
+        hasher.computeHashes().forEach((mn, hashes) -> {
+            if (options.dryrun) {
+                out.format("%s%n", mn);
+                hashes.names().stream()
+                    .sorted()
+                    .forEach(name -> out.format("  hashes %s %s %s%n",
+                        name, hashes.algorithm(), toHex(hashes.hashFor(name))));
+            } else {
+                try {
+                    hasher.updateModuleInfo(mn, hashes);
+                } catch (IOException ex) {
+                    throw new UncheckedIOException(ex);
+                }
+            }
+        });
+        return true;
     }
 
     private boolean describe() throws IOException {
@@ -377,25 +394,30 @@
         // create jmod with temporary name to avoid it being examined
         // when scanning the module path
         Path target = options.jmodFile;
-        Path tempTarget = target.resolveSibling(target.getFileName() + ".tmp");
+        Path tempTarget = jmodTempFilePath(target);
         try {
             try (JmodOutputStream jos = JmodOutputStream.newOutputStream(tempTarget)) {
                 jmod.write(jos);
             }
             Files.move(tempTarget, target);
         } catch (Exception e) {
-            if (Files.exists(tempTarget)) {
-                try {
-                    Files.delete(tempTarget);
-                } catch (IOException ioe) {
-                    e.addSuppressed(ioe);
-                }
+            try {
+                Files.deleteIfExists(tempTarget);
+            } catch (IOException ioe) {
+                e.addSuppressed(ioe);
             }
             throw e;
         }
         return true;
     }
 
+    /*
+     * Create a JMOD .tmp file for the given target JMOD file
+     */
+    private static Path jmodTempFilePath(Path target) throws IOException {
+        return target.resolveSibling("." + target.getFileName() + ".tmp");
+    }
+
     private class JmodFileWriter {
         final List<Path> cmds = options.cmds;
         final List<Path> libs = options.libs;
@@ -411,7 +433,6 @@
         final String osArch = options.osArch;
         final String osVersion = options.osVersion;
         final List<PathMatcher> excludes = options.excludes;
-        final Hasher hasher = hasher();
         final ModuleResolution moduleResolution = options.moduleResolution;
 
         JmodFileWriter() { }
@@ -514,8 +535,17 @@
                 if (moduleVersion != null)
                     extender.version(moduleVersion);
 
-                if (hasher != null) {
-                    ModuleHashes moduleHashes = hasher.computeHashes(descriptor.name());
+                // --hash-modules
+                if (options.modulesToHash != null) {
+                    // To compute hashes, it creates a Configuration to resolve
+                    // a module graph.  The post-resolution check requires
+                    // the packages in ModuleDescriptor be available for validation.
+                    ModuleDescriptor md;
+                    try (InputStream is = miSupplier.get()) {
+                        md = ModuleDescriptor.read(is, () -> packages);
+                    }
+
+                    ModuleHashes moduleHashes = computeHashes(md);
                     if (moduleHashes != null) {
                         extender.hashes(moduleHashes);
                     } else {
@@ -557,50 +587,34 @@
          * The jmod file is being created and does not exist in the
          * given modulepath.
          */
-        private Hasher hasher() {
-            if (options.modulesToHash == null)
-                return null;
-
-            try {
-                Supplier<InputStream> miSupplier = newModuleInfoSupplier();
-                if (miSupplier == null) {
-                    throw new IOException(MODULE_INFO + " not found");
+        private ModuleHashes computeHashes(ModuleDescriptor descriptor) {
+            String mn = descriptor.name();
+            URI uri = options.jmodFile.toUri();
+            ModuleReference mref = new ModuleReference(descriptor, uri) {
+                @Override
+                public ModuleReader open() {
+                    throw new UnsupportedOperationException("opening " + mn);
                 }
+            };
 
-                ModuleDescriptor descriptor;
-                try (InputStream in = miSupplier.get()) {
-                    descriptor = ModuleDescriptor.read(in);
-                }
-
-                URI uri = options.jmodFile.toUri();
-                ModuleReference mref = new ModuleReference(descriptor, uri) {
+            // compose a module finder with the module path and also
+            // a module finder that can find the jmod file being created
+            ModuleFinder finder = ModuleFinder.compose(options.moduleFinder,
+                new ModuleFinder() {
                     @Override
-                    public ModuleReader open() {
-                        throw new UnsupportedOperationException();
+                    public Optional<ModuleReference> find(String name) {
+                        if (descriptor.name().equals(name))
+                            return Optional.of(mref);
+                        else return Optional.empty();
                     }
-                };
 
-                // compose a module finder with the module path and also
-                // a module finder that can find the jmod file being created
-                ModuleFinder finder = ModuleFinder.compose(options.moduleFinder,
-                    new ModuleFinder() {
-                        @Override
-                        public Optional<ModuleReference> find(String name) {
-                            if (descriptor.name().equals(name))
-                                return Optional.of(mref);
-                            else return Optional.empty();
-                        }
+                    @Override
+                    public Set<ModuleReference> findAll() {
+                        return Collections.singleton(mref);
+                    }
+                });
 
-                        @Override
-                        public Set<ModuleReference> findAll() {
-                            return Collections.singleton(mref);
-                        }
-                    });
-
-                return new Hasher(finder);
-            } catch (IOException e) {
-                throw new UncheckedIOException(e);
-            }
+            return new Hasher(mn, finder).computeHashes().get(mn);
         }
 
         /**
@@ -789,192 +803,93 @@
      * Compute and record hashes
      */
     private class Hasher {
-        final ModuleFinder moduleFinder;
-        final Map<String, Path> moduleNameToPath;
+        final Configuration configuration;
+        final ModuleHashesBuilder hashesBuilder;
         final Set<String> modules;
-        final Configuration configuration;
-        final boolean dryrun = options.dryrun;
+        final String moduleName;  // a specific module to record hashes, if set
+
+        /**
+         * This constructor is for jmod hash command.
+         *
+         * This Hasher will determine which modules to record hashes, i.e.
+         * the module in a subgraph of modules to be hashed and that
+         * has no outgoing edges.  It will record in each of these modules,
+         * say `M`, with the the hashes of modules that depend upon M
+         * directly or indirectly matching the specified --hash-modules pattern.
+         */
         Hasher(ModuleFinder finder) {
-            this.moduleFinder = finder;
+            this(null, finder);
+        }
+
+        /**
+         * Constructs a Hasher to compute hashes.
+         *
+         * If a module name `M` is specified, it will compute the hashes of
+         * modules that depend upon M directly or indirectly matching the
+         * specified --hash-modules pattern and record in the ModuleHashes
+         * attribute in M's module-info.class.
+         *
+         * @param name    name of the module to record hashes
+         * @param finder  module finder for the specified --module-path
+         */
+        Hasher(String name, ModuleFinder finder) {
             // Determine the modules that matches the pattern {@code modulesToHash}
-            this.modules = moduleFinder.findAll().stream()
+            Set<String> roots = finder.findAll().stream()
                 .map(mref -> mref.descriptor().name())
                 .filter(mn -> options.modulesToHash.matcher(mn).find())
                 .collect(Collectors.toSet());
 
-            // a map from a module name to Path of the packaged module
-            this.moduleNameToPath = moduleFinder.findAll().stream()
-                .map(mref -> mref.descriptor().name())
-                .collect(Collectors.toMap(Function.identity(), mn -> moduleToPath(mn)));
-
+            // use system module path unless it creates a JMOD file for
+            // a module that is present in the system image e.g. upgradeable
+            // module
+            ModuleFinder system;
+            if (name != null && ModuleFinder.ofSystem().find(name).isPresent()) {
+                system = ModuleFinder.of();
+            } else {
+                system = ModuleFinder.ofSystem();
+            }
             // get a resolved module graph
             Configuration config = null;
             try {
-                config = Configuration.empty()
-                    .resolveRequires(ModuleFinder.ofSystem(), moduleFinder, modules);
+                config = Configuration.empty().resolveRequires(system, finder, roots);
             } catch (ResolutionException e) {
-                warning("warn.module.resolution.fail", e.getMessage());
+                throw new CommandException("err.module.resolution.fail", e.getMessage());
             }
+
+            this.moduleName = name;
             this.configuration = config;
+
+            // filter modules resolved from the system module finder
+            this.modules = config.modules().stream()
+                .map(ResolvedModule::name)
+                .filter(mn -> roots.contains(mn) && !system.find(mn).isPresent())
+                .collect(Collectors.toSet());
+
+            this.hashesBuilder = new ModuleHashesBuilder(config, modules);
         }
 
         /**
-         * This method is for jmod hash command.
+         * Returns a map of a module M to record hashes of the modules
+         * that depend upon M directly or indirectly.
          *
-         * Identify the base modules in the module graph, i.e. no outgoing edge
-         * to any of the modules to be hashed.
+         * For jmod hash command, the returned map contains one entry
+         * for each module M that has no outgoing edges to any of the
+         * modules matching the specified --hash-modules pattern.
          *
-         * For each base module M, compute the hashes of all modules that depend
-         * upon M directly or indirectly.  Then update M's module-info.class
-         * to record the hashes.
+         * Each entry represents a leaf node in a connected subgraph containing
+         * M and other candidate modules from the module graph where M's outgoing
+         * edges to any module other than the ones matching the specified
+         * --hash-modules pattern are excluded.
          */
-        boolean run() {
-            if (configuration == null)
-                return false;
-
-            // transposed graph containing the the packaged modules and
-            // its transitive dependences matching --hash-modules
-            Map<String, Set<String>> graph = new HashMap<>();
-            for (String root : modules) {
-                Deque<String> deque = new ArrayDeque<>();
-                deque.add(root);
-                Set<String> visited = new HashSet<>();
-                while (!deque.isEmpty()) {
-                    String mn = deque.pop();
-                    if (!visited.contains(mn)) {
-                        visited.add(mn);
-
-                        if (modules.contains(mn))
-                            graph.computeIfAbsent(mn, _k -> new HashSet<>());
-
-                        ResolvedModule resolvedModule = configuration.findModule(mn).get();
-                        for (ResolvedModule dm : resolvedModule.reads()) {
-                            String name = dm.name();
-                            if (!visited.contains(name)) {
-                                deque.push(name);
-                            }
-
-                            // reverse edge
-                            if (modules.contains(name) && modules.contains(mn)) {
-                                graph.computeIfAbsent(name, _k -> new HashSet<>()).add(mn);
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (dryrun)
-                out.println("Dry run:");
-
-            // each node in a transposed graph is a matching packaged module
-            // in which the hash of the modules that depend upon it is recorded
-            graph.entrySet().stream()
-                .filter(e -> !e.getValue().isEmpty())
-                .forEach(e -> {
-                    String mn = e.getKey();
-                    Map<String, Path> modulesForHash = e.getValue().stream()
-                            .collect(Collectors.toMap(Function.identity(),
-                                                      moduleNameToPath::get));
-                    ModuleHashes hashes = ModuleHashes.generate(modulesForHash, "SHA-256");
-                    if (dryrun) {
-                        out.format("%s%n", mn);
-                        hashes.names().stream()
-                              .sorted()
-                              .forEach(name -> out.format("  hashes %s %s %s%n",
-                                  name, hashes.algorithm(), hashes.hashFor(name)));
-                    } else {
-                        try {
-                            updateModuleInfo(mn, hashes);
-                        } catch (IOException ex) {
-                            throw new UncheckedIOException(ex);
-                        }
-                    }
-                });
-            return true;
-        }
-
-        /**
-         * Compute hashes of the specified module.
-         *
-         * It records the hashing modules that depend upon the specified
-         * module directly or indirectly.
-         */
-        ModuleHashes computeHashes(String name) {
-            if (configuration == null)
+        Map<String, ModuleHashes> computeHashes() {
+            if (hashesBuilder == null)
                 return null;
 
-            // the transposed graph includes all modules in the resolved graph
-            Map<String, Set<String>> graph = transpose();
-
-            // find the modules that transitively depend upon the specified name
-            Deque<String> deque = new ArrayDeque<>();
-            deque.add(name);
-            Set<String> mods = visitNodes(graph, deque);
-
-            // filter modules matching the pattern specified --hash-modules
-            // as well as itself as the jmod file is being generated
-            Map<String, Path> modulesForHash = mods.stream()
-                .filter(mn -> !mn.equals(name) && modules.contains(mn))
-                .collect(Collectors.toMap(Function.identity(), moduleNameToPath::get));
-
-            if (modulesForHash.isEmpty())
-                return null;
-
-           return ModuleHashes.generate(modulesForHash, "SHA-256");
-        }
-
-        /**
-         * Returns all nodes traversed from the given roots.
-         */
-        private Set<String> visitNodes(Map<String, Set<String>> graph,
-                                       Deque<String> roots) {
-            Set<String> visited = new HashSet<>();
-            while (!roots.isEmpty()) {
-                String mn = roots.pop();
-                if (!visited.contains(mn)) {
-                    visited.add(mn);
-                    // the given roots may not be part of the graph
-                    if (graph.containsKey(mn)) {
-                        for (String dm : graph.get(mn)) {
-                            if (!visited.contains(dm)) {
-                                roots.push(dm);
-                            }
-                        }
-                    }
-                }
+            if (moduleName != null) {
+                return hashesBuilder.computeHashes(Set.of(moduleName));
+            } else {
+                return hashesBuilder.computeHashes(modules);
             }
-            return visited;
-        }
-
-        /**
-         * Returns a transposed graph from the resolved module graph.
-         */
-        private Map<String, Set<String>> transpose() {
-            Map<String, Set<String>> transposedGraph = new HashMap<>();
-            Deque<String> deque = new ArrayDeque<>(modules);
-
-            Set<String> visited = new HashSet<>();
-            while (!deque.isEmpty()) {
-                String mn = deque.pop();
-                if (!visited.contains(mn)) {
-                    visited.add(mn);
-
-                    transposedGraph.computeIfAbsent(mn, _k -> new HashSet<>());
-
-                    ResolvedModule resolvedModule = configuration.findModule(mn).get();
-                    for (ResolvedModule dm : resolvedModule.reads()) {
-                        String name = dm.name();
-                        if (!visited.contains(name)) {
-                            deque.push(name);
-                        }
-
-                        // reverse edge
-                        transposedGraph.computeIfAbsent(name, _k -> new HashSet<>())
-                                .add(mn);
-                    }
-                }
-            }
-            return transposedGraph;
         }
 
         /**
@@ -993,11 +908,11 @@
             extender.write(out);
         }
 
-        private void updateModuleInfo(String name, ModuleHashes moduleHashes)
+        void updateModuleInfo(String name, ModuleHashes moduleHashes)
             throws IOException
         {
-            Path target = moduleNameToPath.get(name);
-            Path tempTarget = target.resolveSibling(target.getFileName() + ".tmp");
+            Path target = moduleToPath(name);
+            Path tempTarget = jmodTempFilePath(target);
             try {
                 if (target.getFileName().toString().endsWith(".jmod")) {
                     updateJmodFile(target, tempTarget, moduleHashes);
@@ -1005,12 +920,10 @@
                     updateModularJar(target, tempTarget, moduleHashes);
                 }
             } catch (IOException|RuntimeException e) {
-                if (Files.exists(tempTarget)) {
-                    try {
-                        Files.delete(tempTarget);
-                    } catch (IOException ioe) {
-                        e.addSuppressed(ioe);
-                    }
+                try {
+                    Files.deleteIfExists(tempTarget);
+                } catch (IOException ioe) {
+                    e.addSuppressed(ioe);
                 }
                 throw e;
             }
@@ -1075,10 +988,10 @@
         }
 
         private Path moduleToPath(String name) {
-            ModuleReference mref = moduleFinder.find(name).orElseThrow(
+            ResolvedModule rm = configuration.findModule(name).orElseThrow(
                 () -> new InternalError("Selected module " + name + " not on module path"));
 
-            URI uri = mref.location().get();
+            URI uri = rm.reference().location().get();
             Path path = Paths.get(uri);
             String fn = path.getFileName().toString();
             if (!fn.endsWith(".jar") && !fn.endsWith(".jmod")) {
@@ -1088,34 +1001,58 @@
         }
     }
 
-    static class ClassPathConverter implements ValueConverter<Path> {
-        static final ValueConverter<Path> INSTANCE = new ClassPathConverter();
+    /**
+     * An abstract converter that given a string representing a list of paths,
+     * separated by the File.pathSeparator, returns a List of java.nio.Path's.
+     * Specific subclasses should do whatever validation is required on the
+     * individual path elements, if any.
+     */
+    static abstract class AbstractPathConverter implements ValueConverter<List<Path>> {
+        @Override
+        public List<Path> convert(String value) {
+            List<Path> paths = new ArrayList<>();
+            String[] pathElements = value.split(File.pathSeparator);
+            for (String pathElement : pathElements) {
+                paths.add(toPath(pathElement));
+            }
+            return paths;
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public Class<List<Path>> valueType() {
+            return (Class<List<Path>>)(Object)List.class;
+        }
+
+        @Override public String valuePattern() { return "path"; }
+
+        abstract Path toPath(String path);
+    }
+
+    static class ClassPathConverter extends AbstractPathConverter {
+        static final ValueConverter<List<Path>> INSTANCE = new ClassPathConverter();
 
         @Override
-        public Path convert(String value) {
+        public Path toPath(String value) {
             try {
                 Path path = CWD.resolve(value);
                 if (Files.notExists(path))
                     throw new CommandException("err.path.not.found", path);
-                if (! (Files.isDirectory(path) ||
-                       (Files.isRegularFile(path) && path.toString().endsWith(".jar"))))
+                if (!(Files.isDirectory(path) ||
+                        (Files.isRegularFile(path) && path.toString().endsWith(".jar"))))
                     throw new CommandException("err.invalid.class.path.entry", path);
                 return path;
             } catch (InvalidPathException x) {
                 throw new CommandException("err.path.not.valid", value);
             }
         }
-
-        @Override  public Class<Path> valueType() { return Path.class; }
-
-        @Override  public String valuePattern() { return "path"; }
     }
 
-    static class DirPathConverter implements ValueConverter<Path> {
-        static final ValueConverter<Path> INSTANCE = new DirPathConverter();
+    static class DirPathConverter extends AbstractPathConverter {
+        static final ValueConverter<List<Path>> INSTANCE = new DirPathConverter();
 
         @Override
-        public Path convert(String value) {
+        public Path toPath(String value) {
             try {
                 Path path = CWD.resolve(value);
                 if (Files.notExists(path))
@@ -1127,10 +1064,6 @@
                 throw new CommandException("err.path.not.valid", value);
             }
         }
-
-        @Override  public Class<Path> valueType() { return Path.class; }
-
-        @Override  public String valuePattern() { return "path"; }
     }
 
     static class ExtractDirPathConverter implements ValueConverter<Path> {
@@ -1142,12 +1075,6 @@
                 if (Files.exists(path)) {
                     if (!Files.isDirectory(path))
                         throw new CommandException("err.cannot.create.dir", path);
-                } else {
-                    try {
-                        Files.createDirectories(path);
-                    } catch (IOException ioe) {
-                        throw new CommandException("err.cannot.create.dir", path);
-                    }
                 }
                 return path;
             } catch (InvalidPathException x) {
@@ -1316,22 +1243,19 @@
         options = new Options();
         parser.formatHelpWith(new JmodHelpFormatter(options));
 
-        OptionSpec<Path> classPath
+        OptionSpec<List<Path>> classPath
                 = parser.accepts("class-path", getMessage("main.opt.class-path"))
                         .withRequiredArg()
-                        .withValuesSeparatedBy(File.pathSeparatorChar)
                         .withValuesConvertedBy(ClassPathConverter.INSTANCE);
 
-        OptionSpec<Path> cmds
+        OptionSpec<List<Path>> cmds
                 = parser.accepts("cmds", getMessage("main.opt.cmds"))
                         .withRequiredArg()
-                        .withValuesSeparatedBy(File.pathSeparatorChar)
                         .withValuesConvertedBy(DirPathConverter.INSTANCE);
 
-        OptionSpec<Path> config
+        OptionSpec<List<Path>> config
                 = parser.accepts("config", getMessage("main.opt.config"))
                         .withRequiredArg()
-                        .withValuesSeparatedBy(File.pathSeparatorChar)
                         .withValuesConvertedBy(DirPathConverter.INSTANCE);
 
         OptionSpec<Path> dir
@@ -1359,22 +1283,19 @@
         OptionSpec<Void> helpExtra
                 = parser.accepts("help-extra", getMessage("main.opt.help-extra"));
 
-        OptionSpec<Path> headerFiles
+        OptionSpec<List<Path>> headerFiles
                 = parser.accepts("header-files", getMessage("main.opt.header-files"))
                         .withRequiredArg()
-                        .withValuesSeparatedBy(File.pathSeparatorChar)
                         .withValuesConvertedBy(DirPathConverter.INSTANCE);
 
-        OptionSpec<Path> libs
+        OptionSpec<List<Path>> libs
                 = parser.accepts("libs", getMessage("main.opt.libs"))
                         .withRequiredArg()
-                        .withValuesSeparatedBy(File.pathSeparatorChar)
                         .withValuesConvertedBy(DirPathConverter.INSTANCE);
 
-        OptionSpec<Path> legalNotices
+        OptionSpec<List<Path>> legalNotices
                 = parser.accepts("legal-notices", getMessage("main.opt.legal-notices"))
                         .withRequiredArg()
-                        .withValuesSeparatedBy(File.pathSeparatorChar)
                         .withValuesConvertedBy(DirPathConverter.INSTANCE);
 
 
@@ -1383,17 +1304,15 @@
                         .withRequiredArg()
                         .describedAs(getMessage("main.opt.main-class.arg"));
 
-        OptionSpec<Path> manPages
+        OptionSpec<List<Path>> manPages
                 = parser.accepts("man-pages", getMessage("main.opt.man-pages"))
                         .withRequiredArg()
-                        .withValuesSeparatedBy(File.pathSeparatorChar)
                         .withValuesConvertedBy(DirPathConverter.INSTANCE);
 
-        OptionSpec<Path> modulePath
+        OptionSpec<List<Path>> modulePath
                 = parser.acceptsAll(Set.of("p", "module-path"),
                                     getMessage("main.opt.module-path"))
                         .withRequiredArg()
-                        .withValuesSeparatedBy(File.pathSeparatorChar)
                         .withValuesConvertedBy(DirPathConverter.INSTANCE);
 
         OptionSpec<Version> moduleVersion
@@ -1452,48 +1371,48 @@
             }
 
             if (opts.has(classPath))
-                options.classpath = opts.valuesOf(classPath);
+                options.classpath = getLastElement(opts.valuesOf(classPath));
             if (opts.has(cmds))
-                options.cmds = opts.valuesOf(cmds);
+                options.cmds = getLastElement(opts.valuesOf(cmds));
             if (opts.has(config))
-                options.configs = opts.valuesOf(config);
+                options.configs = getLastElement(opts.valuesOf(config));
             if (opts.has(dir))
-                options.extractDir = opts.valueOf(dir);
+                options.extractDir = getLastElement(opts.valuesOf(dir));
             if (opts.has(dryrun))
                 options.dryrun = true;
             if (opts.has(excludes))
-                options.excludes = opts.valuesOf(excludes);
+                options.excludes = opts.valuesOf(excludes);  // excludes is repeatable
             if (opts.has(libs))
-                options.libs = opts.valuesOf(libs);
+                options.libs = getLastElement(opts.valuesOf(libs));
             if (opts.has(headerFiles))
-                options.headerFiles = opts.valuesOf(headerFiles);
+                options.headerFiles = getLastElement(opts.valuesOf(headerFiles));
             if (opts.has(manPages))
-                options.manPages = opts.valuesOf(manPages);
+                options.manPages = getLastElement(opts.valuesOf(manPages));
             if (opts.has(legalNotices))
-                options.legalNotices = opts.valuesOf(legalNotices);
+                options.legalNotices = getLastElement(opts.valuesOf(legalNotices));
             if (opts.has(modulePath)) {
-                Path[] dirs = opts.valuesOf(modulePath).toArray(new Path[0]);
+                Path[] dirs = getLastElement(opts.valuesOf(modulePath)).toArray(new Path[0]);
                 options.moduleFinder = new ModulePath(Runtime.version(), true, dirs);
             }
             if (opts.has(moduleVersion))
-                options.moduleVersion = opts.valueOf(moduleVersion);
+                options.moduleVersion = getLastElement(opts.valuesOf(moduleVersion));
             if (opts.has(mainClass))
-                options.mainClass = opts.valueOf(mainClass);
+                options.mainClass = getLastElement(opts.valuesOf(mainClass));
             if (opts.has(osName))
-                options.osName = opts.valueOf(osName);
+                options.osName = getLastElement(opts.valuesOf(osName));
             if (opts.has(osArch))
-                options.osArch = opts.valueOf(osArch);
+                options.osArch = getLastElement(opts.valuesOf(osArch));
             if (opts.has(osVersion))
-                options.osVersion = opts.valueOf(osVersion);
+                options.osVersion = getLastElement(opts.valuesOf(osVersion));
             if (opts.has(warnIfResolved))
-                options.moduleResolution = opts.valueOf(warnIfResolved);
+                options.moduleResolution = getLastElement(opts.valuesOf(warnIfResolved));
             if (opts.has(doNotResolveByDefault)) {
                 if (options.moduleResolution == null)
                     options.moduleResolution = ModuleResolution.empty();
                 options.moduleResolution = options.moduleResolution.withDoNotResolveByDefault();
             }
             if (opts.has(hashModules)) {
-                options.modulesToHash = opts.valueOf(hashModules);
+                options.modulesToHash = getLastElement(opts.valuesOf(hashModules));
                 // if storing hashes then the module path is required
                 if (options.moduleFinder == null)
                     throw new CommandException("err.modulepath.must.be.specified")
@@ -1531,6 +1450,13 @@
                 throw new CommandException("err.classpath.must.be.specified").showUsage(true);
             if (options.mainClass != null && !isValidJavaIdentifier(options.mainClass))
                 throw new CommandException("err.invalid.main-class", options.mainClass);
+            if (options.mode.equals(Mode.EXTRACT) && options.extractDir != null) {
+                try {
+                    Files.createDirectories(options.extractDir);
+                } catch (IOException ioe) {
+                    throw new CommandException("err.cannot.create.dir", options.extractDir);
+                }
+            }
         } catch (OptionException e) {
              throw new CommandException(e.getMessage());
         }
@@ -1558,6 +1484,12 @@
         return true;
     }
 
+    static <E> E getLastElement(List<E> list) {
+        if (list.size() == 0)
+            throw new InternalError("Unexpected 0 list size");
+        return list.get(list.size() - 1);
+    }
+
     private void reportError(String message) {
         out.println(getMessage("error.prefix") + " " + message);
     }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -108,9 +108,9 @@
 err.invalid.dryrun.option=--dry-run can only be used with hash mode
 err.module.descriptor.not.found=Module descriptor not found
 err.missing.export.or.open.packages=Packages that are exported or open in {0} are not present: {1}
+err.module.resolution.fail=Resolution failed: {0}
 warn.invalid.arg=Invalid classname or pathname not exist: {0}
 warn.no.module.hashes=No hashes recorded: no module specified for hashing depends on {0}
-warn.module.resolution.fail=No hashes recorded: {0}
 warn.ignore.entry=ignoring entry {0}, in section {1}
 warn.ignore.duplicate.entry=ignoring duplicate entry {0}, in section {1}
 
--- a/jdk/src/jdk.jlink/share/classes/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.jlink/share/classes/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -24,8 +24,6 @@
  */
 
 module jdk.jlink {
-    exports jdk.tools.jlink.plugin;
-
     requires jdk.internal.opt;
     requires jdk.jdeps;
 
--- a/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java	Tue Jan 24 00:30:25 2017 +0100
@@ -32,6 +32,8 @@
 import java.rmi.server.*;
 import java.rmi.registry.Registry;
 import java.rmi.registry.LocateRegistry;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import javax.naming.*;
 import javax.naming.spi.NamingManager;
@@ -52,6 +54,18 @@
     private int port;
     private static final NameParser nameParser = new AtomicNameParser();
     private static final String SOCKET_FACTORY = "com.sun.jndi.rmi.factory.socket";
+    /**
+     * Determines whether classes may be loaded from an arbitrary URL code base.
+     */
+    static final boolean trustURLCodebase;
+    static {
+        // System property to control whether classes may be loaded from an
+        // arbitrary URL codebase
+        PrivilegedAction<String> act = () -> System.getProperty(
+            "com.sun.jndi.rmi.object.trustURLCodebase", "false");
+        String trust = AccessController.doPrivileged(act);
+        trustURLCodebase = "true".equalsIgnoreCase(trust);
+    }
 
     Reference reference = null; // ref used to create this context, if any
 
@@ -460,6 +474,27 @@
             Object obj = (r instanceof RemoteReference)
                         ? ((RemoteReference)r).getReference()
                         : (Object)r;
+
+            /*
+             * Classes may only be loaded from an arbitrary URL codebase when
+             * the system property com.sun.jndi.rmi.object.trustURLCodebase
+             * has been set to "true".
+             */
+
+            // Use reference if possible
+            Reference ref = null;
+            if (obj instanceof Reference) {
+                ref = (Reference) obj;
+            } else if (obj instanceof Referenceable) {
+                ref = ((Referenceable)(obj)).getReference();
+            }
+
+            if (ref != null && ref.getFactoryClassLocation() != null &&
+                !trustURLCodebase) {
+                throw new ConfigurationException(
+                    "The object factory is untrusted. Set the system property" +
+                    " 'com.sun.jndi.rmi.object.trustURLCodebase' to 'true'.");
+            }
             return NamingManager.getObjectInstance(obj, name, this,
                                                    environment);
         } catch (NamingException e) {
--- a/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c	Tue Jan 24 00:30:25 2017 +0100
@@ -418,7 +418,6 @@
   (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj,
    jlong address, jint length, jboolean peek) {
     SOCKETADDRESS sa;
-    int sa_len = sizeof(SOCKETADDRESS);
     ssize_t rv = 0;
     jlong *addr = jlong_to_ptr(address);
     struct iovec iov[1];
@@ -429,7 +428,7 @@
     /* Set up the msghdr structure for receiving */
     memset(msg, 0, sizeof (*msg));
     msg->msg_name = &sa;
-    msg->msg_namelen = sa_len;
+    msg->msg_namelen = sizeof(sa);
     iov->iov_base = addr;
     iov->iov_len = length;
     msg->msg_iov = iov;
@@ -538,7 +537,7 @@
    jobject targetAddress, jint targetPort, jint assocId, jint streamNumber,
    jboolean unordered, jint ppid) {
     SOCKETADDRESS sa;
-    int sa_len = sizeof(SOCKETADDRESS);
+    int sa_len = 0;
     ssize_t rv = 0;
     jlong *addr = jlong_to_ptr(address);
     struct iovec iov[1];
@@ -555,13 +554,12 @@
      *    Association already existing, assocId != -1, targetAddress = preferred addr
      */
     if (targetAddress != NULL /*&& assocId <= 0*/) {
-        if (NET_InetAddressToSockaddr(env, targetAddress, targetPort, &sa.sa,
+        if (NET_InetAddressToSockaddr(env, targetAddress, targetPort, &sa,
                                       &sa_len, JNI_TRUE) != 0) {
             return IOS_THROWN;
         }
     } else {
-        memset(&sa, '\x0', sa_len);
-        sa_len = 0;
+        memset(&sa, '\x0', sizeof(sa));
     }
 
     /* Set up the msghdr structure for sending */
--- a/jdk/src/jdk.sctp/unix/native/libsctp/SctpNet.c	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.sctp/unix/native/libsctp/SctpNet.c	Tue Jan 24 00:30:25 2017 +0100
@@ -211,22 +211,22 @@
   (JNIEnv *env, jclass klass, jint fd, jobjectArray addrs, jint port,
    jint addrsLength, jboolean add, jboolean preferIPv6) {
     SOCKETADDRESS *sap, *tmpSap;
-    int i, sa_len = sizeof(SOCKETADDRESS);
+    int i;
     jobject ia;
 
     if (addrsLength < 1)
         return;
 
-    if ((sap = calloc(addrsLength, sa_len)) == NULL) {
-          JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
+    if ((sap = calloc(addrsLength, sizeof(SOCKETADDRESS))) == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
         return;
     }
 
     tmpSap = sap;
     for (i = 0; i < addrsLength; i++) {
         ia = (*env)->GetObjectArrayElement(env, addrs, i);
-        if (NET_InetAddressToSockaddr(env, ia, port, (struct sockaddr*)tmpSap,
-                                      &sa_len, preferIPv6) != 0) {
+        if (NET_InetAddressToSockaddr(env, ia, port, tmpSap, NULL,
+                                      preferIPv6) != 0) {
             free(sap);
             return;
         }
@@ -262,11 +262,11 @@
 Java_sun_nio_ch_sctp_SctpNet_connect0
   (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) {
     SOCKETADDRESS sa;
-    int sa_len = sizeof(SOCKETADDRESS);
+    int sa_len = 0;
     int rv;
 
-    if (NET_InetAddressToSockaddr(env, iao, port, &sa.sa,
-                                  &sa_len, JNI_TRUE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len,
+                                  JNI_TRUE) != 0) {
         return IOS_THROWN;
     }
 
@@ -311,8 +311,7 @@
     }
 }
 
-void initializeISA
-  (JNIEnv* env) {
+void initializeISA(JNIEnv* env) {
     if (isaCls == 0) {
         jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress");
         CHECK_NULL(c);
@@ -325,8 +324,7 @@
     }
 }
 
-jobject SockAddrToInetSocketAddress
-  (JNIEnv *env, struct sockaddr* sap) {
+jobject SockAddrToInetSocketAddress(JNIEnv *env, SOCKETADDRESS *sap) {
     int port = 0;
 
     jobject ia = NET_SockaddrToInetAddress(env, sap, &port);
@@ -347,9 +345,9 @@
  * Signature: (I)[Ljava/net/SocketAddress;
  */
 JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0
-  (JNIEnv *env, jclass klass, jint fd) {
+  (JNIEnv *env, jclass klass, jint fd)
+{
     void *addr_buf, *laddr;
-    struct sockaddr* sap;
     int i, addrCount;
     jobjectArray isaa;
 
@@ -377,38 +375,35 @@
     }
 
     laddr = addr_buf;
-    for (i=0; i<addrCount; i++) {
+    for (i = 0; i < addrCount; i++) {
         int port = 0;
-        jobject isa = NULL, ia;
-        sap = (struct sockaddr*)addr_buf;
-        ia = NET_SockaddrToInetAddress(env, sap, &port);
+        jobject ia, isa = NULL;
+        ia = NET_SockaddrToInetAddress(env, (SOCKETADDRESS *)addr_buf, &port);
         if (ia != NULL)
             isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
         if (isa == NULL)
             break;
         (*env)->SetObjectArrayElement(env, isaa, i, isa);
 
-        if (sap->sa_family == AF_INET)
-            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
+        if (((struct sockaddr *)addr_buf)->sa_family == AF_INET)
+            addr_buf = ((struct sockaddr_in *)addr_buf) + 1;
         else
-            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
+            addr_buf = ((struct sockaddr_in6 *)addr_buf) + 1;
     }
 
     nio_sctp_freeladdrs(laddr);
     return isaa;
 }
 
-jobjectArray getRemoteAddresses
-  (JNIEnv *env, jint fd, sctp_assoc_t id) {
+jobjectArray getRemoteAddresses(JNIEnv *env, jint fd, sctp_assoc_t id) {
     void *addr_buf, *paddr;
-    struct sockaddr* sap;
     int i, addrCount;
     jobjectArray isaa;
 
 #if __solaris__
     if ((addrCount = nio_sctp_getpaddrs(fd, id, (void **)&addr_buf)) == -1) {
 #else /* __linux__ */
-    if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr**)&addr_buf)) == -1) {
+    if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr **)&addr_buf)) == -1) {
 #endif
         handleSocketError(env, errno);
         return NULL;
@@ -429,25 +424,23 @@
     }
 
     paddr = addr_buf;
-    for (i=0; i<addrCount; i++) {
-        jobject ia, isa = NULL;
+    for (i = 0; i < addrCount; i++) {
         int port = 0;
-        sap = (struct sockaddr*)addr_buf;
-        ia = NET_SockaddrToInetAddress(env, sap, &port);
+        jobject ia, isa = NULL;
+        ia = NET_SockaddrToInetAddress(env, (SOCKETADDRESS *)addr_buf, &port);
         if (ia != NULL)
             isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
         if (isa == NULL)
             break;
         (*env)->SetObjectArrayElement(env, isaa, i, isa);
 
-        if (sap->sa_family == AF_INET)
-            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
+        if (((struct sockaddr *)addr_buf)->sa_family == AF_INET)
+            addr_buf = ((struct sockaddr_in *)addr_buf) + 1;
         else
-            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
+            addr_buf = ((struct sockaddr_in6 *)addr_buf) + 1;
     }
 
     nio_sctp_freepaddrs(paddr);
-
     return isaa;
 }
 
@@ -579,7 +572,6 @@
   (JNIEnv *env, jclass klass, jint fd, jint assocId) {
     struct sctp_setprim prim;
     unsigned int prim_len = sizeof(prim);
-    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
 
     prim.ssp_assoc_id = assocId;
 
@@ -589,7 +581,7 @@
         return NULL;
     }
 
-    return SockAddrToInetSocketAddress(env, sap);
+    return SockAddrToInetSocketAddress(env, (SOCKETADDRESS *)&prim.ssp_addr);
 }
 
 /*
@@ -600,11 +592,10 @@
 JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPrimAddrOption0
   (JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port) {
     struct sctp_setprim prim;
-    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
-    int sap_len = sizeof(sap);
 
-    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
-                                  &sap_len, JNI_TRUE) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, port,
+                                  (SOCKETADDRESS *)&prim.ssp_addr,
+                                  NULL, JNI_TRUE) != 0) {
         return;
     }
 
@@ -625,18 +616,17 @@
   (JNIEnv *env, jclass klass, jint fd, jint assocId,
    jobject iaObj, jint port, jboolean preferIPv6) {
     struct sctp_setpeerprim prim;
-    struct sockaddr* sap = (struct sockaddr*)&prim.sspp_addr;
-    int sap_len = sizeof(sap);
 
-    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
-                                  &sap_len, preferIPv6) != 0) {
+    if (NET_InetAddressToSockaddr(env, iaObj, port,
+                                  (SOCKETADDRESS *)&prim.sspp_addr,
+                                  NULL, preferIPv6) != 0) {
         return;
     }
 
     prim.sspp_assoc_id = assocId;
 
     if (setsockopt(fd, IPPROTO_SCTP, SCTP_SET_PEER_PRIMARY_ADDR, &prim,
-            sizeof(prim)) < 0) {
+                   sizeof(prim)) < 0) {
         JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                                      "sun.nio.ch.SctpNet.setPeerPrimAddrOption0");
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -65,9 +65,8 @@
     public NTDomainPrincipal(String name) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -92,9 +91,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTDomainPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTDomainPrincipal.name"));
         Object[] source = {name};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java	Tue Jan 24 00:30:25 2017 +0100
@@ -61,9 +61,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTNumericCredential.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTNumericCredential.name"));
         Object[] source = {Long.toString(impersonationToken)};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java	Tue Jan 24 00:30:25 2017 +0100
@@ -70,17 +70,15 @@
     public NTSid (String stringSid) {
         if (stringSid == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"stringSid"};
             throw new NullPointerException(form.format(source));
         }
         if (stringSid.length() == 0) {
             throw new IllegalArgumentException
-                (sun.security.util.ResourcesMgr.getString
-                        ("Invalid.NTSid.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("Invalid.NTSid.value"));
         }
         sid = new String(stringSid);
     }
@@ -101,9 +99,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSid.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSid.name"));
         Object[] source = {sid};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -68,9 +68,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSidDomainPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSidDomainPrincipal.name"));
         Object[] source = {getName()};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -63,9 +63,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSidGroupPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSidGroupPrincipal.name"));
         Object[] source = {getName()};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -65,9 +65,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSidPrimaryGroupPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSidPrimaryGroupPrincipal.name"));
         Object[] source = {getName()};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -62,9 +62,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTSidUserPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTSidUserPrincipal.name"));
         Object[] source = {getName()};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -61,9 +61,8 @@
     public NTUserPrincipal(String name) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -86,9 +85,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("NTUserPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("NTUserPrincipal.name"));
         Object[] source = {name};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -26,6 +26,7 @@
 package com.sun.security.auth;
 
 import java.security.Principal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * This class implements the {@code Principal} interface
@@ -53,9 +54,6 @@
 
     private static final long serialVersionUID = 2345199581042573224L;
 
-    private static final java.util.ResourceBundle rb =
-        java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /**
      * @serial
      */
@@ -82,7 +80,7 @@
      */
     public SolarisNumericGroupPrincipal(String name, boolean primaryGroup) {
         if (name == null)
-            throw new NullPointerException(rb.getString("provided.null.name"));
+            throw new NullPointerException(getAuthResourceString("provided.null.name"));
 
         this.name = name;
         this.primaryGroup = primaryGroup;
@@ -146,11 +144,11 @@
      *          {@code SolarisNumericGroupPrincipal}.
      */
     public String toString() {
-        return((primaryGroup ?
-            rb.getString
+        return primaryGroup ?
+            getAuthResourceString
             ("SolarisNumericGroupPrincipal.Primary.Group.") + name :
-            rb.getString
-            ("SolarisNumericGroupPrincipal.Supplementary.Group.") + name));
+            getAuthResourceString
+            ("SolarisNumericGroupPrincipal.Supplementary.Group.") + name;
     }
 
     /**
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -26,6 +26,7 @@
 package com.sun.security.auth;
 
 import java.security.Principal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * This class implements the {@code Principal} interface
@@ -52,9 +53,6 @@
 
     private static final long serialVersionUID = -3178578484679887104L;
 
-    private static final java.util.ResourceBundle rb =
-        java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /**
      * @serial
      */
@@ -72,7 +70,7 @@
      */
     public SolarisNumericUserPrincipal(String name) {
         if (name == null)
-            throw new NullPointerException(rb.getString("provided.null.name"));
+            throw new NullPointerException(getAuthResourceString("provided.null.name"));
 
         this.name = name;
     }
@@ -118,7 +116,7 @@
      *          {@code SolarisNumericUserPrincipal}.
      */
     public String toString() {
-        return(rb.getString("SolarisNumericUserPrincipal.") + name);
+        return(getAuthResourceString("SolarisNumericUserPrincipal.") + name);
     }
 
     /**
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -26,6 +26,8 @@
 package com.sun.security.auth;
 
 import java.security.Principal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
+
 
 /**
  * This class implements the {@code Principal} interface
@@ -50,10 +52,6 @@
 
     private static final long serialVersionUID = -7840670002439379038L;
 
-    private static final java.util.ResourceBundle rb =
-        java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
-
-
     /**
      * @serial
      */
@@ -69,7 +67,7 @@
      */
     public SolarisPrincipal(String name) {
         if (name == null)
-            throw new NullPointerException(rb.getString("provided.null.name"));
+            throw new NullPointerException(getAuthResourceString("provided.null.name"));
 
         this.name = name;
     }
@@ -89,7 +87,7 @@
      * @return a string representation of this {@code SolarisPrincipal}.
      */
     public String toString() {
-        return(rb.getString("SolarisPrincipal.") + name);
+        return(getAuthResourceString("SolarisPrincipal.") + name);
     }
 
     /**
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -74,9 +74,8 @@
     public UnixNumericGroupPrincipal(String name, boolean primaryGroup) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -146,16 +145,14 @@
 
         if (primaryGroup) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("UnixNumericGroupPrincipal.Primary.Group.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("UnixNumericGroupPrincipal.Primary.Group.name"));
             Object[] source = {name};
             return form.format(source);
         } else {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                    ("UnixNumericGroupPrincipal.Supplementary.Group.name",
-                    "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                    ("UnixNumericGroupPrincipal.Supplementary.Group.name"));
             Object[] source = {name};
             return form.format(source);
         }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -64,9 +64,8 @@
     public UnixNumericUserPrincipal(String name) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -116,9 +115,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("UnixNumericUserPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("UnixNumericUserPrincipal.name"));
         Object[] source = {name};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -61,9 +61,8 @@
     public UnixPrincipal(String name) {
         if (name == null) {
             java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("invalid.null.input.value",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("invalid.null.input.value"));
             Object[] source = {"name"};
             throw new NullPointerException(form.format(source));
         }
@@ -87,9 +86,8 @@
      */
     public String toString() {
         java.text.MessageFormat form = new java.text.MessageFormat
-                (sun.security.util.ResourcesMgr.getString
-                        ("UnixPrincipal.name",
-                        "sun.security.util.AuthResources"));
+                (sun.security.util.ResourcesMgr.getAuthResourceString
+                        ("UnixPrincipal.name"));
         Object[] source = {name};
         return form.format(source);
     }
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java	Tue Jan 24 00:30:25 2017 +0100
@@ -27,6 +27,7 @@
 
 import java.security.Principal;
 import sun.security.x509.X500Name;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * This class represents an X.500 {@code Principal}.
@@ -55,9 +56,6 @@
 
     private static final long serialVersionUID = -8222422609431628648L;
 
-    private static final java.util.ResourceBundle rb =
-        java.util.ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /**
      * @serial
      */
@@ -80,7 +78,7 @@
      */
     public X500Principal(String name) {
         if (name == null)
-            throw new NullPointerException(rb.getString("provided.null.name"));
+            throw new NullPointerException(getAuthResourceString("provided.null.name"));
 
         try {
             thisX500Name = new X500Name(name);
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/JndiLoginModule.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/JndiLoginModule.java	Tue Jan 24 00:30:25 2017 +0100
@@ -32,15 +32,13 @@
 import javax.naming.*;
 import javax.naming.directory.*;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.Map;
 import java.util.LinkedList;
-import java.util.ResourceBundle;
 
 import com.sun.security.auth.UnixPrincipal;
 import com.sun.security.auth.UnixNumericUserPrincipal;
 import com.sun.security.auth.UnixNumericGroupPrincipal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 
 /**
@@ -153,9 +151,6 @@
  */
 public class JndiLoginModule implements LoginModule {
 
-    private static final ResourceBundle rb =
-        ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /** JNDI Provider */
     public final String USER_PROVIDER = "user.provider.url";
     public final String GROUP_PROVIDER = "group.provider.url";
@@ -677,9 +672,9 @@
 
         Callback[] callbacks = new Callback[2];
         callbacks[0] = new NameCallback(protocol + " "
-                                            + rb.getString("username."));
+                                            + getAuthResourceString("username."));
         callbacks[1] = new PasswordCallback(protocol + " " +
-                                                rb.getString("password."),
+                                                getAuthResourceString("password."),
                                             false);
 
         try {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java	Tue Jan 24 00:30:25 2017 +0100
@@ -51,6 +51,7 @@
 import javax.security.auth.spi.LoginModule;
 
 import sun.security.util.Password;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * Provides a JAAS login module that prompts for a key store alias and
@@ -112,9 +113,6 @@
  */
 public class KeyStoreLoginModule implements LoginModule {
 
-    private static final ResourceBundle rb =
-        ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     /* -- Fields -- */
 
     private static final int UNINITIALIZED = 0;
@@ -132,7 +130,7 @@
     private static final TextOutputCallback bannerCallback =
                 new TextOutputCallback
                         (TextOutputCallback.INFORMATION,
-                        rb.getString("Please.enter.keystore.information"));
+                        getAuthResourceString("Please.enter.keystore.information"));
     private final ConfirmationCallback confirmationCallback =
                 new ConfirmationCallback
                         (ConfirmationCallback.INFORMATION,
@@ -344,11 +342,10 @@
 
             NameCallback aliasCallback;
             if (keyStoreAlias == null || keyStoreAlias.length() == 0) {
-                aliasCallback = new NameCallback(
-                                        rb.getString("Keystore.alias."));
+                aliasCallback = new NameCallback(getAuthResourceString("Keystore.alias."));
             } else {
                 aliasCallback =
-                    new NameCallback(rb.getString("Keystore.alias."),
+                    new NameCallback(getAuthResourceString("Keystore.alias."),
                                      keyStoreAlias);
             }
 
@@ -360,11 +357,11 @@
                 break;
             case NORMAL:
                 keyPassCallback = new PasswordCallback
-                    (rb.getString("Private.key.password.optional."), false);
+                    (getAuthResourceString("Private.key.password.optional."), false);
                 // fall thru
             case TOKEN:
                 storePassCallback = new PasswordCallback
-                    (rb.getString("Keystore.password."), false);
+                    (getAuthResourceString("Keystore.password."), false);
                 break;
             }
             prompt(aliasCallback, storePassCallback, keyPassCallback);
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java	Tue Jan 24 00:30:25 2017 +0100
@@ -27,8 +27,6 @@
 package com.sun.security.auth.module;
 
 import java.io.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.text.MessageFormat;
 import java.util.*;
 
@@ -45,6 +43,7 @@
 import sun.security.jgss.krb5.Krb5Util;
 import sun.security.krb5.Credentials;
 import sun.security.util.HexDumpEncoder;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 /**
  * This {@code LoginModule} authenticates users using
@@ -419,8 +418,6 @@
 
     private static final String NAME = "javax.security.auth.login.name";
     private static final String PWD = "javax.security.auth.login.password";
-    private static final ResourceBundle rb =
-        ResourceBundle.getBundle("sun.security.util.AuthResources");
 
     /**
      * Initialize this {@code LoginModule}.
@@ -831,7 +828,7 @@
 
                 Callback[] callbacks = new Callback[1];
                 MessageFormat form = new MessageFormat(
-                                       rb.getString(
+                                       getAuthResourceString(
                                        "Kerberos.username.defUsername."));
                 Object[] source =  {defUsername};
                 callbacks[0] = new NameCallback(form.format(source));
@@ -886,7 +883,7 @@
                 Callback[] callbacks = new Callback[1];
                 String userName = krb5PrincName.toString();
                 MessageFormat form = new MessageFormat(
-                                         rb.getString(
+                                         getAuthResourceString(
                                          "Kerberos.password.for.username."));
                 Object[] source = {userName};
                 callbacks[0] = new PasswordCallback(
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java	Tue Jan 24 00:30:25 2017 +0100
@@ -25,14 +25,11 @@
 
 package com.sun.security.auth.module;
 
-import java.security.AccessController;
 import java.net.SocketPermission;
 import java.security.Principal;
-import java.security.PrivilegedAction;
 import java.util.Arrays;
 import java.util.Hashtable;
 import java.util.Map;
-import java.util.ResourceBundle;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.Set;
@@ -47,6 +44,7 @@
 
 import com.sun.security.auth.LdapPrincipal;
 import com.sun.security.auth.UserPrincipal;
+import static sun.security.util.ResourcesMgr.getAuthResourceString;
 
 
 /**
@@ -305,10 +303,6 @@
  */
 public class LdapLoginModule implements LoginModule {
 
-    // Use the default classloader for this class to load the prompt strings.
-    private static final ResourceBundle rb =
-        ResourceBundle.getBundle("sun.security.util.AuthResources");
-
     // Keys to retrieve the stored username and password
     private static final String USERNAME_KEY = "javax.security.auth.login.name";
     private static final String PASSWORD_KEY =
@@ -418,7 +412,6 @@
             constraints = new SearchControls();
             constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
             constraints.setReturningAttributes(new String[0]); //return no attrs
-            constraints.setReturningObjFlag(true); // to get the full DN
         }
 
         authzIdentity = (String)options.get(AUTHZ_IDENTITY);
@@ -878,11 +871,7 @@
             // (Use the first entry if more than one is returned)
             if (results.hasMore()) {
                 SearchResult entry = results.next();
-
-                // %%% - use the SearchResult.getNameInNamespace method
-                //        available in JDK 1.5 and later.
-                //        (can remove call to constraints.setReturningObjFlag)
-                userDN = ((Context)entry.getObject()).getNameInNamespace();
+                userDN = entry.getNameInNamespace();
 
                 if (debug) {
                     System.out.println("\t\t[LdapLoginModule] found entry: " +
@@ -962,8 +951,8 @@
                 "to acquire authentication information from the user");
 
         Callback[] callbacks = new Callback[2];
-        callbacks[0] = new NameCallback(rb.getString("username."));
-        callbacks[1] = new PasswordCallback(rb.getString("password."), false);
+        callbacks[0] = new NameCallback(getAuthResourceString("username."));
+        callbacks[1] = new PasswordCallback(getAuthResourceString("password."), false);
 
         try {
             callbackHandler.handle(callbacks);
--- a/jdk/src/jdk.security.auth/share/classes/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.security.auth/share/classes/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -36,8 +36,6 @@
     exports com.sun.security.auth.login;
     exports com.sun.security.auth.module;
 
-    uses sun.security.util.AuthResourcesProvider;
-
     provides javax.security.auth.spi.LoginModule with
         com.sun.security.auth.module.Krb5LoginModule,
         com.sun.security.auth.module.UnixLoginModule,
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java	Tue Jan 24 00:30:25 2017 +0100
@@ -135,7 +135,7 @@
         TreeMap<Integer,IndexNode> map = new TreeMap<>();
         IndexNode child = metaInfVersions.child;
         while (child != null) {
-            Integer key = getVersion(child.name, metaInfVersions.name.length);
+            Integer key = getVersion(child.name, metaInfVersions.name.length + 1);
             if (key != null && key <= version) {
                 map.put(key, child);
             }
@@ -149,7 +149,7 @@
      */
     private Integer getVersion(byte[] name, int offset) {
         try {
-            return Integer.parseInt(getString(Arrays.copyOfRange(name, offset, name.length-1)));
+            return Integer.parseInt(getString(Arrays.copyOfRange(name, offset, name.length)));
         } catch (NumberFormatException x) {
             // ignore this even though it might indicate issues with the JAR structure
             return null;
@@ -176,7 +176,7 @@
      *   returns foo/bar.class
      */
     private byte[] getRootName(IndexNode prefix, IndexNode inode) {
-        int offset = prefix.name.length - 1;
+        int offset = prefix.name.length;
         byte[] fullName = inode.name;
         return Arrays.copyOfRange(fullName, offset, fullName.length);
     }
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,21 +34,56 @@
 import java.nio.charset.CodingErrorAction;
 import java.util.Arrays;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.nio.charset.StandardCharsets.ISO_8859_1;
+
 /**
  * Utility class for zipfile name and comment decoding and encoding
  *
  * @author  Xueming Shen
  */
 
-final class ZipCoder {
+class ZipCoder {
+
+    static class UTF8 extends ZipCoder {
+        UTF8() {
+            super(UTF_8);
+        }
+
+        @Override
+        byte[] getBytes(String s) {        // fast pass for ascii
+            for (int i = 0; i < s.length(); i++) {
+                if (s.charAt(i) > 0x7f) return super.getBytes(s);
+            }
+            return s.getBytes(ISO_8859_1);
+        }
 
-    String toString(byte[] ba, int length) {
+        @Override
+        String toString(byte[] ba) {
+            for (byte b : ba) {
+                if (b < 0) return super.toString(ba);
+            }
+            return new String(ba, ISO_8859_1);
+        }
+    }
+
+    private static final ZipCoder utf8 = new UTF8();
+
+    public static ZipCoder get(String csn) {
+        Charset cs = Charset.forName(csn);
+        if (cs.name().equals("UTF-8")) {
+            return utf8;
+        }
+        return new ZipCoder(cs);
+    }
+
+    String toString(byte[] ba) {
         CharsetDecoder cd = decoder().reset();
-        int len = (int)(length * cd.maxCharsPerByte());
-        char[] ca = new char[len];
-        if (len == 0)
+        int clen = (int)(ba.length * cd.maxCharsPerByte());
+        char[] ca = new char[clen];
+        if (clen == 0)
             return new String(ca);
-        ByteBuffer bb = ByteBuffer.wrap(ba, 0, length);
+        ByteBuffer bb = ByteBuffer.wrap(ba, 0, ba.length);
         CharBuffer cb = CharBuffer.wrap(ca);
         CoderResult cr = cd.decode(bb, cb, true);
         if (!cr.isUnderflow())
@@ -59,10 +94,6 @@
         return new String(ca, 0, cb.position());
     }
 
-    String toString(byte[] ba) {
-        return toString(ba, ba.length);
-    }
-
     byte[] getBytes(String s) {
         CharsetEncoder ce = encoder().reset();
         char[] ca = s.toCharArray();
@@ -84,47 +115,14 @@
             return Arrays.copyOf(ba, bb.position());
     }
 
-    // assume invoked only if "this" is not utf8
-    byte[] getBytesUTF8(String s) {
-        if (isutf8)
-            return getBytes(s);
-        if (utf8 == null)
-            utf8 = new ZipCoder(Charset.forName("UTF-8"));
-        return utf8.getBytes(s);
-    }
-
-    String toStringUTF8(byte[] ba, int len) {
-        if (isutf8)
-            return toString(ba, len);
-        if (utf8 == null)
-            utf8 = new ZipCoder(Charset.forName("UTF-8"));
-        return utf8.toString(ba, len);
-    }
-
     boolean isUTF8() {
-        return isutf8;
+        return cs == UTF_8;
     }
 
     private Charset cs;
-    private boolean isutf8;
-    private ZipCoder utf8;
 
     private ZipCoder(Charset cs) {
         this.cs = cs;
-        this.isutf8 = cs.name().equals("UTF-8");
-    }
-
-    static ZipCoder get(Charset charset) {
-        return new ZipCoder(charset);
-    }
-
-    static ZipCoder get(String csn) {
-        try {
-            return new ZipCoder(Charset.forName(csn));
-        } catch (Throwable t) {
-            t.printStackTrace();
-        }
-        return new ZipCoder(Charset.defaultCharset());
     }
 
     private final ThreadLocal<CharsetDecoder> decTL = new ThreadLocal<>();
@@ -133,10 +131,10 @@
     private CharsetDecoder decoder() {
         CharsetDecoder dec = decTL.get();
         if (dec == null) {
-            dec = cs.newDecoder()
-              .onMalformedInput(CodingErrorAction.REPORT)
-              .onUnmappableCharacter(CodingErrorAction.REPORT);
-            decTL.set(dec);
+        dec = cs.newDecoder()
+            .onMalformedInput(CodingErrorAction.REPORT)
+            .onUnmappableCharacter(CodingErrorAction.REPORT);
+        decTL.set(dec);
         }
         return dec;
     }
@@ -144,10 +142,10 @@
     private CharsetEncoder encoder() {
         CharsetEncoder enc = encTL.get();
         if (enc == null) {
-            enc = cs.newEncoder()
-              .onMalformedInput(CodingErrorAction.REPORT)
-              .onUnmappableCharacter(CodingErrorAction.REPORT);
-            encTL.set(enc);
+        enc = cs.newEncoder()
+            .onMalformedInput(CodingErrorAction.REPORT)
+            .onUnmappableCharacter(CodingErrorAction.REPORT);
+        encTL.set(enc);
         }
         return enc;
     }
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -314,8 +314,8 @@
                 IndexNode inode = getInode(path);
                 if (inode == null)
                     return null;
-                e = new Entry(inode.name);       // pseudo directory
-                e.method = METHOD_STORED;        // STORED for dir
+                e = new Entry(inode.name, inode.isdir);  // pseudo directory
+                e.method = METHOD_STORED;         // STORED for dir
                 e.mtime = e.atime = e.ctime = zfsDefaultTimeStamp;
             }
         } finally {
@@ -400,7 +400,8 @@
             List<Path> list = new ArrayList<>();
             IndexNode child = inode.child;
             while (child != null) {
-                ZipPath zp = new ZipPath(this, child.name);
+                // assume all path from zip file itself is "normalized"
+                ZipPath zp = new ZipPath(this, child.name, true);
                 if (filter == null || filter.accept(zp))
                     list.add(zp);
                 child = child.sibling;
@@ -415,14 +416,14 @@
         throws IOException
     {
         checkWritable();
-        dir = toDirectoryPath(dir);
+        //  dir = toDirectoryPath(dir);
         beginWrite();
         try {
             ensureOpen();
             if (dir.length == 0 || exists(dir))  // root dir, or exiting dir
                 throw new FileAlreadyExistsException(getString(dir));
             checkParents(dir);
-            Entry e = new Entry(dir, Entry.NEW);
+            Entry e = new Entry(dir, Entry.NEW, true);
             e.method = METHOD_STORED;            // STORED for dir
             update(e);
         } finally {
@@ -463,7 +464,7 @@
             } else {
                 checkParents(dst);
             }
-            Entry u = new Entry(eSrc, Entry.COPY);    // copy eSrc entry
+            Entry u = new Entry(eSrc, Entry.COPY);  // copy eSrc entry
             u.name(dst);                              // change name
             if (eSrc.type == Entry.NEW || eSrc.type == Entry.FILECH)
             {
@@ -533,7 +534,7 @@
                 if (!hasCreate && !hasCreateNew)
                     throw new NoSuchFileException(getString(path));
                 checkParents(path);
-                return getOutputStream(new Entry(path, Entry.NEW));
+                return getOutputStream(new Entry(path, Entry.NEW, false));
             }
         } finally {
             endRead();
@@ -887,7 +888,7 @@
         int off = getParentOff(path);
         if (off <= 1)
             return ROOTPATH;
-        return Arrays.copyOf(path, off + 1);
+        return Arrays.copyOf(path, off);
     }
 
     private static int getParentOff(byte[] path) {
@@ -1075,11 +1076,9 @@
             if (pos + CENHDR + nlen > limit) {
                 zerror("invalid CEN header (bad header size)");
             }
-            byte[] name = new byte[nlen + 1];
-            System.arraycopy(cen, pos + CENHDR, name, 1, nlen);
-            name[0] = '/';
-            IndexNode inode = new IndexNode(name, pos);
+            IndexNode inode = new IndexNode(cen, pos + CENHDR, nlen, pos);
             inodes.put(inode, inode);
+
             // skip ext and comment
             pos += (CENHDR + nlen + elen + clen);
         }
@@ -1112,7 +1111,7 @@
     private boolean hasUpdate = false;
 
     // shared key. consumer guarantees the "writeLock" before use it.
-    private final IndexNode LOOKUPKEY = IndexNode.keyOf(null);
+    private final IndexNode LOOKUPKEY = new IndexNode(null, -1);
 
     private void updateDelete(IndexNode inode) {
         beginWrite();
@@ -1312,16 +1311,7 @@
     IndexNode getInode(byte[] path) {
         if (path == null)
             throw new NullPointerException("path");
-        IndexNode key = IndexNode.keyOf(path);
-        IndexNode inode = inodes.get(key);
-        if (inode == null &&
-            (path.length == 0 || path[path.length -1] != '/')) {
-            // if does not ends with a slash
-            path = Arrays.copyOf(path, path.length + 1);
-            path[path.length - 1] = '/';
-            inode = inodes.get(key.as(path));
-        }
-        return inode;
+        return inodes.get(IndexNode.keyOf(path));
     }
 
     Entry getEntry(byte[] path) throws IOException {
@@ -1782,8 +1772,11 @@
         int    hashcode;  // node is hashable/hashed by its name
         int    pos = -1;  // position in cen table, -1 menas the
                           // entry does not exists in zip file
-        IndexNode(byte[] name) {
+        boolean isdir;
+
+        IndexNode(byte[] name, boolean isdir) {
             name(name);
+            this.isdir = isdir;
             this.pos = -1;
         }
 
@@ -1792,8 +1785,28 @@
             this.pos = pos;
         }
 
+        // constructor for cenInit()
+        IndexNode(byte[] cen, int noff, int nlen, int pos) {
+            if (cen[noff + nlen - 1] == '/') {
+                isdir = true;
+                nlen--;
+            }
+            name = new byte[nlen + 1];
+            System.arraycopy(cen, pos + CENHDR, name, 1, nlen);
+            name[0] = '/';
+            name(name);
+            this.pos = pos;
+        }
+
+        private static final ThreadLocal<IndexNode> cachedKey = new ThreadLocal<>();
+
         final static IndexNode keyOf(byte[] name) { // get a lookup key;
-            return new IndexNode(name, -1);
+            IndexNode key = cachedKey.get();
+            if (key == null) {
+                key = new IndexNode(name, -1);
+                cachedKey.set(key);
+            }
+            return key.as(name);
         }
 
         final void name(byte[] name) {
@@ -1807,8 +1820,7 @@
         }
 
         boolean isDir() {
-            return name != null &&
-                   (name.length == 0 || name[name.length - 1] == '/');
+            return isdir;
         }
 
         public boolean equals(Object other) {
@@ -1865,8 +1877,9 @@
 
         Entry() {}
 
-        Entry(byte[] name) {
+        Entry(byte[] name, boolean isdir) {
             name(name);
+            this.isdir = isdir;
             this.mtime  = this.ctime = this.atime = System.currentTimeMillis();
             this.crc    = 0;
             this.size   = 0;
@@ -1874,13 +1887,14 @@
             this.method = METHOD_DEFLATED;
         }
 
-        Entry(byte[] name, int type) {
-            this(name);
+        Entry(byte[] name, int type, boolean isdir) {
+            this(name, isdir);
             this.type = type;
         }
 
         Entry (Entry e, int type) {
             name(e.name);
+            this.isdir     = e.isdir;
             this.version   = e.version;
             this.ctime     = e.ctime;
             this.atime     = e.atime;
@@ -1902,7 +1916,7 @@
         }
 
         Entry (byte[] name, Path file, int type) {
-            this(name, type);
+            this(name, type, false);
             this.file = file;
             this.method = METHOD_STORED;
         }
@@ -1948,6 +1962,7 @@
             locoff      = CENOFF(cen, pos);
             pos += CENHDR;
             this.name = inode.name;
+            this.isdir = inode.isdir;
             this.hashcode = inode.hashcode;
 
             pos += nlen;
@@ -1974,9 +1989,10 @@
             int elenEXTT = 0;                // extra for Extended Timestamp
             boolean foundExtraTime = false;  // if time stamp NTFS, EXTT present
 
-            // confirm size/length
+            byte[] zname = isdir ? toDirectoryPath(name) : name;
 
-            int nlen = (name != null) ? name.length - 1 : 0;  // name has [0] as "slash"
+            // confirm size/length
+            int nlen = (zname != null) ? zname.length - 1 : 0;  // name has [0] as "slash"
             int elen = (extra != null) ? extra.length : 0;
             int eoff = 0;
             int clen = (comment != null) ? comment.length : 0;
@@ -2037,7 +2053,7 @@
             writeShort(os, 0);              // internal file attributes (unused)
             writeInt(os, 0);                // external file attributes (unused)
             writeInt(os, locoff0);          // relative offset of local header
-            writeBytes(os, name, 1, nlen);
+            writeBytes(os, zname, 1, nlen);
             if (elen64 != 0) {
                 writeShort(os, EXTID_ZIP64);// Zip64 extra
                 writeShort(os, elen64 - 4); // size of "this" extra block
@@ -2075,87 +2091,13 @@
         }
 
         ///////////////////// LOC //////////////////////
-        static Entry readLOC(ZipFileSystem zipfs, long pos)
-            throws IOException
-        {
-            return readLOC(zipfs, pos, new byte[1024]);
-        }
-
-        static Entry readLOC(ZipFileSystem zipfs, long pos, byte[] buf)
-            throws IOException
-        {
-            return new Entry().loc(zipfs, pos, buf);
-        }
-
-        Entry loc(ZipFileSystem zipfs, long pos, byte[] buf)
-            throws IOException
-        {
-            assert (buf.length >= LOCHDR);
-            if (zipfs.readFullyAt(buf, 0, LOCHDR , pos) != LOCHDR)
-                throw new ZipException("loc: reading failed");
-            if (!locSigAt(buf, 0))
-                throw new ZipException("loc: wrong sig ->"
-                                       + Long.toString(getSig(buf, 0), 16));
-            //startPos = pos;
-            version  = LOCVER(buf);
-            flag     = LOCFLG(buf);
-            method   = LOCHOW(buf);
-            mtime    = dosToJavaTime(LOCTIM(buf));
-            crc      = LOCCRC(buf);
-            csize    = LOCSIZ(buf);
-            size     = LOCLEN(buf);
-            int nlen = LOCNAM(buf);
-            int elen = LOCEXT(buf);
-
-            name = new byte[nlen + 1];
-            name[0] = '/';
-            if (zipfs.readFullyAt(name, 1, nlen, pos + LOCHDR) != nlen) {
-                throw new ZipException("loc: name reading failed");
-            }
-            if (elen > 0) {
-                extra = new byte[elen];
-                if (zipfs.readFullyAt(extra, 0, elen, pos + LOCHDR + nlen)
-                    != elen) {
-                    throw new ZipException("loc: ext reading failed");
-                }
-            }
-            pos += (LOCHDR + nlen + elen);
-            if ((flag & FLAG_DATADESCR) != 0) {
-                // Data Descriptor
-                Entry e = zipfs.getEntry(name);  // get the size/csize from cen
-                if (e == null)
-                    throw new ZipException("loc: name not found in cen");
-                size = e.size;
-                csize = e.csize;
-                pos += (method == METHOD_STORED ? size : csize);
-                if (size >= ZIP64_MINVAL || csize >= ZIP64_MINVAL)
-                    pos += 24;
-                else
-                    pos += 16;
-            } else {
-                if (extra != null &&
-                    (size == ZIP64_MINVAL || csize == ZIP64_MINVAL)) {
-                    // zip64 ext: must include both size and csize
-                    int off = 0;
-                    while (off + 20 < elen) {    // HeaderID+DataSize+Data
-                        int sz = SH(extra, off + 2);
-                        if (SH(extra, off) == EXTID_ZIP64 && sz == 16) {
-                            size = LL(extra, off + 4);
-                            csize = LL(extra, off + 12);
-                            break;
-                        }
-                        off += (sz + 4);
-                    }
-                }
-                pos += (method == METHOD_STORED ? size : csize);
-            }
-            return this;
-        }
 
         int writeLOC(OutputStream os) throws IOException {
             writeInt(os, LOCSIG);               // LOC header signature
             int version = version();
-            int nlen = (name != null) ? name.length - 1 : 0; // [0] is slash
+
+            byte[] zname = isdir ? toDirectoryPath(name) : name;
+            int nlen = (zname != null) ? zname.length - 1 : 0; // [0] is slash
             int elen = (extra != null) ? extra.length : 0;
             boolean foundExtraTime = false;     // if extra timestamp present
             int eoff = 0;
@@ -2214,7 +2156,7 @@
             }
             writeShort(os, nlen);
             writeShort(os, elen + elen64 + elenNTFS + elenEXTT);
-            writeBytes(os, name, 1, nlen);
+            writeBytes(os, zname, 1, nlen);
             if (elen64 != 0) {
                 writeShort(os, EXTID_ZIP64);
                 writeShort(os, 16);
@@ -2352,16 +2294,17 @@
                             locPos += locSZ;
                              continue;
                         }
+                        int end = locPos + locSZ - 4;
                         int flag = CH(buf, locPos++);
-                        if ((flag & 0x1) != 0) {
+                        if ((flag & 0x1) != 0 && locPos <= end) {
                             mtime = unixToJavaTime(LG(buf, locPos));
                             locPos += 4;
                         }
-                        if ((flag & 0x2) != 0) {
+                        if ((flag & 0x2) != 0 && locPos <= end) {
                             atime = unixToJavaTime(LG(buf, locPos));
                             locPos += 4;
                         }
-                        if ((flag & 0x4) != 0) {
+                        if ((flag & 0x4) != 0 && locPos <= end) {
                             ctime = unixToJavaTime(LG(buf, locPos));
                             locPos += 4;
                         }
@@ -2551,7 +2494,7 @@
     private void buildNodeTree() throws IOException {
         beginWrite();
         try {
-            IndexNode root = new IndexNode(ROOTPATH);
+            IndexNode root = new IndexNode(ROOTPATH, true);
             IndexNode[] nodes = inodes.keySet().toArray(new IndexNode[0]);
             inodes.put(root, root);
             ParentLookup lookup = new ParentLookup();
@@ -2564,7 +2507,7 @@
                         root.child = node;
                         break;
                     }
-                    lookup = lookup.as(node.name, off + 1);
+                    lookup = lookup.as(node.name, off);
                     if (inodes.containsKey(lookup)) {
                         parent = inodes.get(lookup);
                         node.sibling = parent.child;
@@ -2572,7 +2515,7 @@
                         break;
                     }
                     // add new pseudo directory entry
-                    parent = new IndexNode(Arrays.copyOf(node.name, off + 1));
+                    parent = new IndexNode(Arrays.copyOf(node.name, off), true);
                     inodes.put(parent, parent);
                     node.sibling = parent.child;
                     parent.child = node;
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,8 +59,7 @@
         } else {
             if (zfs.zc.isUTF8()) {
                 this.path = normalize(path);
-            } else {
-                // see normalize(String);
+            } else {    // see normalize(String);
                 this.path = normalize(zfs.getString(path));
             }
         }
@@ -68,12 +67,7 @@
 
     ZipPath(ZipFileSystem zfs, String path) {
         this.zfs = zfs;
-        if (zfs.zc.isUTF8()) {
-            this.path = normalize(zfs.getBytes(path));
-        } else {
-            // see normalize(String);
-            this.path = normalize(path);
-        }
+        this.path = normalize(path);
     }
 
     @Override
@@ -84,33 +78,31 @@
             return null;
     }
 
-    @Override
+   @Override
     public Path getFileName() {
-        initOffsets();
-        int count = offsets.length;
-        if (count == 0)
-            return null;  // no elements so no name
-        if (count == 1 && path[0] != '/')
+        int off = path.length;
+        if (off == 0 || off == 1 && path[0] == '/')
+            return null;
+        while (--off >= 0 && path[off] != '/') {}
+        if (off < 0)
             return this;
-        int lastOffset = offsets[count-1];
-        int len = path.length - lastOffset;
-        byte[] result = new byte[len];
-        System.arraycopy(path, lastOffset, result, 0, len);
-        return new ZipPath(zfs, result);
+        off++;
+        byte[] result = new byte[path.length - off];
+        System.arraycopy(path, off, result, 0, result.length);
+        return new ZipPath(getFileSystem(), result, true);
     }
 
     @Override
     public ZipPath getParent() {
-        initOffsets();
-        int count = offsets.length;
-        if (count == 0)    // no elements so no parent
+        int off = path.length;
+        if (off == 0 || off == 1 && path[0] == '/')
             return null;
-        int len = offsets[count-1] - 1;
-        if (len <= 0)      // parent is root only (may be null)
+        while (--off >= 0 && path[off] != '/') {}
+        if (off <= 0)
             return getRoot();
-        byte[] result = new byte[len];
-        System.arraycopy(path, 0, result, 0, len);
-        return new ZipPath(zfs, result);
+        byte[] result = new byte[off];
+        System.arraycopy(path, 0, result, 0, off);
+        return new ZipPath(getFileSystem(), result, true);
     }
 
     @Override
@@ -277,30 +269,36 @@
 
     @Override
     public boolean isAbsolute() {
-        return (this.path.length > 0 && path[0] == '/');
+        return path.length > 0 && path[0] == '/';
     }
 
     @Override
     public ZipPath resolve(Path other) {
-        final ZipPath o = checkPath(other);
-        int tlen = this.path.length;
-        if (tlen == 0 || o.isAbsolute())
+        ZipPath o = checkPath(other);
+        if (o.path.length == 0)
+            return this;
+        if (o.isAbsolute() || this.path.length == 0)
             return o;
-        int olen = o.path.length;
-        if (olen == 0)
-            return this;
+        return resolve(o.path);
+    }
+
+    // opath is normalized, just concat
+    private ZipPath resolve(byte[] opath) {
         byte[] resolved = null;
-        if (this.path[tlen - 1] == '/') {
+        byte[] tpath = this.path;
+        int tlen = tpath.length;
+        int olen = opath.length;
+        if (path[tlen - 1] == '/') {
             resolved = new byte[tlen + olen];
-            System.arraycopy(path, 0, resolved, 0, tlen);
-            System.arraycopy(o.path, 0, resolved, tlen, olen);
+            System.arraycopy(tpath, 0, resolved, 0, tlen);
+            System.arraycopy(opath, 0, resolved, tlen, olen);
         } else {
             resolved = new byte[tlen + 1 + olen];
-            System.arraycopy(path, 0, resolved, 0, tlen);
+            System.arraycopy(tpath, 0, resolved, 0, tlen);
             resolved[tlen] = '/';
-            System.arraycopy(o.path, 0, resolved, tlen + 1, olen);
+            System.arraycopy(opath, 0, resolved, tlen + 1, olen);
         }
-        return new ZipPath(zfs, resolved);
+        return new ZipPath(zfs, resolved, true);
     }
 
     @Override
@@ -351,7 +349,12 @@
 
     @Override
     public ZipPath resolve(String other) {
-        return resolve(zfs.getPath(other));
+        byte[] opath = normalize(other);
+        if (opath.length == 0)
+            return this;
+        if (opath[0] == '/' || this.path.length == 0)
+            return new ZipPath(zfs, opath, true);
+        return resolve(opath);
     }
 
     @Override
@@ -455,8 +458,9 @@
                 return normalize(path, i - 1);
             prevC = c;
         }
-        if (len > 1 && prevC == '/')
+        if (len > 1 && prevC == '/') {
             return Arrays.copyOf(path, len - 1);
+        }
         return path;
     }
 
@@ -490,6 +494,8 @@
     // to avoid incorrectly normalizing byte '0x5c' (as '\')
     // to '/'.
     private byte[] normalize(String path) {
+        if (zfs.zc.isUTF8())
+            return normalize(zfs.getBytes(path));
         int len = path.length();
         if (len == 0)
             return new byte[0];
@@ -533,7 +539,8 @@
     // Remove DotSlash(./) and resolve DotDot (..) components
     private byte[] getResolved() {
         for (int i = 0; i < path.length; i++) {
-            if (path[i] == (byte)'.') {
+            if (path[i] == (byte)'.' &&
+                (i + 1 == path.length || path[i + 1] == '/')) {
                 return resolve0();
             }
         }
@@ -976,5 +983,4 @@
         }
         return sb.toString();
     }
-
 }
--- a/jdk/src/linux/doc/man/ja/jvisualvm.1	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-'\" t
-.\"
-.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-.\"
-.\" This code is free software; you can redistribute it and/or modify it
-.\" under the terms of the GNU General Public License version 2 only, as
-.\" published by the Free Software Foundation.
-.\"
-.\" This code is distributed in the hope that it will be useful, but WITHOUT
-.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-.\" FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-.\" version 2 for more details (a copy is included in the LICENSE file that
-.\" accompanied this code).
-.\"
-.\" You should have received a copy of the GNU General Public License version
-.\" 2 along with this work; if not, write to the Free Software Foundation,
-.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-.\"
-.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-.\" or visit www.oracle.com if you need additional information or have any
-.\" questions.
-.\"
-.\" Title: jvisualvm
-.\" Language: Japanese
-.\" Date: 2013ǯ11·î21Æü
-.\" SectDesc: Java¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¡¢¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¢¥â¥Ë¥¿¥ê¥ó¥°¤ª¤è¤Ó´ÉÍý¥Ä¡¼¥ë
-.\" Software: JDK 8
-.\" Arch: ÈÆÍÑ
-.\" Part Number: E58103-01
-.\" Doc ID: JSSON
-.\"
-.if n .pl 99999
-.TH "jvisualvm" "1" "2013ǯ11·î21Æü" "JDK 8" "Java¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¡¢¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¢¥â¥Ë¥¿¥ê¥ó"
-.\" -----------------------------------------------------------------
-.\" * Define some portability stuff
-.\" -----------------------------------------------------------------
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" http://bugs.debian.org/507673
-.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.ie \n(.g .ds Aq \(aq
-.el       .ds Aq '
-.\" -----------------------------------------------------------------
-.\" * set default formatting
-.\" -----------------------------------------------------------------
-.\" disable hyphenation
-.nh
-.\" disable justification (adjust text to left margin only)
-.ad l
-.\" -----------------------------------------------------------------
-.\" * MAIN CONTENT STARTS HERE *
-.\" -----------------------------------------------------------------
-.SH "̾Á°"
-jvisualvm \- Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò»ë³ÐŪ¤Ë¥â¥Ë¥¿¡¼¡¢¥È¥é¥Ö¥ë¥·¥å¡¼¥È¤ª¤è¤Ó¥×¥í¥Õ¥¡¥¤¥ë¤·¤Þ¤¹¡£
-.SH "³µÍ×"
-.sp
-.if n \{\
-.RS 4
-.\}
-.nf
-\fBjvisualvm\fR [ \fIoptions\fR ]
-.fi
-.if n \{\
-.RE
-.\}
-.PP
-\fIoptions\fR
-.RS 4
-¥³¥Þ¥ó¥É¹Ô¥ª¥×¥·¥ç¥ó¡£¥ª¥×¥·¥ç¥ó¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
-.RE
-.SH "ÀâÌÀ"
-.PP
-Java VisualVM¤Ï¡¢»ØÄꤵ¤ì¤¿Java Virtual Machine (JVM)¤ÇJava¥Æ¥¯¥Î¥í¥¸¡¦¥Ù¡¼¥¹¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó(Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó)¤¬¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¤È¤­¤Ë¡¢¤½¤ÎJava¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë´Ø¤¹¤ë¾ÜºÙ¤Ê¾ðÊó¤òÄ󶡤¹¤ëľ´¶Åª¤Ê¥°¥é¥Õ¥£¥«¥ë¡¦¥æ¡¼¥¶¡¼¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ç¤¹¡£Java VisualVM¤È¤¤¤¦Ì¾Á°¤Ï¡¢Java VisualVM¤¬JVM¥½¥Õ¥È¥¦¥§¥¢¤Ë´Ø¤¹¤ë¾ðÊó¤ò»ë³ÐŪ¤ËÄ󶡤¹¤ë¤È¤¤¤¦»ö¼Â¤ËͳÍ褷¤Æ¤¤¤Þ¤¹¡£
-.PP
-Java VisualVM¤Ï¡¢¤¤¤¯¤Ä¤«¤Î¥â¥Ë¥¿¥ê¥ó¥°¡¢¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¤ª¤è¤Ó¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¦¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤ò1¤Ä¤Î¥Ä¡¼¥ë¤ËÅý¹ç¤·¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢¥¹¥¿¥ó¥É¥¢¥í¥ó¡¦¥Ä¡¼¥ë\fBjmap\fR¡¢\fBjinfo\fR¡¢\fBjstat\fR¤ª¤è¤Ó\fBjstack\fR¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ëµ¡Ç½¤Î¤Û¤È¤ó¤É¤¬¡¢Java VisualVM¤ËÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£\fBjconsole\fR¥³¥Þ¥ó¥É¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤ë°ìÉô¤Îµ¡Ç½¤Ê¤É¡¢Â¾¤Îµ¡Ç½¤Ï¥ª¥×¥·¥ç¥ó¤Î¥×¥é¥°¥¤¥ó¤È¤·¤ÆÄɲäǤ­¤Þ¤¹¡£
-.PP
-Java VisualVM¤Ï¡¢Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î³«È¯¼Ô¤¬¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¤ò¹Ô¤Ã¤¿¤ê¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤ò¥â¥Ë¥¿¡¼¤ª¤è¤Ó²þÁ±¤·¤¿¤ê¤¹¤ë¤Î¤ËÌòΩ¤Á¤Þ¤¹¡£Java VisualVM¤ò»ÈÍѤ¹¤ë¤È¡¢³«È¯¼Ô¤Ï¥Ò¡¼¥×¡¦¥À¥ó¥×¤ÎÀ¸À®¤ª¤è¤Ó²òÀÏ¡¢¥á¥â¥ê¡¼¡¦¥ê¡¼¥¯¤ÎÆÃÄê¡¢¥¬¥Ù¡¼¥¸¡¦¥³¥ì¥¯¥·¥ç¥ó¤Î¼Â¹Ô¤ª¤è¤Ó¥â¥Ë¥¿¡¼¡¢¤ª¤è¤Ó¥á¥â¥ê¡¼¤ÈCPU¤Î´Ê°×¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¤Î¼Â¹Ô¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£¥×¥é¥°¥¤¥ó¤ÇJava VisualVM¤Îµ¡Ç½¤ò³ÈÄ¥¤Ç¤­¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢\fBjconsole\fR¥³¥Þ¥ó¥É¤Î¤Û¤È¤ó¤É¤Îµ¡Ç½¤Ï¡¢¡ÖMBean¡×¥¿¥Ö¤ª¤è¤ÓJConsole Plug\-in Wrapper¥×¥é¥°¥¤¥ó¤ò²ð¤·¤Æ»ÈÍѤǤ­¤Þ¤¹¡£É¸½à¤ÎJava VisualVM¥×¥é¥°¥¤¥ó¤Î¥«¥¿¥í¥°¤«¤éÁªÂò¤¹¤ë¤Ë¤Ï¡¢Java VisualVM¥á¥Ë¥å¡¼¤Î\fB¡Ö¥Ä¡¼¥ë¡×\fR¡¢\fB¡Ö¥×¥é¥°¥¤¥ó¡×\fR¤òÁªÂò¤·¤Þ¤¹¡£
-.PP
-Java VisualVM¤òµ¯Æ°¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤·¤Þ¤¹¡£
-.sp
-.if n \{\
-.RS 4
-.\}
-.nf
-\fB%  jvisualvm <options>\fR
- 
-.fi
-.if n \{\
-.RE
-.\}
-.SH "¥ª¥×¥·¥ç¥ó"
-.PP
-¼¡¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢Java VisualVM¤òµ¯Æ°¤·¤¿¤È¤­¤Ë¼Â¹Ô²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£
-.PP
-\-J\fIjvm_option\fR
-.RS 4
-¤³¤Î\fBjvm_option\fR¤òJVM¥½¥Õ¥È¥¦¥§¥¢¤ËÅϤ·¤Þ¤¹¡£
-.RE
-.SH "´ØÏ¢¹àÌÜ"
-.sp
-.RS 4
-.ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Java VisualVM³«È¯¼Ô¤Î¥µ¥¤¥È
-http://visualvm\&.java\&.net/
-.RE
-.sp
-.RS 4
-.ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Java SE¥É¥­¥å¥á¥ó¥È¤ÎJava VisualVM
-(http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/visualvm/index\&.html)
-.RE
-.br
-'pl 8.5i
-'bp
--- a/jdk/src/linux/doc/man/jvisualvm.1	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-." Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
-." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-."
-." This code is free software; you can redistribute it and/or modify it
-." under the terms of the GNU General Public License version 2 only, as
-." published by the Free Software Foundation.
-."
-." This code is distributed in the hope that it will be useful, but WITHOUT
-." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-." version 2 for more details (a copy is included in the LICENSE file that
-." accompanied this code).
-."
-." You should have received a copy of the GNU General Public License version
-." 2 along with this work; if not, write to the Free Software Foundation,
-." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-."
-." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-." or visit www.oracle.com if you need additional information or have any
-." questions.
-."
-.TH jvisualvm 1 "10 May 2011"
-
-.LP
-.SH "Name"
-\f2jvisualvm\fP \- Java Virtual Machine Monitoring, Troubleshooting, and Profiling Tool
-.LP
-.SH "SYNOPSIS"
-.LP
-.nf
-\f3
-.fl
-        \fP\f3jvisualvm\fP [ \f2options\fP ]
-.fl
-.fi
-
-.LP
-.SH "PARAMETERS"
-.LP
-.LP
-Options, if used, should follow immediately after the command name. Options may be in any order. For a discussion of parameters that apply to a specific option, see OPTIONS below.
-.LP
-.SH "DESCRIPTION"
-.LP
-.LP
-Java VisualVM is an intuitive graphical user interface that provides detailed information about Java technology\-based applications (Java applications) while they are running on a given Java Virtual Machine (JVM(*)). The name Java VisualVM comes from the fact that Java VisualVM provides information about the JVM software \f2visually\fP.
-.LP
-.LP
-Java VisualVM combines several monitoring, troubleshooting, and profiling utilities into a single tool. For example, most of the functionality offered by the standalone tools \f2jmap\fP, \f2jinfo\fP, \f2jstat\fP and \f2jstack\fP have been integrated into Java VisualVM. Other functionalities, such as some of those offered by the JConsole tool, can be added as optional plug\-ins.
-.LP
-.SH "OPTIONS"
-.LP
-.LP
-The following option is possible when you launch Java VisualVM.
-.LP
-.RS 3
-.TP 3
-\-J<jvm_option>\  
-Pass this \f2<jvm_option>\fP to the JVM software. 
-.RE
-
-.LP
-.SH "USAGE"
-.LP
-.LP
-Java VisualVM is useful to Java application developers to troubleshoot applications and to monitor and improve the applications' performance. Java VisualVM can allow developers to generate and analyse heap dumps, track down memory leaks, perform and monitor garbage collection, and perform lightweight memory and CPU profiling. Plug\-ins also exist that expand the functionality of Java VisualVM. For example, most of the functionality of the JConsole tool is available via the MBeans Tab and JConsole Plug\-in Wrapper plug\-ins. You can choose from a catalog of standard Java VisualVM plug\-ins by selecting 'Tools' | 'Plugins' in the Java VisualVM menus.
-.LP
-.LP
-Start Java VisualVM with the following command:
-.LP
-.nf
-\f3
-.fl
-%  jvisualvm \fP\f4<options>\fP\f3
-.fl
-\fP
-.fi
-
-.LP
-.SH "SEE ALSO"
-.LP
-.LP
-For more details about Java VisualVM see the following pages.
-.LP
-.RS 3
-.TP 2
-o
-.na
-\f2Java VisualVM developers' site\fP @
-.fi
-http://visualvm.java.net 
-.TP 2
-o
-.na
-\f2Java VisualVM in Java SE platform documentation\fP @
-.fi
-http://download.oracle.com/javase/7/docs/technotes/guides/visualvm/index.html 
-.RE
-
-.LP
-.LP
-\f2(* The terms "Java Virtual Machine" and "JVM" mean a Virtual Machine for the Java platform.)\fP
-.LP
- 
--- a/jdk/src/solaris/doc/sun/man/man1/ja/jvisualvm.1	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-'\" t
-.\"
-.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-.\"
-.\" This code is free software; you can redistribute it and/or modify it
-.\" under the terms of the GNU General Public License version 2 only, as
-.\" published by the Free Software Foundation.
-.\"
-.\" This code is distributed in the hope that it will be useful, but WITHOUT
-.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-.\" FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-.\" version 2 for more details (a copy is included in the LICENSE file that
-.\" accompanied this code).
-.\"
-.\" You should have received a copy of the GNU General Public License version
-.\" 2 along with this work; if not, write to the Free Software Foundation,
-.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-.\"
-.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-.\" or visit www.oracle.com if you need additional information or have any
-.\" questions.
-.\"
-.\" Title: jvisualvm
-.\" Language: Japanese
-.\" Date: 2013ǯ11·î21Æü
-.\" SectDesc: Java¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¡¢¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¢¥â¥Ë¥¿¥ê¥ó¥°¤ª¤è¤Ó´ÉÍý¥Ä¡¼¥ë
-.\" Software: JDK 8
-.\" Arch: ÈÆÍÑ
-.\" Part Number: E58103-01
-.\" Doc ID: JSSON
-.\"
-.if n .pl 99999
-.TH "jvisualvm" "1" "2013ǯ11·î21Æü" "JDK 8" "Java¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¡¢¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¢¥â¥Ë¥¿¥ê¥ó"
-.\" -----------------------------------------------------------------
-.\" * Define some portability stuff
-.\" -----------------------------------------------------------------
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" http://bugs.debian.org/507673
-.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.ie \n(.g .ds Aq \(aq
-.el       .ds Aq '
-.\" -----------------------------------------------------------------
-.\" * set default formatting
-.\" -----------------------------------------------------------------
-.\" disable hyphenation
-.nh
-.\" disable justification (adjust text to left margin only)
-.ad l
-.\" -----------------------------------------------------------------
-.\" * MAIN CONTENT STARTS HERE *
-.\" -----------------------------------------------------------------
-.SH "̾Á°"
-jvisualvm \- Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò»ë³ÐŪ¤Ë¥â¥Ë¥¿¡¼¡¢¥È¥é¥Ö¥ë¥·¥å¡¼¥È¤ª¤è¤Ó¥×¥í¥Õ¥¡¥¤¥ë¤·¤Þ¤¹¡£
-.SH "³µÍ×"
-.sp
-.if n \{\
-.RS 4
-.\}
-.nf
-\fBjvisualvm\fR [ \fIoptions\fR ]
-.fi
-.if n \{\
-.RE
-.\}
-.PP
-\fIoptions\fR
-.RS 4
-¥³¥Þ¥ó¥É¹Ô¥ª¥×¥·¥ç¥ó¡£¥ª¥×¥·¥ç¥ó¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
-.RE
-.SH "ÀâÌÀ"
-.PP
-Java VisualVM¤Ï¡¢»ØÄꤵ¤ì¤¿Java Virtual Machine (JVM)¤ÇJava¥Æ¥¯¥Î¥í¥¸¡¦¥Ù¡¼¥¹¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó(Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó)¤¬¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¤È¤­¤Ë¡¢¤½¤ÎJava¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë´Ø¤¹¤ë¾ÜºÙ¤Ê¾ðÊó¤òÄ󶡤¹¤ëľ´¶Åª¤Ê¥°¥é¥Õ¥£¥«¥ë¡¦¥æ¡¼¥¶¡¼¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ç¤¹¡£Java VisualVM¤È¤¤¤¦Ì¾Á°¤Ï¡¢Java VisualVM¤¬JVM¥½¥Õ¥È¥¦¥§¥¢¤Ë´Ø¤¹¤ë¾ðÊó¤ò»ë³ÐŪ¤ËÄ󶡤¹¤ë¤È¤¤¤¦»ö¼Â¤ËͳÍ褷¤Æ¤¤¤Þ¤¹¡£
-.PP
-Java VisualVM¤Ï¡¢¤¤¤¯¤Ä¤«¤Î¥â¥Ë¥¿¥ê¥ó¥°¡¢¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¤ª¤è¤Ó¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¦¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤ò1¤Ä¤Î¥Ä¡¼¥ë¤ËÅý¹ç¤·¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢¥¹¥¿¥ó¥É¥¢¥í¥ó¡¦¥Ä¡¼¥ë\fBjmap\fR¡¢\fBjinfo\fR¡¢\fBjstat\fR¤ª¤è¤Ó\fBjstack\fR¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ëµ¡Ç½¤Î¤Û¤È¤ó¤É¤¬¡¢Java VisualVM¤ËÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£\fBjconsole\fR¥³¥Þ¥ó¥É¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤ë°ìÉô¤Îµ¡Ç½¤Ê¤É¡¢Â¾¤Îµ¡Ç½¤Ï¥ª¥×¥·¥ç¥ó¤Î¥×¥é¥°¥¤¥ó¤È¤·¤ÆÄɲäǤ­¤Þ¤¹¡£
-.PP
-Java VisualVM¤Ï¡¢Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î³«È¯¼Ô¤¬¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¤ò¹Ô¤Ã¤¿¤ê¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤ò¥â¥Ë¥¿¡¼¤ª¤è¤Ó²þÁ±¤·¤¿¤ê¤¹¤ë¤Î¤ËÌòΩ¤Á¤Þ¤¹¡£Java VisualVM¤ò»ÈÍѤ¹¤ë¤È¡¢³«È¯¼Ô¤Ï¥Ò¡¼¥×¡¦¥À¥ó¥×¤ÎÀ¸À®¤ª¤è¤Ó²òÀÏ¡¢¥á¥â¥ê¡¼¡¦¥ê¡¼¥¯¤ÎÆÃÄê¡¢¥¬¥Ù¡¼¥¸¡¦¥³¥ì¥¯¥·¥ç¥ó¤Î¼Â¹Ô¤ª¤è¤Ó¥â¥Ë¥¿¡¼¡¢¤ª¤è¤Ó¥á¥â¥ê¡¼¤ÈCPU¤Î´Ê°×¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¤Î¼Â¹Ô¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£¥×¥é¥°¥¤¥ó¤ÇJava VisualVM¤Îµ¡Ç½¤ò³ÈÄ¥¤Ç¤­¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢\fBjconsole\fR¥³¥Þ¥ó¥É¤Î¤Û¤È¤ó¤É¤Îµ¡Ç½¤Ï¡¢¡ÖMBean¡×¥¿¥Ö¤ª¤è¤ÓJConsole Plug\-in Wrapper¥×¥é¥°¥¤¥ó¤ò²ð¤·¤Æ»ÈÍѤǤ­¤Þ¤¹¡£É¸½à¤ÎJava VisualVM¥×¥é¥°¥¤¥ó¤Î¥«¥¿¥í¥°¤«¤éÁªÂò¤¹¤ë¤Ë¤Ï¡¢Java VisualVM¥á¥Ë¥å¡¼¤Î\fB¡Ö¥Ä¡¼¥ë¡×\fR¡¢\fB¡Ö¥×¥é¥°¥¤¥ó¡×\fR¤òÁªÂò¤·¤Þ¤¹¡£
-.PP
-Java VisualVM¤òµ¯Æ°¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤·¤Þ¤¹¡£
-.sp
-.if n \{\
-.RS 4
-.\}
-.nf
-\fB%  jvisualvm <options>\fR
- 
-.fi
-.if n \{\
-.RE
-.\}
-.SH "¥ª¥×¥·¥ç¥ó"
-.PP
-¼¡¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢Java VisualVM¤òµ¯Æ°¤·¤¿¤È¤­¤Ë¼Â¹Ô²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£
-.PP
-\-J\fIjvm_option\fR
-.RS 4
-¤³¤Î\fBjvm_option\fR¤òJVM¥½¥Õ¥È¥¦¥§¥¢¤ËÅϤ·¤Þ¤¹¡£
-.RE
-.SH "´ØÏ¢¹àÌÜ"
-.sp
-.RS 4
-.ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Java VisualVM³«È¯¼Ô¤Î¥µ¥¤¥È
-http://visualvm\&.java\&.net/
-.RE
-.sp
-.RS 4
-.ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Java SE¥É¥­¥å¥á¥ó¥È¤ÎJava VisualVM
-(http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/visualvm/index\&.html)
-.RE
-.br
-'pl 8.5i
-'bp
--- a/jdk/src/solaris/doc/sun/man/man1/jvisualvm.1	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-." Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
-." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-."
-." This code is free software; you can redistribute it and/or modify it
-." under the terms of the GNU General Public License version 2 only, as
-." published by the Free Software Foundation.
-."
-." This code is distributed in the hope that it will be useful, but WITHOUT
-." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-." version 2 for more details (a copy is included in the LICENSE file that
-." accompanied this code).
-."
-." You should have received a copy of the GNU General Public License version
-." 2 along with this work; if not, write to the Free Software Foundation,
-." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-."
-." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-." or visit www.oracle.com if you need additional information or have any
-." questions.
-."
-.TH jvisualvm 1 "10 May 2011"
-
-.LP
-.SH "Name"
-\f2jvisualvm\fP \- Java Virtual Machine Monitoring, Troubleshooting, and Profiling Tool
-.LP
-.SH "SYNOPSIS"
-.LP
-.nf
-\f3
-.fl
-        \fP\f3jvisualvm\fP [ \f2options\fP ]
-.fl
-.fi
-
-.LP
-.SH "PARAMETERS"
-.LP
-.LP
-Options, if used, should follow immediately after the command name. Options may be in any order. For a discussion of parameters that apply to a specific option, see OPTIONS below.
-.LP
-.SH "DESCRIPTION"
-.LP
-.LP
-Java VisualVM is an intuitive graphical user interface that provides detailed information about Java technology\-based applications (Java applications) while they are running on a given Java Virtual Machine (JVM(*)). The name Java VisualVM comes from the fact that Java VisualVM provides information about the JVM software \f2visually\fP.
-.LP
-.LP
-Java VisualVM combines several monitoring, troubleshooting, and profiling utilities into a single tool. For example, most of the functionality offered by the standalone tools \f2jmap\fP, \f2jinfo\fP, \f2jstat\fP and \f2jstack\fP have been integrated into Java VisualVM. Other functionalities, such as some of those offered by the JConsole tool, can be added as optional plug\-ins.
-.LP
-.SH "OPTIONS"
-.LP
-.LP
-The following option is possible when you launch Java VisualVM.
-.LP
-.RS 3
-.TP 3
-\-J<jvm_option>\  
-Pass this \f2<jvm_option>\fP to the JVM software. 
-.RE
-
-.LP
-.SH "USAGE"
-.LP
-.LP
-Java VisualVM is useful to Java application developers to troubleshoot applications and to monitor and improve the applications' performance. Java VisualVM can allow developers to generate and analyse heap dumps, track down memory leaks, perform and monitor garbage collection, and perform lightweight memory and CPU profiling. Plug\-ins also exist that expand the functionality of Java VisualVM. For example, most of the functionality of the JConsole tool is available via the MBeans Tab and JConsole Plug\-in Wrapper plug\-ins. You can choose from a catalog of standard Java VisualVM plug\-ins by selecting 'Tools' | 'Plugins' in the Java VisualVM menus.
-.LP
-.LP
-Start Java VisualVM with the following command:
-.LP
-.nf
-\f3
-.fl
-%  jvisualvm \fP\f4<options>\fP\f3
-.fl
-\fP
-.fi
-
-.LP
-.SH "SEE ALSO"
-.LP
-.LP
-For more details about Java VisualVM see the following pages.
-.LP
-.RS 3
-.TP 2
-o
-.na
-\f2Java VisualVM developers' site\fP @
-.fi
-http://visualvm.java.net 
-.TP 2
-o
-.na
-\f2Java VisualVM in Java SE platform documentation\fP @
-.fi
-http://download.oracle.com/javase/7/docs/technotes/guides/visualvm/index.html 
-.RE
-
-.LP
-.LP
-\f2(* The terms "Java Virtual Machine" and "JVM" mean a Virtual Machine for the Java platform.)\fP
-.LP
- 
--- a/jdk/test/ProblemList.txt	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/ProblemList.txt	Tue Jan 24 00:30:25 2017 +0100
@@ -1,6 +1,6 @@
 ###########################################################################
 #
-# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -141,8 +141,6 @@
 
 # jdk_io
 
-java/io/pathNames/GeneralWin32.java                             8156595 windows-all
-
 ############################################################################
 
 # jdk_management
@@ -199,9 +197,9 @@
 
 java/rmi/activation/Activatable/extLoadedImpl/ext.sh            8062724 generic-all
 
-sun/rmi/rmic/newrmic/equivalence/run.sh                         8145980 generic-all
+java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java 8169569 windows-all
 
-java/rmi/registry/readTest/readTest.sh                          7146543 generic-all
+sun/rmi/rmic/newrmic/equivalence/run.sh                         8145980 generic-all
 
 ############################################################################
 
@@ -260,6 +258,8 @@
 
 tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java       8169971 windows-x64
 
+tools/jlink/CustomPluginTest.java                               8172864 generic-all
+
 ############################################################################
 
 # jdk_jdi
--- a/jdk/test/TEST.ROOT	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/TEST.ROOT	Tue Jan 24 00:30:25 2017 +0100
@@ -26,8 +26,8 @@
 # Allow querying of various System properties in @requires clauses
 requires.properties=sun.arch.data.model java.runtime.name
 
-# Tests using jtreg 4.2 b04 features
-requiredVersion=4.2 b04
+# Tests using jtreg 4.2 b05 features
+requiredVersion=4.2 b05
 
 # Path to libraries in the topmost test directory. This is needed so @library
 # does not need ../../ notation to reach them
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -1,6 +1,6 @@
-grant 
-{
+grant codeBase "file:${test.classes}/*" {
     permission java.security.SecurityPermission "removeProvider.SunJCE";
     permission java.security.SecurityPermission "insertProvider.SunJCE";
-    permission java.security.SecurityPermission "putProviderProperty.SunJCE";
+    permission java.lang.RuntimePermission
+               "accessClassInPackage.com.sun.crypto.provider";
 };
--- a/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckConfigs.policy	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckConfigs.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -1,9 +1,9 @@
-
-grant {
+grant codeBase "file:${test.classes}/*" {
     // The following permissions are not required because the test is
     // not expected to connect to an LDAP server
     //
     //permission java.net.SocketPermission "*:389", "connect";
     //permission java.net.SocketPermission "*:636", "connect";
     //permission javax.security.auth.AuthPermission "modifyPrincipals";
+    permission java.lang.RuntimePermission "accessClassInPackage.com.sun.jndi.ldap";
 };
--- a/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8169589
+ * @bug 8169589 8171909
  * @summary Activating a dialog puts to back another dialog owned by the same frame
  * @author Dmitry Markov
  * @library ../../regtesthelpers
@@ -68,7 +68,7 @@
         int y = point.y + (int)(dialog1.getHeight() * 0.9);
 
         try {
-            if (!robot.getPixelColor(x, y).equals(dialog1.getBackground())) {
+            if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
                 throw new RuntimeException("Test FAILED: Dialog is behind the frame");
             }
         } finally {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/NormalToIconified/NormalToIconifiedTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,105 @@
+/*
+ * 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 8171949
+ * @summary Tests that bitwise mask is set and state listener is notified during state transition.
+ * @author Dmitry Markov
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main NormalToIconifiedTest
+ */
+
+import java.awt.Frame;
+import java.awt.Robot;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowStateListener;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class NormalToIconifiedTest {
+    private static final AtomicBoolean listenerNotified = new AtomicBoolean(false);
+
+    public static void main(String[] args) {
+        Robot robot = Util.createRobot();
+
+        Frame testFrame = new Frame("Test Frame");
+        testFrame.setSize(200, 200);
+        testFrame.addWindowStateListener(new WindowStateListener() {
+            @Override
+            public void windowStateChanged(WindowEvent e) {
+                listenerNotified.set(true);
+                synchronized (listenerNotified) {
+                    listenerNotified.notifyAll();
+                }
+            }
+        });
+        testFrame.setVisible(true);
+
+        Frame mainFrame = new Frame("Main Frame");
+        mainFrame.setSize(200, 200);
+        mainFrame.setLocationRelativeTo(null);
+        mainFrame.setVisible(true);
+
+        Util.waitForIdle(robot);
+
+        try {
+            Util.clickOnComp(mainFrame, robot);
+            Util.waitForIdle(robot);
+
+            // NORMAL -> ICONIFIED
+            listenerNotified.set(false);
+            testFrame.setExtendedState(Frame.ICONIFIED);
+            Util.waitForIdle(robot);
+
+            Util.waitForCondition(listenerNotified, 2000);
+            if (!listenerNotified.get()) {
+                throw new RuntimeException("Test FAILED! Window state listener was not notified during NORMAL to" +
+                        "ICONIFIED transition");
+            }
+            if (testFrame.getExtendedState() != Frame.ICONIFIED) {
+                throw new RuntimeException("Test FAILED! Frame is not in ICONIFIED state");
+            }
+
+            // ICONIFIED -> NORMAL
+            listenerNotified.set(false);
+            testFrame.setExtendedState(Frame.NORMAL);
+            Util.waitForIdle(robot);
+
+            Util.waitForCondition(listenerNotified, 2000);
+            if (!listenerNotified.get()) {
+                throw new RuntimeException("Test FAILED! Window state listener was not notified during ICONIFIED to" +
+                        "NORMAL transition");
+            }
+            if (testFrame.getExtendedState() != Frame.NORMAL) {
+                throw new RuntimeException("Test FAILED! Frame is not in NORMAL state");
+            }
+        } finally {
+            testFrame.dispose();
+            mainFrame.dispose();
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,70 @@
+/*
+ * 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 8171952
+ * @summary Tests that getMousePosition() returns null for obscured component.
+ * @author Dmitry Markov
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main ObscuredFrameTest
+ */
+
+import java.awt.*;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class ObscuredFrameTest {
+    public static void main(String[] args) {
+        Robot robot = Util.createRobot();
+
+        Frame frame = new Frame("Obscured Frame");
+        frame.setSize(200, 200);
+        frame.setLocationRelativeTo(null);
+        Button button = new Button("Button");
+        frame.add(button);
+
+        Dialog dialog = new Dialog(frame, "Visible Dialog", false);
+        dialog.setSize(200, 200);
+        dialog.setLocationRelativeTo(null);
+        dialog.setVisible(true);
+
+        frame.setVisible(true);
+
+        Util.waitForIdle(robot);
+
+        Util.pointOnComp(button, robot);
+        Util.waitForIdle(robot);
+
+        try {
+            if (button.getMousePosition() != null) {
+                throw new RuntimeException("Test Failed! Mouse position is not null for obscured component.");
+            }
+        } finally {
+            frame.dispose();
+            dialog.dispose();
+        }
+    }
+}
+
--- a/jdk/test/java/awt/Window/ChangeWindowResizabilty/ChangeWindowResizabiltyTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/awt/Window/ChangeWindowResizabilty/ChangeWindowResizabiltyTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -23,7 +23,7 @@
 
 /* @test
    @key headful
-   @bug      8166897
+   @bug      8166897 8167652
    @summary  Some font overlap in the Optionpane dialog.
    @run      main ChangeWindowResizabiltyTest
 */
@@ -34,41 +34,75 @@
 import java.awt.Frame;
 import java.awt.Panel;
 import java.awt.Robot;
+import java.awt.Point;
 
 public class ChangeWindowResizabiltyTest {
     public static void main(String[] args) throws Exception {
         Robot robot = new Robot();
         for(int i = 0; i < 10; i++) {
             Dialog dialog = new Dialog((Frame) null);
+            dialog.setLocation(100, 100);
             Component panel = new Panel();
             panel.setPreferredSize(new Dimension(200, 100));
             dialog.add(panel);
             dialog.pack();
             dialog.setVisible(true);
+            robot.waitForIdle();
+            robot.delay(200);
+
+            Point frameLoc = dialog.getLocationOnScreen();
+            Point contentLoc = panel.getLocationOnScreen();
+
+            System.out.println("Decor location " + frameLoc);
+            System.out.println("Content location " + contentLoc);
 
             dialog.setResizable(false);
             robot.waitForIdle();
             robot.delay(200);
 
-            System.out.println(panel.getLocationOnScreen());
-            System.out.println(dialog.getLocationOnScreen());
+            Point l = dialog.getLocationOnScreen();
+            if (!l.equals(frameLoc)) {
+                dialog.dispose();
+                throw new RuntimeException("Decorated frame location moved " +
+                        "after setResizable(false)" + l);
+            }
+
+            l = panel.getLocationOnScreen();
+            if (!l.equals(contentLoc)) {
+                dialog.dispose();
+                throw new RuntimeException("Content location moved after " +
+                        "setResizable(false)" + l);
+            }
+
             if (panel.getLocationOnScreen().y <
-                       dialog.getLocationOnScreen().y + dialog.getInsets().top) {
+                      dialog.getLocationOnScreen().y + dialog.getInsets().top) {
                 dialog.dispose();
                 throw new RuntimeException(
-                        "Wrong content position after setResizable(false)");
+                            "Wrong content position after setResizable(false)");
             }
 
             dialog.setResizable(true);
             robot.waitForIdle();
             robot.delay(200);
-            System.out.println(panel.getLocationOnScreen());
-            System.out.println(dialog.getLocationOnScreen());
+
+            l = dialog.getLocationOnScreen();
+            if (!l.equals(frameLoc)) {
+                dialog.dispose();
+                throw new RuntimeException("Decorated frame location moved " +
+                        "after setResizable(true)" + l);
+            }
+
+            l = panel.getLocationOnScreen();
+            if (!l.equals(contentLoc)) {
+                dialog.dispose();
+                throw new RuntimeException("Content location moved after " +
+                        "setResizable(true)" + l);
+            }
             if (panel.getLocationOnScreen().y <
-                    dialog.getLocationOnScreen().y + dialog.getInsets().top) {
+                      dialog.getLocationOnScreen().y + dialog.getInsets().top) {
                 dialog.dispose();
                 throw new RuntimeException(
-                        "Wrong content position after setResizable(true)");
+                             "Wrong content position after setResizable(true)");
             }
 
             dialog.dispose();
--- a/jdk/test/java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -22,7 +22,6 @@
  */
 
 import sun.awt.image.MultiResolutionToolkitImage;
-import sun.java2d.SunGraphics2D;
 
 import javax.swing.*;
 import java.awt.*;
@@ -37,7 +36,6 @@
  * @summary [macosx] Drag image of TransferHandler does not honor
  * MultiResolutionImage
  * @modules java.desktop/sun.awt.image
- *          java.desktop/sun.java2d
  * @run main MultiResolutionDragImageTest TEST_DRAG
  */
 public class MultiResolutionDragImageTest {
@@ -126,30 +124,11 @@
         return Math.abs(n - m) <= 50;
     }
 
-    private static float getScaleFactor() {
-
-        final Dialog dialog = new Dialog((Window) null);
-        dialog.setSize(100, 100);
-        dialog.setModal(true);
-        final float[] scaleFactors = new float[1];
-        Panel panel = new Panel() {
-
-            @Override
-            public void paint(Graphics g) {
-                float scaleFactor = 1;
-                if (g instanceof SunGraphics2D) {
-                    scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
-                }
-                scaleFactors[0] = scaleFactor;
-                dialog.setVisible(false);
-            }
-        };
-
-        dialog.add(panel);
-        dialog.setVisible(true);
-        dialog.dispose();
-
-        return scaleFactors[0];
+    static float getScaleFactor() {
+        return (float) GraphicsEnvironment.
+                getLocalGraphicsEnvironment().
+                getDefaultScreenDevice().getDefaultConfiguration().
+                getDefaultTransform().getScaleX();
     }
 
     private static Image createMultiResolutionImage() {
--- a/jdk/test/java/awt/font/GlyphVector/TestLayoutFlags.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/awt/font/GlyphVector/TestLayoutFlags.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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,7 +23,7 @@
 
 
 /* @test
-   @bug 4328745 5090704
+   @bug 4328745 5090704 8166111
    @summary exercise getLayoutFlags, getGlyphCharIndex, getGlyphCharIndices
  */
 
@@ -82,7 +82,7 @@
         test("latin", latinGV, GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
         test("hebrew", hebrewGV, GlyphVector.FLAG_RUN_RTL |
              GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
-        test("arabic", arabicGV, GlyphVector.FLAG_RUN_RTL |
+        test("arabic", arabicGV, GlyphVector.FLAG_COMPLEX_GLYPHS |
              GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
         test("hindi", hindiGV, GlyphVector.FLAG_COMPLEX_GLYPHS |
              GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/Raster/TestChildRasterOp.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8130737 8172559
+ * @summary test no exception rasterop for child raster with non-zero offset
+ */
+
+import java.awt.geom.AffineTransform;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DataBufferUShort;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+public class TestChildRasterOp {
+
+    private static AffineTransform at = new AffineTransform();
+    private static final AffineTransformOp rop =
+        new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
+    private static int[] offsets = {0};
+
+    public static void main(String[] args) {
+        testByteRaster();
+        testShortRaster();
+        testIntRaster();
+    }
+
+    private static void testByteRaster() {
+        WritableRaster srcRaster, dstRaster;
+
+        byte[] pixels =
+            { 11, 12, 13, 14,
+              21, 22, 23, 24,
+              31, 32, 33, 34,
+              41, 42, 43, 44 };
+
+        DataBuffer db = new DataBufferByte(pixels, pixels.length);
+        srcRaster =
+            Raster.createInterleavedRaster(db, 4, 4, 4, 1, offsets, null);
+        srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null);
+        dstRaster = rop.filter(srcRaster, null);
+    }
+
+    private static void testShortRaster() {
+        WritableRaster srcRaster, dstRaster;
+
+        short[] pixels =
+            { 11, 12, 13, 14,
+              21, 22, 23, 24,
+              31, 32, 33, 34,
+              41, 42, 43, 44 };
+
+        DataBuffer db = new DataBufferUShort(pixels, pixels.length);
+        srcRaster =
+            Raster.createInterleavedRaster(db, 4, 4, 4, 1, offsets, null);
+        srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null);
+        dstRaster = rop.filter(srcRaster, null);
+    }
+
+    private static void testIntRaster() {
+        WritableRaster srcRaster, dstRaster;
+
+        int[] pixels =
+            { 11, 12, 13, 14,
+              21, 22, 23, 24,
+              31, 32, 33, 34,
+              41, 42, 43, 44 };
+
+        DataBuffer db = new DataBufferInt(pixels, pixels.length);
+        srcRaster =
+            Raster.createPackedRaster(db, 4, 4, 4,  offsets, null);
+        srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null);
+        dstRaster = rop.filter(srcRaster, null);
+    }
+}
--- a/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java	Tue Jan 24 00:30:25 2017 +0100
@@ -24,16 +24,28 @@
 /*
  * @test
  * @key headful
- * @bug 7108598
+ * @bug 7108598 8172009
  * @summary Container.paint/KeyboardFocusManager.clearMostRecentFocusOwner methods deadlock
  * @library ../../regtesthelpers
  * @author Oleg Pekhovskiy
  * @build Util
- * @run main/timeout=20 PaintSetEnabledDeadlock
+ * @run main PaintSetEnabledDeadlock
  */
 
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.Image;
+import java.awt.Panel;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
 import test.java.awt.regtesthelpers.Util;
 
 public class PaintSetEnabledDeadlock extends Frame {
--- a/jdk/test/java/awt/print/PrinterJob/BannerTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/awt/print/PrinterJob/BannerTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -22,7 +22,7 @@
  */
 /*
  * @test
- * @bug 6575247
+ * @bug 6575247 8170579
  * @summary  Verifies if Banner page is printed
  * @requires (os.family == "linux" | os.family == "solaris")
  * @run main/manual BannerTest
@@ -39,6 +39,9 @@
 import static java.awt.print.Printable.PAGE_EXISTS;
 import java.awt.print.PrinterException;
 import java.awt.print.PrinterJob;
+import javax.print.PrintService;
+import javax.print.attribute.standard.JobSheets;
+import javax.print.attribute.standard.SheetCollate;
 import javax.swing.JButton;
 import javax.swing.JDialog;
 import javax.swing.JPanel;
@@ -50,8 +53,18 @@
     private static Thread mainThread;
     private static boolean testPassed;
     private static boolean testGeneratedInterrupt;
+    private static volatile PrinterJob job;
 
     public static void main(String[] args)  throws Exception {
+        job = PrinterJob.getPrinterJob();
+        PrintService prtSrv = job.getPrintService();
+        if (job.getPrintService() == null) {
+            System.out.println("No printers. Test cannot continue");
+            return;
+        }
+        if (!prtSrv.isAttributeCategorySupported(JobSheets.class)) {
+            return;
+        }
         SwingUtilities.invokeAndWait(() -> {
             doTest(BannerTest::printTest);
         });
@@ -69,11 +82,6 @@
     }
 
     private static void printTest() {
-        PrinterJob job = PrinterJob.getPrinterJob();
-        if (job.getPrintService() == null) {
-            System.out.println("No printers. Test cannot continue");
-            return;
-        }
         job.setPrintable(new BannerTest());
         if(job.printDialog()) {
             try {
--- a/jdk/test/java/awt/print/PrinterJob/TestCheckSystemDefaultBannerOption.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/awt/print/PrinterJob/TestCheckSystemDefaultBannerOption.java	Tue Jan 24 00:30:25 2017 +0100
@@ -22,7 +22,7 @@
  */
 /*
  * @test
- * @bug 8165947
+ * @bug 8165947 8170579
  * @summary  Verifies System default banner page option is honoured by jdk
  * @requires (os.family == "linux" | os.family == "solaris")
  * @run main/manual TestCheckSystemDefaultBannerOption
@@ -38,6 +38,7 @@
 import static java.awt.print.Printable.PAGE_EXISTS;
 import java.awt.print.PrinterException;
 import java.awt.print.PrinterJob;
+import javax.print.PrintService;
 import javax.print.attribute.standard.JobSheets;
 import javax.swing.JButton;
 import javax.swing.JDialog;
@@ -56,10 +57,15 @@
     public static void main (String[] args) throws Exception {
 
         job = PrinterJob.getPrinterJob();
-        if (job.getPrintService() == null) {
+        PrintService prtSrv = job.getPrintService();
+        if (prtSrv == null) {
             System.out.println("No printers. Test cannot continue");
             return;
         }
+        // do not run the test if JobSheet category is not supported
+        if (!prtSrv.isAttributeCategorySupported(JobSheets.class)) {
+            return;
+        }
         // check system default banner option and let user know what to expect
         JobSheets js = (JobSheets)job.getPrintService().
                 getDefaultAttributeValue(JobSheets.class);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/File/WinDirRelative.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 8153250
+ * @summary Tests that files are correctly listed for a directory-relative path
+ * @requires (os.family == "windows")
+ */
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class WinDirRelative {
+    private static final char COLON = ':';
+    private static final String BASENAME = "TestFile_";
+    private static final String EXTENSION = ".txt";
+    private static final int NUM_FILES = 10;
+
+    private static boolean isLetter(char c) {
+        return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
+    }
+
+    public static void main(String[] args) throws Throwable {
+        // Get the working directory which is also the default
+        // directory for the current drive.
+        String userDir = System.getProperty("user.dir");
+
+        // Test only if a leading drive letter is found
+        if (isLetter(userDir.charAt(0)) && userDir.charAt(1) == COLON) {
+            // Create some empty files
+            List<String> filenames = new ArrayList<String>(NUM_FILES);
+            for (int i = 0; i < NUM_FILES; i++) {
+                String filename = BASENAME + i + EXTENSION;
+                filenames.add(filename);
+                File f = new File(filename);
+                f.createNewFile();
+                f.deleteOnExit();
+                System.out.printf("Created %s (%s)%n", filename,
+                    f.getAbsolutePath());
+            }
+
+            // List files and verify that the ones with recognized names exist.
+            String prefix = userDir.substring(0, 2);
+            File p = new File(prefix);
+            int failures = 0;
+            int successes = 0;
+            for (File f : p.listFiles()) {
+                if (f.getName().toString().startsWith(BASENAME)) {
+                    if (!f.exists()) {
+                        System.err.printf("%s (%s) does not exist%n", f,
+                            f.getAbsolutePath());
+                        failures++;
+                    } else {
+                        successes++;
+                    }
+                }
+            }
+
+            // Fail if there was an existence test failure or if not
+            // enough of the created files were found
+            boolean testFailed = false;
+            if (failures > 0) {
+                System.err.println("Existence check failed");
+                testFailed = true;
+            }
+            if (successes != NUM_FILES) {
+                System.err.println("Count check failed");
+                testFailed = true;
+            }
+            if (testFailed) {
+                throw new RuntimeException("Test failed");
+            }
+        }
+    }
+}
--- a/jdk/test/java/io/File/createTempFile/Patterns.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/io/File/createTempFile/Patterns.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
  */
 
 /* @test
-   @bug 4152178
+   @bug 4152178 8152272
    @summary Check various temp-file prefix/suffix cases */
 
 import java.io.File;
@@ -66,6 +66,7 @@
         cky("xxx", "");
         cky("xxx", "y");
         cky("xxx", ".y");
+        cky("xyz", "Directory" + System.getProperty("file.separator"));
     }
 
 }
--- a/jdk/test/java/io/pathNames/General.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/io/pathNames/General.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,7 @@
     private static int gensymCounter = 0;
 
     protected static final String userDir = System.getProperty("user.dir");
+    protected static final String workSubDir = "tmp";
 
     protected static String baseDir = null;
     protected static String relative = null;
@@ -60,7 +61,10 @@
      *                  direct or indirect calling) in a whole test.
      */
     protected static void initTestData(int depth) throws IOException {
-        File parent = new File(userDir);
+        File parent = new File(userDir + File.separator + workSubDir);
+        if (!parent.mkdir()) {
+            throw new IOException("Fail to create directory: " + parent);
+        }
         for (int i = 0; i < depth; i++) {
             File tmp = new File(parent, gensym());
             tmp.createNewFile();
--- a/jdk/test/java/io/pathNames/GeneralWin32.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/io/pathNames/GeneralWin32.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,8 @@
     private static void checkCaseLookup() throws IOException {
         /* Use long names here to avoid 8.3 format, which Samba servers often
            force to lowercase */
-        File d = new File("XyZzY0123", "FOO_bar_BAZ");
+        File r = new File (workSubDir, "XyZzY0123");
+        File d = new File(r, "FOO_bar_BAZ");
         File f = new File(d, "GLORPified");
         if (!f.exists()) {
             if (!d.exists()) {
@@ -74,9 +75,9 @@
            case of filenames, rather than just using the input case */
         File y = new File(userDir, f.getPath());
         String ans = y.getPath();
-        check(ans, "XyZzY0123\\FOO_bar_BAZ\\GLORPified");
-        check(ans, "xyzzy0123\\foo_bar_baz\\glorpified");
-        check(ans, "XYZZY0123\\FOO_BAR_BAZ\\GLORPIFIED");
+        check(ans, workSubDir + File.separator + "XyZzY0123\\FOO_bar_BAZ\\GLORPified");
+        check(ans, workSubDir + File.separator + "xyzzy0123\\foo_bar_baz\\glorpified");
+        check(ans, workSubDir + File.separator + "XYZZY0123\\FOO_BAR_BAZ\\GLORPIFIED");
     }
 
     private static void checkWild(File f) throws Exception {
@@ -125,20 +126,19 @@
         throw new RuntimeException("Can't find an active drive");
     }
 
-    private static void checkDrive(int depth, char drive, boolean exists)
+    private static void checkDrive(int depth, String drive, boolean exists)
         throws Exception
     {
-        String d = drive + ":";
-        File df = new File(d);
-        String ans = exists ? df.getAbsolutePath() : d;
+        File df = new File(drive);
+        String ans = exists ? df.getAbsolutePath() : drive;
         if (!ans.endsWith("\\"))
             ans = ans + "\\";
-        checkNames(depth, false, ans, d);
+        checkNames(depth, false, ans, drive);
     }
 
     private static void checkDrivePaths(int depth) throws Exception {
-        checkDrive(depth, findActiveDrive(), true);
-        checkDrive(depth, findInactiveDrive(), false);
+        checkDrive(depth, findActiveDrive() + ":" + workSubDir + File.separator, true);
+        checkDrive(depth, findInactiveDrive() + ":", false);
     }
 
 
--- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,87 +23,173 @@
 
 /*
  *  @test
- *  @bug 6741606 7146431 8000450 8019830 8022945 8027144 8041633 8078427
- *  @summary Make sure all restricted packages listed in the package.access
+ *  @bug 6741606 7146431 8000450 8019830 8022945 8027144 8041633 8078427 8055206
+ *  @summary Check that various restricted packages that are supposed to be
+ *           restricted by default or are listed in the package.access
  *           property in the java.security file are blocked
+ *  @modules java.xml.ws java.corba
  *  @run main/othervm CheckPackageAccess
  */
 
-import java.util.Collections;
-import java.util.ArrayList;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Optional;
+
+public class CheckPackageAccess {
+
+    private static final SecurityManager sm = new SecurityManager();
+    private static final ModuleFinder mf = ModuleFinder.ofSystem();
+
+    /*
+     * The expected list of restricted packages of the package.access property.
+     *
+     * This array should be updated whenever new packages are added to the
+     * package.access property in the java.security file
+     * NOTE: it should be in the same order as the java.security file
+     */
+    private static final String[] EXPECTED = {
+        "sun.misc.",
+        "sun.reflect.",
+    };
+
+    /**
+     * Tests access to various packages of a module.
+     */
+    private static class Test {
+        String moduleName;     // name of module
+        ModuleReference moduleRef;     // module reference
+        String exports;    // exported pkg
+        Optional<String> opens;      // opened pkg
+        String conceals;   // concealed pkg
+        Optional<String> qualExports; // qualified export pkg
+        Optional<String> qualOpens;   // qualified open pkg
+        // qual open and non-qualified export pkg
+        Optional<String> qualOpensAndExports;
+        Test(String module, String exports, String opens, String conceals,
+             String qualExports, String qualOpens, String qualOpensAndExports) {
+            this.moduleName = module;
+            this.moduleRef = mf.find(moduleName).get();
+            this.exports = exports;
+            this.opens = Optional.ofNullable(opens);
+            this.conceals = conceals;
+            this.qualExports = Optional.ofNullable(qualExports);
+            this.qualOpens = Optional.ofNullable(qualOpens);
+            this.qualOpensAndExports = Optional.ofNullable(qualOpensAndExports);
+        }
+
+        void test() {
+            System.out.println("Testing module " + moduleName);
+
+            // access to exported pkg should pass
+            testNonRestricted(exports);
+
+            // access to opened pkg should pass
+            opens.ifPresent(Test::testNonRestricted);
+
+            // access to concealed pkg should fail
+            testRestricted(conceals);
 
-/*
- * The main benefit of this test is to catch merge errors or other types
- * of issues where one or more of the packages are accidentally
- * removed. This is why the packages that are known to be restricted have to
- * be explicitly listed below.
- */
-public class CheckPackageAccess {
+            // access to qualified export pkg should fail
+            qualExports.ifPresent(Test::testRestricted);
+
+            // access to qualified open pkg should fail
+            qualOpens.ifPresent(Test::testRestricted);
+
+            // access to qualified opened pkg that is also exported should pass
+            qualOpensAndExports.ifPresent(Test::testNonRestricted);
+        }
+
+        private static void testRestricted(String pkg) {
+            try {
+                sm.checkPackageAccess(pkg);
+                throw new RuntimeException("Able to access restricted package: "
+                                           + pkg);
+            } catch (SecurityException se) {}
+            try {
+                sm.checkPackageDefinition(pkg);
+                throw new RuntimeException("Able to access restricted package: "
+                                           + pkg);
+            } catch (SecurityException se) {}
+        }
+
+        private static void testNonRestricted(String pkg) {
+            try {
+                sm.checkPackageAccess(pkg);
+            } catch (SecurityException se) {
+                throw new RuntimeException("Unable to access exported package: "
+                                           + pkg, se);
+            }
+            try {
+                sm.checkPackageDefinition(pkg);
+            } catch (SecurityException se) {
+                throw new RuntimeException("Unable to access exported package: "
+                                           + pkg, se);
+            }
+        }
+    }
+
+    private static final Test[] tests = new Test[] {
+        // java.base module loaded by boot loader
+        new Test("java.base", "java.security", null, "jdk.internal.jrtfs",
+                 "jdk.internal.loader", null, null),
+        // java.desktop module loaded by boot loader and has an openQual pkg
+        // that is exported
+        new Test("java.desktop", "java.applet", null, "sun.applet",
+                 "sun.awt", null, "javax.swing.plaf.basic"),
+        // java.security.jgss module loaded by platform loader
+        new Test("java.security.jgss", "org.ietf.jgss", null,
+                 "sun.security.krb5.internal.crypto", "sun.security.krb5",
+                 null, null),
+        // java.xml.ws module loaded by platform loader but needs to be added
+        // and has an openQual pkg that is exported
+        new Test("java.xml.ws", "javax.xml.soap", null,
+                 "com.sun.xml.internal.stream.buffer",
+                 "com.sun.xml.internal.ws.api", null,
+                 "javax.xml.ws.wsaddressing"),
+        // java.xml.ws module loaded by platform loader but needs to be added
+        // and has an openQual pkg
+        new Test("java.corba", "javax.rmi", null, "sun.corba",
+                 "com.sun.corba.se.impl.util", "com.sun.jndi.cosnaming", null),
+    };
 
     public static void main(String[] args) throws Exception {
-        // get expected list of restricted packages
-        List<String> pkgs = RestrictedPackages.expected();
 
-        // get actual list of restricted packages
-        List<String> jspkgs = RestrictedPackages.actual();
+        // check expected list of restricted packages in java.security file
+        checkPackages(Arrays.asList(EXPECTED));
 
-        if (!isOpenJDKOnly()) {
-            String lastPkg = pkgs.get(pkgs.size() - 1);
-
-            // Remove any closed packages from list before comparing
-            int index = jspkgs.indexOf(lastPkg);
-            if (index != -1 && index != jspkgs.size() - 1) {
-                jspkgs.subList(index + 1, jspkgs.size()).clear();
-            }
+        // check access to each module's packages
+        for (Test test : tests) {
+            test.test();
         }
 
-        // Sort to ensure lists are comparable
-        Collections.sort(pkgs);
-        Collections.sort(jspkgs);
+        System.out.println("Test passed");
+    }
 
-        if (!pkgs.equals(jspkgs)) {
-            for (String p : pkgs)
-                if (!jspkgs.contains(p))
-                    System.out.println("In golden set, but not in j.s file: " + p);
-            for (String p : jspkgs)
-                if (!pkgs.contains(p))
-                    System.out.println("In j.s file, but not in golden set: " + p);
-
-
-            throw new RuntimeException("restricted packages are not " +
-                                       "consistent with java.security file");
-        }
-        System.setSecurityManager(new SecurityManager());
-        SecurityManager sm = System.getSecurityManager();
+    private static void checkPackages(List<String> pkgs) {
         for (String pkg : pkgs) {
-            String subpkg = pkg + "foo";
             try {
                 sm.checkPackageAccess(pkg);
                 throw new RuntimeException("Able to access " + pkg +
                                            " package");
             } catch (SecurityException se) { }
             try {
-                sm.checkPackageAccess(subpkg);
-                throw new RuntimeException("Able to access " + subpkg +
-                                           " package");
-            } catch (SecurityException se) { }
-            try {
                 sm.checkPackageDefinition(pkg);
                 throw new RuntimeException("Able to define class in " + pkg +
                                            " package");
             } catch (SecurityException se) { }
+            String subpkg = pkg + "foo";
+            try {
+                sm.checkPackageAccess(subpkg);
+                throw new RuntimeException("Able to access " + subpkg +
+                                           " package");
+            } catch (SecurityException se) { }
             try {
                 sm.checkPackageDefinition(subpkg);
-                throw new RuntimeException("Able to define class in " + subpkg +
-                                           " package");
+                throw new RuntimeException("Able to define class in " +
+                                           subpkg + " package");
             } catch (SecurityException se) { }
         }
-        System.out.println("Test passed");
-    }
-
-    private static boolean isOpenJDKOnly() {
-        String prop = System.getProperty("java.runtime.name");
-        return prop != null && prop.startsWith("OpenJDK");
     }
 }
--- a/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,11 +28,13 @@
  * @run main/othervm CheckPackageMatching
  */
 
+import java.security.Security;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.StringTokenizer;
 
 /*
  * The purpose of this test is not to verify the content of the package
@@ -46,10 +48,23 @@
      * The restricted packages listed in the package.access property of the
      * java.security file.
      */
-    private static final String[] packages =
-        RestrictedPackages.actual().toArray(new String[0]);
+    private static final String[] packages = actual().toArray(new String[0]);
 
-    private static final boolean OPEN_JDK = isOpenJDKOnly();
+    /**
+     * Returns the list of restricted packages in the package.access property.
+     */
+    private static List<String> actual() {
+        String prop = Security.getProperty("package.access");
+        List<String> packages = new ArrayList<>();
+        if (prop != null && !prop.equals("")) {
+            StringTokenizer tok = new StringTokenizer(prop, ",");
+            while (tok.hasMoreElements()) {
+                String s = tok.nextToken().trim();
+                packages.add(s);
+            }
+        }
+        return packages;
+    }
 
     /**
      * PackageMatcher implements a state machine that matches package
@@ -326,13 +341,8 @@
         System.getSecurityManager().checkPackageAccess("com.sun.jmxa");
         System.getSecurityManager().checkPackageAccess("jmx");
         List<String> actual = Arrays.asList(packages);
-        for (String p : actual) {
-            if (!actual.contains(p)) {
-                System.err.println("Warning: '" + p + " not in package.access");
-            }
-        }
-        if (!actual.contains("sun.")) {
-            throw new Error("package.access does not contain 'sun.'");
+        if (!actual.contains("sun.misc.")) {
+            throw new Error("package.access does not contain 'sun.misc.'");
         }
     }
 
@@ -447,17 +457,15 @@
 
         // These should not match.
         for (String pkg : new String[] {"gloups.machin", "su",
-                                        "org.jcp.xml.dsig.interna",
+                                        "org.jcp.xml.dsig.inter",
                                         "com.sun.jm", "com.sun.jmxa"}) {
             testMatch(matcher, pkg, false, true);
         }
 
         // These should match.
         for (String pkg : Arrays.asList(
-                new String[] {"sun.gloups.machin", "sun", "sun.com",
-                              "com.sun.jmx", "com.sun.jmx.a",
-                              "org.jcp.xml.dsig.internal",
-                              "org.jcp.xml.dsig.internal.foo"})) {
+                new String[] {"sun.misc.gloups.machin", "sun.misc",
+                              "sun.reflect"})) {
             testMatch(matcher, pkg, true, true);
         }
 
@@ -486,12 +494,6 @@
         }
 
         for (String pkg : pkgs) {
-            if (!OPEN_JDK && pkg.equals("com.sun.media.sound.")) {
-                // don't test com.sun.media.sound since there is an entry
-                // for com.sun.media in non OpenJDK builds. Otherwise,
-                // the test for this package will fail unexpectedly.
-                continue;
-            }
             String candidate = pkg.substring(0, pkg.length() - 2);
             boolean expected = pkglist.contains(candidate + ".");
             testMatch(matcher, candidate, expected,
@@ -537,9 +539,4 @@
             }
         }
     }
-
-    private static boolean isOpenJDKOnly() {
-        String prop = System.getProperty("java.runtime.name");
-        return prop != null && prop.startsWith("OpenJDK");
-    }
 }
--- a/jdk/test/java/lang/SecurityManager/RestrictedPackages.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.security.Security;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * A collection of utility methods and constants for testing the package
- * access and package definition security checks.
- */
-final class RestrictedPackages {
-
-    /*
-     * The expected list of restricted packages.
-     *
-     * This array should be updated whenever new packages are added to the
-     * package.access property in the java.security file
-     * NOTE: it should be in the same order as the java.security file
-     */
-    static final String[] EXPECTED = {
-        "sun.",
-        "com.sun.xml.internal.",
-        "com.sun.imageio.",
-        "com.sun.istack.internal.",
-        "com.sun.jmx.",
-        "com.sun.media.sound.",
-        "com.sun.naming.internal.",
-        "com.sun.proxy.",
-        "com.sun.corba.se.",
-        "com.sun.org.apache.bcel.internal.",
-        "com.sun.org.apache.regexp.internal.",
-        "com.sun.org.apache.xerces.internal.",
-        "com.sun.org.apache.xpath.internal.",
-        "com.sun.org.apache.xalan.internal.extensions.",
-        "com.sun.org.apache.xalan.internal.lib.",
-        "com.sun.org.apache.xalan.internal.res.",
-        "com.sun.org.apache.xalan.internal.templates.",
-        "com.sun.org.apache.xalan.internal.utils.",
-        "com.sun.org.apache.xalan.internal.xslt.",
-        "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
-        "com.sun.org.apache.xalan.internal.xsltc.compiler.",
-        "com.sun.org.apache.xalan.internal.xsltc.trax.",
-        "com.sun.org.apache.xalan.internal.xsltc.util.",
-        "com.sun.org.apache.xml.internal.res.",
-        "com.sun.org.apache.xml.internal.security.",
-        "com.sun.org.apache.xml.internal.serializer.dom3.",
-        "com.sun.org.apache.xml.internal.serializer.utils.",
-        "com.sun.org.apache.xml.internal.utils.",
-        "com.sun.org.glassfish.",
-        "com.sun.tools.script.",
-        "com.oracle.xmlns.internal.",
-        "com.oracle.webservices.internal.",
-        "org.jcp.xml.dsig.internal.",
-        "jdk.internal.",
-        "jdk.nashorn.internal.",
-        "jdk.nashorn.tools.",
-        "jdk.tools.jimage.",
-        "com.sun.activation.registries.",
-        "com.sun.java.accessibility.util.internal."
-    };
-
-    /*
-     * A non-exhaustive list of restricted packages.
-     *
-     * Contrary to what is in the EXPECTED list, this list does not need
-     * to be exhaustive.
-     */
-    static final String[] EXPECTED_NONEXHAUSTIVE = {
-        "sun.",
-        "com.sun.xml.internal.",
-        "com.sun.imageio.",
-        "com.sun.istack.internal.",
-        "com.sun.jmx.",
-        "com.sun.proxy.",
-        "com.sun.org.apache.bcel.internal.",
-        "com.sun.org.apache.regexp.internal.",
-        "com.sun.org.apache.xerces.internal.",
-        "com.sun.org.apache.xpath.internal.",
-        "com.sun.org.apache.xalan.internal.extensions.",
-        "com.sun.org.apache.xalan.internal.lib.",
-        "com.sun.org.apache.xalan.internal.res.",
-        "com.sun.org.apache.xalan.internal.templates.",
-        "com.sun.org.apache.xalan.internal.utils.",
-        "com.sun.org.apache.xalan.internal.xslt.",
-        "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
-        "com.sun.org.apache.xalan.internal.xsltc.compiler.",
-        "com.sun.org.apache.xalan.internal.xsltc.trax.",
-        "com.sun.org.apache.xalan.internal.xsltc.util.",
-        "com.sun.org.apache.xml.internal.res.",
-        "com.sun.org.apache.xml.internal.serializer.utils.",
-        "com.sun.org.apache.xml.internal.utils.",
-        "com.sun.org.apache.xml.internal.security.",
-        "com.sun.org.glassfish.",
-        "org.jcp.xml.dsig.internal."
-    };
-
-    private static final String OS_NAME = System.getProperty("os.name");
-
-    /**
-     * Returns a list of expected restricted packages, including any
-     * OS specific packages. The returned list is mutable.
-     */
-    static List<String> expected() {
-        List<String> pkgs = new ArrayList<>(Arrays.asList(EXPECTED));
-        if (OS_NAME.contains("OS X")) {
-            pkgs.add("apple.");  // add apple package for OS X
-        }
-        if (OS_NAME.contains("Win")) {
-            pkgs.add("com.sun.java.accessibility.internal.");  // add Win only package
-        }
-        return pkgs;
-    }
-
-    /**
-     * Returns a list of actual restricted packages. The returned list
-     * is mutable.
-     */
-    static List<String> actual() {
-        String prop = Security.getProperty("package.access");
-        List<String> packages = new ArrayList<>();
-        if (prop != null && !prop.equals("")) {
-            StringTokenizer tok = new StringTokenizer(prop, ",");
-            while (tok.hasMoreElements()) {
-                String s = tok.nextToken().trim();
-                packages.add(s);
-            }
-        }
-        return packages;
-    }
-
-    private RestrictedPackages() { }
-}
--- a/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,6 +63,7 @@
         scratch.add("        int foo();");
         scratch.add("    }");
         scratch.add("    public static void main(String[] args) {");
+        scratch.add("        System.setSecurityManager(new SecurityManager());");
         scratch.add("        I lam = () -> 10;");
         scratch.add("        Runnable r = () -> {");
         scratch.add("            System.out.println(\"Runnable\");");
@@ -114,7 +115,6 @@
     public void testNotLogging() {
         TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
                                "-cp", ".",
-                               "-Djava.security.manager",
                                "com.example.TestLambda");
         tr.assertZero("Should still return 0");
     }
@@ -125,7 +125,6 @@
         TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
                                "-cp", ".",
                                "-Djdk.internal.lambda.dumpProxyClasses=dump",
-                               "-Djava.security.manager",
                                "com.example.TestLambda");
         // 2 our own class files. We don't care about the others
         assertEquals(Files.find(
@@ -143,7 +142,6 @@
         TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
                                "-cp", ".",
                                "-Djdk.internal.lambda.dumpProxyClasses=notExist",
-                               "-Djava.security.manager",
                                "com.example.TestLambda");
         assertEquals(tr.testOutput.stream()
                                   .filter(s -> s.startsWith("WARNING"))
@@ -159,7 +157,6 @@
         TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
                                "-cp", ".",
                                "-Djdk.internal.lambda.dumpProxyClasses=file",
-                               "-Djava.security.manager",
                                "com.example.TestLambda");
         assertEquals(tr.testOutput.stream()
                                   .filter(s -> s.startsWith("WARNING"))
@@ -218,7 +215,6 @@
             TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
                                    "-cp", ".",
                                    "-Djdk.internal.lambda.dumpProxyClasses=readOnly",
-                                   "-Djava.security.manager",
                                    "com.example.TestLambda");
             assertEquals(tr.testOutput.stream()
                                       .filter(s -> s.startsWith("WARNING"))
@@ -237,7 +233,6 @@
         TestResult tr = doExec(JAVA_CMD.getAbsolutePath(),
                                "-cp", ".",
                                "-Djdk.internal.lambda.dumpProxyClasses=dumpLong",
-                               "-Djava.security.manager",
                                longFQCN);
         assertEquals(tr.testOutput.stream()
                                   .filter(s -> s.startsWith("WARNING: Exception"))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLConnection/SetDefaultUseCaches.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,67 @@
+/*
+ * 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 8163449
+ * @summary Allow per protocol setting for URLConnection defaultUseCaches
+ * @run main/othervm SetDefaultUseCaches
+ */
+
+import java.net.*;
+import java.io.*;
+
+public class SetDefaultUseCaches {
+    static void testAssert(boolean value, boolean comparator) {
+        if (value != comparator) {
+            System.err.println("Expected " + comparator + " Got " + value);
+            throw new RuntimeException("Test failed:");
+        } else
+            System.err.println("OK");
+    }
+
+    public static void main(String s[]) throws Exception {
+        URL url = new URL("http://www.foo.com/");
+        URL url1 = new URL("file:///a/b.txt");
+
+        // check default default is true
+        URLConnection urlc = url.openConnection();
+        testAssert(urlc.getDefaultUseCaches(), true);
+
+        // set default for http to false and check
+        URLConnection.setDefaultUseCaches("HTTP", false);
+
+        urlc = url.openConnection();
+        testAssert(urlc.getDefaultUseCaches(), true);
+        testAssert(urlc.getUseCaches(), false);
+        testAssert(URLConnection.getDefaultUseCaches("http"), false);
+
+        URLConnection urlc1 = url1.openConnection();
+        testAssert(urlc1.getDefaultUseCaches(), true);
+
+        // set default default to false and check other values the same
+        urlc.setDefaultUseCaches(false);
+        urlc1.setDefaultUseCaches("fiLe", true);
+        testAssert(urlc1.getDefaultUseCaches(), false);
+        testAssert(URLConnection.getDefaultUseCaches("fiLE"), true);
+    }
+}
--- a/jdk/test/java/nio/channels/Selector/SelectTimeout.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/nio/channels/Selector/SelectTimeout.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,46 +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.
-*/
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
 
 /*
  * @test
- * @bug 8165000
- * @summary Verify no IOException on OS X for large timeout value in select().
- * @requires (os.family == "mac")
+ * @bug 8165000 8172547
+ * @summary Verify no IOException on OS X for large timeout value in select()
+ * and that timeout does not occur too early on Windows.
+ * @requires (os.family == "mac" | os.family == "windows")
  */
 import java.io.IOException;
 import java.nio.channels.Selector;
 
 public class SelectTimeout {
-    private static final long HUGE_TIMEOUT = 100000001000L;
-    private static final long SLEEP_MILLIS = 10000;
+    private static final long BIG_TIMEOUT    = 100_000_001_000L; // 8165000
+    private static final long BIGGER_TIMEOUT = 850_000_000_000_000L; // 8172547
+    private static final long SLEEP_MILLIS   = 10000;
 
-    private static Exception theException;
+    private static volatile Exception theException;
+    private static volatile boolean isTimedOut;
 
     public static void main(String[] args)
         throws IOException, InterruptedException {
         int failures = 0;
         long[] timeouts =
-            new long[] {0, HUGE_TIMEOUT/2, HUGE_TIMEOUT - 1, HUGE_TIMEOUT};
+            new long[] {1, BIG_TIMEOUT/2, BIG_TIMEOUT - 1, BIG_TIMEOUT,
+                BIGGER_TIMEOUT};
         for (long t : timeouts) {
             if (!test(t)) {
                 failures++;
@@ -61,23 +65,35 @@
 
         Thread t = new Thread(() -> {
             try {
+                isTimedOut = false;
                 selector.select(timeout);
+                isTimedOut = true;
             } catch (IOException ioe) {
                 theException = ioe;
             }
         });
         t.start();
 
-        Thread.currentThread().sleep(SLEEP_MILLIS);
-        t.interrupt();
+        t.join(SLEEP_MILLIS);
 
+        boolean result;
         if (theException == null) {
-            System.out.printf("Test succeeded with timeout %d%n", timeout);
-            return true;
+            if (timeout > SLEEP_MILLIS && isTimedOut) {
+                System.err.printf("Test timed out early with timeout %d%n",
+                    timeout);
+                result = false;
+            } else {
+                System.out.printf("Test succeeded with timeout %d%n", timeout);
+                result = true;
+            }
         } else {
             System.err.printf("Test failed with timeout %d%n", timeout);
             theException.printStackTrace();
-            return false;
+            result = false;
         }
+
+        t.interrupt();
+
+        return result;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/MarshalledObject/MOFilterTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,140 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InvalidClassException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectInputFilter;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.util.Objects;
+
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+
+/* @test
+ * @run testng/othervm  MOFilterTest
+ *
+ * @summary Test MarshalledObject applies ObjectInputFilter
+ */
+@Test
+public class MOFilterTest {
+
+    /**
+     * Two cases are tested.
+     * The filter = null and a filter set to verify the calls to the filter.
+     * @return array objects with test parameters for each test case
+     */
+    @DataProvider(name = "FilterCases")
+    public static Object[][] filterCases() {
+        return new Object[][] {
+                {true},     // run the test with the filter
+                {false},    // run the test without the filter
+
+        };
+    }
+
+    /**
+     * Test that MarshalledObject inherits the ObjectInputFilter from
+     * the stream it was deserialized from.
+     */
+    @Test(dataProvider="FilterCases")
+    static void delegatesToMO(boolean withFilter) {
+        try {
+            Serializable testobj = Integer.valueOf(5);
+            MarshalledObject<Serializable> mo = new MarshalledObject<>(testobj);
+            Assert.assertEquals(mo.get(), testobj, "MarshalledObject.get returned a non-equals test object");
+
+            byte[] bytes = writeObjects(mo);
+
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                 ObjectInputStream ois = new ObjectInputStream(bais)) {
+
+                CountingFilter filter1 = new CountingFilter();
+                ois.setObjectInputFilter(withFilter ? filter1 : null);
+                MarshalledObject<?> actualMO = (MarshalledObject<?>)ois.readObject();
+                int count = filter1.getCount();
+
+                actualMO.get();
+                int expectedCount = withFilter ? count + 2 : count;
+                int actualCount = filter1.getCount();
+                Assert.assertEquals(actualCount, expectedCount, "filter called wrong number of times during get()");
+            }
+        } catch (IOException ioe) {
+            Assert.fail("Unexpected IOException", ioe);
+        } catch (ClassNotFoundException cnf) {
+            Assert.fail("Deserializing", cnf);
+        }
+    }
+
+    /**
+     * Write objects and return a byte array with the bytes.
+     *
+     * @param objects zero or more objects to serialize
+     * @return the byte array of the serialized objects
+     * @throws IOException if an exception occurs
+     */
+    static byte[] writeObjects(Object... objects)  throws IOException {
+        byte[] bytes;
+        try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+             ObjectOutputStream oos = new ObjectOutputStream(baos)) {
+            for (Object o : objects) {
+                oos.writeObject(o);
+            }
+            bytes = baos.toByteArray();
+        }
+        return bytes;
+    }
+
+
+    static class CountingFilter implements ObjectInputFilter {
+
+        private int count;      // count of calls to the filter
+
+        CountingFilter() {
+            count = 0;
+        }
+
+        int getCount() {
+            return count;
+        }
+
+        /**
+         * Filter that rejects class Integer and allows others
+         *
+         * @param filterInfo access to the class, arrayLength, etc.
+         * @return {@code STATUS.REJECTED}
+         */
+        public ObjectInputFilter.Status checkInput(FilterInfo filterInfo) {
+            count++;
+            return ObjectInputFilter.Status.ALLOWED;
+        }
+    }
+
+}
--- a/jdk/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
  *          java.rmi/sun.rmi.server
  *          java.rmi/sun.rmi.transport
  *          java.rmi/sun.rmi.transport.tcp
- * @build TestLibrary Dummy
+ * @build TestLibrary Dummy RegistryVM RMIRegistryRunner
  * @run main/othervm/policy=security.policy
  *     -Djava.rmi.server.useCodebaseOnly=false ClassPathCodebase
  */
@@ -48,8 +48,9 @@
 
 public class ClassPathCodebase {
 
-    /** wait 10 seconds for the registry process to be ready to call */
-    private final static long REGISTRY_WAIT = 15000;
+    /** wait dozens of seconds for the registry process to be ready to call */
+    private static final long REGISTRY_WAIT =
+            (long)(10000 * TestLibrary.getTimeoutFactor());
 
     private final static String dummyClassName = "Dummy";
 
@@ -64,7 +65,7 @@
 
         TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
 
-        Process rmiregistry = null;
+        RegistryVM rmiregistry = null;
 
         try {
             /*
@@ -82,27 +83,13 @@
              * Spawn an rmiregistry in the "import" codebase directory.
              */
             File rmiregistryDir =
-                new File(System.getProperty("user.dir", "."), importCodebase);
-
-            String rmiregistryCommand =
-                System.getProperty("java.home") + File.separator +
-                "bin" + File.separator + "rmiregistry";
-
-            int port = TestLibrary.getUnusedRandomPort();
-            String cmdarray[] = new String[] {
-                rmiregistryCommand,
-                "-J-Denv.class.path=.",
-                "-J-Djava.rmi.server.codebase=" + exportCodebaseURL,
-                Integer.toString(port) };
-
-            System.err.println("\nCommand used to spawn rmiregistry process:");
-            System.err.println("\t" + Arrays.asList(cmdarray).toString());
-
-            rmiregistry = Runtime.getRuntime().exec(cmdarray, null, rmiregistryDir);
-
-            // pipe rmiregistry output to our output, for debugging failures
-            StreamPipe.plugTogether(rmiregistry.getInputStream(), System.err);
-            StreamPipe.plugTogether(rmiregistry.getErrorStream(), System.err);
+                  new File(System.getProperty("user.dir", "."), importCodebase);
+            rmiregistry = RegistryVM.createRegistryVMWithRunner("RMIRegistryRunner",
+                            " -Denv.class.path=."
+                            + " -Djava.rmi.server.codebase=" + exportCodebaseURL
+                            + " -Duser.dir=" + rmiregistryDir.getAbsolutePath());
+            rmiregistry.start();
+            int port = rmiregistry.getPort();
 
             /*
              * Wait for the registry to initialize and be ready to call.
@@ -174,7 +161,7 @@
             throw new RuntimeException("TEST FAILED: " + e.toString());
         } finally {
             if (rmiregistry != null) {
-                rmiregistry.destroy();
+                rmiregistry.cleanup();
             }
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/registry/classPathCodebase/registry.security.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,18 @@
+/*
+ * security policy used by the registry process started by RegistryVM.
+ */
+
+grant {
+  permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry";
+  permission java.util.PropertyPermission "env.class.path", "read";
+  permission java.io.FilePermission ".", "read";
+  permission java.util.PropertyPermission "user.dir", "read";
+  permission java.lang.RuntimePermission "createClassLoader";
+  permission java.lang.RuntimePermission "setContextClassLoader";
+  permission java.io.FilePermission ".-Djava.rmi.server.codebase=file", "read";
+  permission java.io.FilePermission ".${/}-", "read";
+  permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server";
+  permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport";
+  permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp";
+  permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
+};
--- a/jdk/test/java/rmi/registry/classPathCodebase/security.policy	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/rmi/registry/classPathCodebase/security.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -18,6 +18,12 @@
   // test needs to use java to exec an rmiregistry
   permission java.io.FilePermission "${java.home}${/}bin${/}-", "execute";
 
-  // test needs to communicate with this its registry
+  // test needs to communicate with its registry
   permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
+
+  permission java.util.PropertyPermission "java.security.policy", "read";
+  permission java.util.PropertyPermission "java.security.manager", "read";
+
+  // used by TestLibrary to determine extra commandline properties
+  permission java.io.FilePermission "..${/}..${/}test.props", "read";
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/registry/readTest/CodebaseTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7102369 7094468 7100592
+ * @modules java.rmi/sun.rmi.registry
+ *          java.rmi/sun.rmi.server
+ *          java.rmi/sun.rmi.transport
+ *          java.rmi/sun.rmi.transport.tcp
+ * @library ../../testlibrary
+ * @build TestLibrary RMIRegistryRunner RegistryVM JavaVM testPkg.* RegistryLookup
+ * @summary remove java.rmi.server.codebase property parsing from registyimpl
+ * @run main/othervm CodebaseTest
+*/
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.rmi.registry.Registry;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+public class CodebaseTest {
+
+    public static void main(String args[]) throws Exception {
+        RegistryVM rmiregistry = null;
+        JavaVM client = null;
+        try {
+            File src = new File(System.getProperty("test.classes", "."), "testPkg");
+            File dest = new File(System.getProperty("user.dir", "."), "testPkg");
+            Files.move(src.toPath(), dest.toPath(),
+                    StandardCopyOption.REPLACE_EXISTING);
+
+            File rmiregistryDir =
+                new File(System.getProperty("user.dir", "."), "rmi_tmp");
+            rmiregistryDir.mkdirs();
+            rmiregistry = RegistryVM.createRegistryVMWithRunner(
+                    "RMIRegistryRunner",
+                    " -Djava.rmi.server.useCodebaseOnly=false"
+                    + " -Duser.dir=" + rmiregistryDir.getAbsolutePath());
+            rmiregistry.start();
+            int port = rmiregistry.getPort();
+
+            File srcReadTest = new File(System.getProperty("test.classes", "."),
+                                    "RegistryLookup.class");
+            File destReadTest = new File(System.getProperty("user.dir", "."),
+                                    "RegistryLookup.class");
+            Files.move(srcReadTest.toPath(), destReadTest.toPath(),
+                                    StandardCopyOption.REPLACE_EXISTING);
+
+            File codebase = new File(System.getProperty("user.dir", "."));
+            client = new JavaVM("RegistryLookup",
+                    " -Djava.rmi.server.codebase=" + codebase.toURI().toURL()
+                    + " -cp ." + File.pathSeparator + System.getProperty("test.class.path"),
+                    Integer.toString(port));
+            int exit = client.execute();
+            if (exit == RegistryLookup.EXIT_FAIL) {
+                throw new RuntimeException("Test Fails");
+            }
+        } finally {
+            if (rmiregistry != null) {
+                rmiregistry.cleanup();
+            }
+            if (client != null) {
+                client.cleanup();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/registry/readTest/RegistryLookup.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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.rmi.registry.Registry;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+public class RegistryLookup {
+    public static final int EXIT_FAIL = 1;
+
+    public static void main(String args[]) throws Exception {
+        Registry registry = null;
+        int exit = 0;
+        try {
+            int port = Integer.valueOf(args[0]);
+
+            testPkg.Server obj = new testPkg.Server();
+            testPkg.Hello stub =
+                    (testPkg.Hello) UnicastRemoteObject.exportObject(obj, 0);
+            // Bind the remote object's stub in the registry
+            registry = LocateRegistry.getRegistry(port);
+            registry.bind("Hello", stub);
+            System.err.println("Server ready");
+
+            testPkg.Client client = new testPkg.Client(port);
+            String testStubReturn = client.testStub();
+            if(!testStubReturn.equals(obj.hello)) {
+                throw new RuntimeException("Test Fails : "
+                        + "unexpected string from stub call");
+            }
+            registry.unbind("Hello");
+            System.out.println("Test passed");
+        } catch (Exception ex) {
+            exit = EXIT_FAIL;
+            ex.printStackTrace();
+        }
+        // need to exit explicitly, and parent process uses exit value
+        // to tell if the test passed.
+        System.exit(exit);
+    }
+}
--- a/jdk/test/java/rmi/registry/readTest/readTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.rmi.registry.Registry;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.RemoteException;
-import java.rmi.server.UnicastRemoteObject;
-
-public class readTest {
-
-    public static void main(String args[]) throws Exception {
-        try {
-            testPkg.Server obj = new testPkg.Server();
-            testPkg.Hello stub = (testPkg.Hello) UnicastRemoteObject.exportObject(obj, 0);
-            // Bind the remote object's stub in the registry
-            Registry registry =
-                LocateRegistry.getRegistry(TestLibrary.READTEST_REGISTRY_PORT);
-            registry.bind("Hello", stub);
-
-            System.err.println("Server ready");
-
-            // now, let's test client
-            testPkg.Client client =
-                new testPkg.Client(TestLibrary.READTEST_REGISTRY_PORT);
-            String testStubReturn = client.testStub();
-            if(!testStubReturn.equals(obj.hello)) {
-                throw new RuntimeException("Test Fails : unexpected string from stub call");
-            } else {
-                System.out.println("Test passed");
-            }
-            registry.unbind("Hello");
-
-        } catch (Exception e) {
-            System.err.println("Server exception: " + e.toString());
-            e.printStackTrace();
-        }
-
-    }
-}
--- a/jdk/test/java/rmi/registry/readTest/readTest.sh	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-#
-# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 7102369 7094468 7100592
-# @modules java.rmi/sun.rmi.registry
-#          java.rmi/sun.rmi.server
-#          java.rmi/sun.rmi.transport
-#          java.rmi/sun.rmi.transport.tcp
-# @library ../../testlibrary
-# @build TestLibrary
-# @summary remove java.rmi.server.codebase property parsing from registyimpl
-# @run shell readTest.sh
-# @key intermittent
-
-OS=`uname -s`
-VER=`uname -r`
-ARGS=""
-REGARGS=""
-
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    PS=":"
-    FS="/"
-    CHMOD="${FS}bin${FS}chmod"
-    FILEURL="file:"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    CHMOD="chmod"
-    FILEURL="file:/"
-    if [ "$VER" -eq "5" ]; then
-        ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000"
-        REGARGS="-J-Djdk.net.ephemeralPortRange.low=1024 -J-Djdk.net.ephemeralPortRange.high=65000"
-    fi
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    CHMOD="chmod"
-    FILEURL="file:/"
-    if [ "$VER" -eq "5" ]; then
-        ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000"
-        REGARGS="-J-Djdk.net.ephemeralPortRange.low=1024 -J-Djdk.net.ephemeralPortRange.high=65000"
-    fi
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TEST_CLASSPATH=.$PS${TESTCLASSPATH:-$TESTCLASSES}
-cp -r ${TESTSRC}${FS}* .
-${CHMOD} -R u+w *
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} testPkg${FS}*java
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -cp $TEST_CLASSPATH readTest.java
-
-mkdir rmi_tmp
-RMIREG_OUT=rmi.out
-#start rmiregistry without any local classes on classpath
-cd rmi_tmp
-# NOTE: This RMI Registry port must match TestLibrary.READTEST_REGISTRY_PORT
-${TESTJAVA}${FS}bin${FS}rmiregistry ${REGARGS} -J-Djava.rmi.server.useCodebaseOnly=false \
-    ${TESTTOOLVMOPTS} 60005 > ..${FS}${RMIREG_OUT} 2>&1 &
-RMIREG_PID=$!
-# allow some time to start
-sleep 3
-cd ..
-
-case "$OS" in
-  CYGWIN* )
-    CODEBASE=`cygpath -w $PWD`
-    ;;
-  * )
-    CODEBASE=`pwd`
-    ;;
-esac
-# trailing / after code base is important for rmi codebase property.
-TESTVMOPTS="${TESTVMOPTS} \
- --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED \
- --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED \
- --add-exports java.rmi/sun.rmi.transport=ALL-UNNAMED \
- --add-exports java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp $TEST_CLASSPATH ${ARGS} -Djava.rmi.server.codebase=${FILEURL}$CODEBASE/ readTest > OUT.TXT 2>&1 &
-TEST_PID=$!
-#bulk of testcase - let it run for a while
-sleep 5
-
-#we're done, kill processes first
-kill -9 ${RMIREG_PID} ${TEST_PID}
-sleep 3
-
-echo "Test output : "
-
-cat OUT.TXT
-echo "=============="
-echo "rmiregistry output  : "
-cat ${RMIREG_OUT}
-echo "=============="
-
-grep "Server ready" OUT.TXT
-result1=$?
-grep "Test passed" OUT.TXT
-result2=$?
-
-if [ $result1 -eq 0  -a $result2 -eq 0 ]
-then
-    echo "Passed"
-    exitCode=0;
-else
-    echo "Failed"
-    exitCode=1
-fi
-rm -rf OUT.TXT ${RMIREG_OUT} rmi_tmp
-exit ${exitCode}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/registry/readTest/registry.security.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,12 @@
+grant {
+  permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry";
+  permission java.util.PropertyPermission "env.class.path", "read";
+  permission java.io.FilePermission ".", "read";
+  permission java.util.PropertyPermission "user.dir", "read";
+  permission java.lang.RuntimePermission "createClassLoader";
+  permission java.lang.RuntimePermission "setContextClassLoader";
+  permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server";
+  permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport";
+  permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp";
+  permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/registry/serialFilter/RegistryFilterTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,186 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.rmi.MarshalledObject;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.AlreadyBoundException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Objects;
+import java.security.Security;
+
+import org.testng.Assert;
+import org.testng.TestNG;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @test
+ * @library /java/rmi/testlibrary
+ * @modules java.rmi/sun.rmi.registry
+ *          java.rmi/sun.rmi.server
+ *          java.rmi/sun.rmi.transport
+ *          java.rmi/sun.rmi.transport.tcp
+ * @build TestLibrary
+ * @summary Test filters for the RMI Registry
+ * @run testng/othervm RegistryFilterTest
+ * @run testng/othervm
+ *        -Dsun.rmi.registry.registryFilter=!java.lang.Long;!RegistryFilterTest$RejectableClass
+ *        RegistryFilterTest
+ * @run testng/othervm/policy=security.policy
+ *        -Djava.security.properties=${test.src}/java.security-extra1
+ *        RegistryFilterTest
+ */
+public class RegistryFilterTest {
+    private static Registry impl;
+    private static int port;
+    private static Registry registry;
+
+    static final int REGISTRY_MAX_ARRAY = 10000;
+
+    static final String registryFilter =
+            System.getProperty("sun.rmi.registry.registryFilter",
+                    Security.getProperty("sun.rmi.registry.registryFilter"));
+
+    @DataProvider(name = "bindAllowed")
+    static Object[][] bindAllowedObjects() {
+        Object[][] objects = {
+        };
+        return objects;
+    }
+
+    /**
+     * Data RMI Regiry bind test.
+     * - name
+     * - Object
+     * - true/false if object is blacklisted by a filter (implicit or explicit)
+     * @return array of test data
+     */
+    @DataProvider(name = "bindData")
+    static Object[][] bindObjects() {
+        Object[][] data = {
+                { "byte[max]", new XX(new byte[REGISTRY_MAX_ARRAY]), false },
+                { "String", new XX("now is the time"), false},
+                { "String[]", new XX(new String[3]), false},
+                { "Long[4]", new XX(new Long[4]), registryFilter != null },
+                { "rej-byte[toobig]", new XX(new byte[REGISTRY_MAX_ARRAY + 1]), true },
+                { "rej-MarshalledObject", createMarshalledObject(), true },
+                { "rej-RejectableClass", new RejectableClass(), registryFilter != null},
+        };
+        return data;
+    }
+
+    static XX createMarshalledObject() {
+        try {
+            return new XX(new MarshalledObject<>(null));
+        } catch (IOException ioe) {
+            return new XX(ioe);
+        }
+    }
+
+    @BeforeSuite
+    static void setupRegistry() {
+        try {
+            impl = TestLibrary.createRegistryOnEphemeralPort();
+            port = TestLibrary.getRegistryPort(impl);
+            registry = LocateRegistry.getRegistry("localhost", port);
+        } catch (RemoteException ex) {
+            Assert.fail("initialization of registry", ex);
+        }
+
+        System.out.printf("RMI Registry filter: %s%n", registryFilter);
+    }
+
+
+    /*
+     * Test registry rejects an object with the max array size  + 1.
+     */
+    @Test(dataProvider="bindData")
+    public void simpleBind(String name, Remote obj, boolean blacklisted) throws RemoteException, AlreadyBoundException, NotBoundException {
+        try {
+            registry.bind(name, obj);
+            Assert.assertFalse(blacklisted, "Registry filter did not reject (but should have) ");
+            registry.unbind(name);
+        } catch (Exception rex) {
+            Assert.assertTrue(blacklisted, "Registry filter should not have rejected");
+        }
+    }
+
+    /*
+    * Test registry rejects an object with a well known class
+    * if blacklisted in the security properties.
+    */
+    @Test
+    public void simpleRejectableClass() throws RemoteException, AlreadyBoundException, NotBoundException {
+        RejectableClass r1 = null;
+        try {
+            String name = "reject1";
+            r1 = new RejectableClass();
+            registry.bind(name, r1);
+            registry.unbind(name);
+            Assert.assertNull(registryFilter, "Registry filter should not have rejected");
+        } catch (Exception rex) {
+            Assert.assertNotNull(registryFilter, "Registry filter should have rejected");
+        }
+    }
+
+    /**
+     * A simple Serializable Remote object that is passed by value.
+     * It and its contents are checked by the Registry serial filter.
+     */
+    static class XX implements Serializable, Remote {
+        private static final long serialVersionUID = 362498820763181265L;
+
+        final Object obj;
+
+        XX(Object obj) {
+            this.obj = obj;
+        }
+
+        public String toString() {
+            return super.toString() + "//" + Objects.toString(obj);
+        }
+    }
+    /**
+     * A simple Serializable Remote object that is passed by value.
+     * It and its contents are checked by the Registry serial filter.
+     */
+    static class RejectableClass implements Serializable, Remote {
+        private static final long serialVersionUID = 362498820763181264L;
+
+        RejectableClass() {}
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/registry/serialFilter/java.security-extra1	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,9 @@
+# RMI Registry Input Serial Filter
+#
+# The filter pattern uses the same format as java.io.ObjectInputStream.serialFilter.
+# This filter can override the builtin filter if additional types need to be
+# allowed or rejected from the RMI Registry.
+#
+#sun.rmi.registry.registryFilter=pattern,pattern
+sun.rmi.registry.registryFilter=!java.lang.Long;!RegistryFilterTest$RejectableClass
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/registry/serialFilter/security.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,4 @@
+grant {
+        permission java.security.AllPermission;
+};
+
--- a/jdk/test/java/security/KeyRep/SerialOld.policy	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/security/KeyRep/SerialOld.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -1,4 +1,4 @@
-grant {
+grant codeBase "file:${test.classes}/*" {
 
     permission java.io.FilePermission "${test.src}${file.separator}*", "read";
     permission java.util.PropertyPermission "test.src", "read";
@@ -11,4 +11,6 @@
         "accessClassInPackage.sun.security.x509";
     permission java.lang.RuntimePermission
         "accessClassInPackage.sun.security.rsa";
+    permission java.lang.RuntimePermission
+        "accessClassInPackage.com.sun.crypto.provider";
 };
--- a/jdk/test/java/util/Collection/SetFactories.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/util/Collection/SetFactories.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -103,6 +103,8 @@
               hashSetOf("a", "b", "c", "d", "e", "f", "g", "h", "i")),
             a(   Set.of("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"),
               hashSetOf("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")),
+            a(   Set.of("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"),
+                 Set.of("j", "i", "h", "g", "f", "e", "d", "c", "b", "a")),
             a(   Set.of(stringArray),
               hashSetOf(stringArray))
         ).iterator();
@@ -183,6 +185,17 @@
         Set<String> set = Set.of(array);
     }
 
+    @Test(dataProvider="all")
+    public void hashCodeEqual(Set<String> act, Set<String> exp) {
+        assertEquals(act.hashCode(), exp.hashCode());
+    }
+
+    @Test(dataProvider="all")
+    public void containsAll(Set<String> act, Set<String> exp) {
+        assertTrue(act.containsAll(exp));
+        assertTrue(exp.containsAll(act));
+    }
+
     @Test(expectedExceptions=NullPointerException.class)
     public void nullDisallowed1() {
         Set.of((String)null); // force one-arg overload
--- a/jdk/test/java/util/Map/MapFactories.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/util/Map/MapFactories.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -103,6 +103,8 @@
             a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h"), genMap(8)),
             a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i"), genMap(9)),
             a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j"), genMap(10)),
+            a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j"),
+              Map.of(4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j", 0, "a", 1, "b", 2, "c", 3, "d")),
             a(Map.ofEntries(genEntries(MAX_ENTRIES)), genMap(MAX_ENTRIES))
         ).iterator();
     }
@@ -135,6 +137,18 @@
         assertEquals(act, exp);
     }
 
+    @Test(dataProvider="all")
+    public void containsAllKeys(Map<Integer,String> act, Map<Integer,String> exp) {
+        assertTrue(act.keySet().containsAll(exp.keySet()));
+        assertTrue(exp.keySet().containsAll(act.keySet()));
+    }
+
+    @Test(dataProvider="all")
+    public void containsAllValues(Map<Integer,String> act, Map<Integer,String> exp) {
+        assertTrue(act.values().containsAll(exp.values()));
+        assertTrue(exp.values().containsAll(act.values()));
+    }
+
     @Test(expectedExceptions=IllegalArgumentException.class)
     public void dupKeysDisallowed2() {
         Map<Integer, String> map = Map.of(0, "a", 0, "b");
@@ -192,6 +206,11 @@
         Map<Integer, String> map = Map.ofEntries(entries);
     }
 
+    @Test(dataProvider="all")
+    public void hashCodeEquals(Map<Integer,String> act, Map<Integer,String> exp) {
+        assertEquals(act.hashCode(), exp.hashCode());
+    }
+
     @Test(expectedExceptions=NullPointerException.class)
     public void nullKeyDisallowed1() {
         Map<Integer, String> map = Map.of(null, "a");
--- a/jdk/test/java/util/ResourceBundle/ResourceBundleTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/java/util/ResourceBundle/ResourceBundleTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
  */
 /*
     @test
-    @bug 4049325 4073127 4083270 4106034 4108126 8027930
+    @bug 4049325 4073127 4083270 4106034 4108126 8027930 8171139
     @summary test Resource Bundle
     @build TestResource TestResource_de TestResource_fr TestResource_fr_CH
     @build TestResource_it FakeTestResource
@@ -65,6 +65,7 @@
 import java.util.*;
 import java.util.ResourceBundle.Control;
 import java.io.*;
+import java.net.URL;
 
 public class ResourceBundleTest extends RBTestFmwk {
     public static void main(String[] args) throws Exception {
@@ -330,6 +331,44 @@
         }
     }
 
+    /*
+     * @bug 8171139
+     * @summary Make sure clearCache() clears cached ResourceBundle instances
+     */
+    public void TestClearCache() {
+        final String className = "TestResource";
+        Locale loc = Locale.getDefault();
+
+        // testing no-arg clearCache()
+        ResourceBundle rb1 = ResourceBundle.getBundle(className, loc);
+        ResourceBundle.clearCache();
+        ResourceBundle rb2 = ResourceBundle.getBundle(className, loc);
+        if (rb1 == rb2) {
+            errln("clearCache(no-arg) did not clear cache");
+        }
+
+        // clearCache() with a custom classloader
+        ClassLoader cl1 = new DummyClassLoader();
+        rb1 = ResourceBundle.getBundle(className, loc, cl1);
+        if (rb1 == rb2) {
+            errln("Same bundle was returned for different class loaders");
+        }
+        ResourceBundle.clearCache(cl1);
+        rb2= ResourceBundle.getBundle(className, loc, cl1);
+        if (rb1 == rb2) {
+            errln("clearCache(classLoader) did not clear cache");
+        }
+        ClassLoader cl2 = new DummyClassLoader();
+        rb1 = ResourceBundle.getBundle(className, loc, cl2);
+        if (rb1 == rb2) {
+            errln("Same bundle was returned for different class loaders");
+        }
+        ResourceBundle.clearCache(cl1);
+        rb2 = ResourceBundle.getBundle(className, loc, cl2);
+        if (rb1 != rb2) {
+            errln("clearCache(classLoader) incorrectly cleared cache");
+        }
+    }
 
     private void makePropertiesFile() {
         try {
@@ -393,4 +432,22 @@
             errln("Wrong number of elements in key list: expected " + expectedKeys.length +
                 " got " + elementCount);
     }
+
+    private static class DummyClassLoader extends ClassLoader {
+        public DummyClassLoader() {
+            super(DummyClassLoader.class.getClassLoader());
+        }
+
+        public Class<?> loadClass(String name) throws ClassNotFoundException {
+            return DummyClassLoader.class.getClassLoader().loadClass(name);
+        }
+
+        public URL getResource(String name) {
+            return DummyClassLoader.class.getClassLoader().getResource(name);
+        }
+
+        public InputStream getResourceAsStream(String name) {
+            return DummyClassLoader.class.getClassLoader().getResourceAsStream(name);
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/modules/LogManagerInModule/LogManagerInModuleTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.nio.file.Paths;
+import java.util.logging.Handler;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+/**
+ * @test
+ * @bug 8172886
+ * @summary Verifies that a custom LogManager or custom Handler can be
+ *          instantiated by the logging system if they are in a package
+ *          that is exported to java.logging by a module.
+ * @build test.logmanager/test.logmanager.TestLogManager
+ *        test.handlers/test.handlers.TestHandler
+ *        test.config/test.config.LogConfig
+ *        LogManagerInModuleTest
+ * @run main/othervm --add-modules test.logmanager,test.handlers
+ *          -Djava.util.logging.manager=test.logmanager.TestLogManager
+ *          LogManagerInModuleTest
+ * @run main/othervm --add-modules test.logmanager,test.handlers,test.config
+ *          -Djava.util.logging.manager=test.logmanager.TestLogManager
+ *          -Djava.util.logging.config.class=test.config.LogConfig
+ *          LogManagerInModuleTest
+ *
+ * @author danielfuchs
+ */
+public class LogManagerInModuleTest {
+
+    public static void main(String[] args) throws Exception {
+        if (System.getProperty("java.util.logging.config.class", null) == null) {
+            System.setProperty("java.util.logging.config.file",
+                Paths.get(System.getProperty("test.src", "src"),
+                          "logging.properties").toString());
+        }
+        // sanity check
+        if (LogManagerInModuleTest.class.getModule().isNamed()) {
+            throw new RuntimeException("Unexpected named module for "
+                  + LogManagerInModuleTest.class + ": "
+                  + LogManagerInModuleTest.class.getModule().getName());
+        }
+
+        // now check that the LogManager was correctly instantiated.
+        LogManager manager = LogManager.getLogManager();
+        System.out.println("LogManager: " + manager);
+        Class<?> logManagerClass = manager.getClass();
+        if (!"test.logmanager".equals(logManagerClass.getModule().getName())) {
+            throw new RuntimeException("Bad module for log manager: "
+                    + logManagerClass.getModule() + "; class is: "
+                    + logManagerClass.getName());
+        }
+
+        Logger logger = Logger.getLogger("com.xyz.foo");
+        Handler[] handlers = logger.getHandlers();
+        if (handlers.length != 1) {
+            throw new RuntimeException("Expected 1 handler, found " + handlers.length);
+        }
+        Class<?> handlerClass = handlers[0].getClass();
+        if (!"test.handlers".equals(handlerClass.getModule().getName())) {
+            throw new RuntimeException("Bad module for handler: "
+                    + handlerClass.getModule() + "; class is: "
+                    + handlerClass.getName());
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/modules/LogManagerInModule/logging.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,56 @@
+############################################################
+#  	Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler 
+# classes.  These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the INFO and above levels.
+handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers.  For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level= INFO
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = %h/java%u.log
+java.util.logging.FileHandler.limit = 50000
+java.util.logging.FileHandler.count = 1
+# Default number of locks FileHandler can obtain synchronously.
+# This specifies maximum number of attempts to obtain lock file by FileHandler
+# implemented by incrementing the unique field %u as per FileHandler API documentation.
+java.util.logging.FileHandler.maxLocks = 100
+java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to INFO and above.
+java.util.logging.ConsoleHandler.level = INFO
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+# Example to customize the SimpleFormatter output format 
+# to print one-line log message like this:
+#     <level>: <log message> [<date/time>]
+#
+# java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+
+# For example, set the com.xyz.foo logger to only log SEVERE
+# messages:
+com.xyz.foo.level = SEVERE
+com.xyz.foo.handlers = test.handlers.TestHandler
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.config/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module test.config {
+    requires java.logging;
+    requires test.handlers;
+    // makes it possible for java.logging to instantiate test.config.LogConfig;
+    // this doesn't need to be a qualified export, but making it so will prevent
+    // any other module from being able to instantiate the provided classes.
+    exports test.config to java.logging;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.config/test/config/LogConfig.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import test.handlers.TestHandler;
+
+/**
+ * A dummy class that configures the logging system.
+ * @author danielfuchs
+ */
+public class LogConfig {
+    private static final List<Logger> LOGGERS = new ArrayList<>();
+    public LogConfig() {
+        LogManager manager = LogManager.getLogManager();
+        Logger logger = Logger.getLogger("com.xyz.foo");
+        if (logger.getHandlers().length > 0) {
+            System.err.println(this.getClass().getName() + ": "
+                    + "Unexpected handlers: "
+                    + List.of(logger.getHandlers()));
+            throw new RuntimeException("Unexpected handlers: "
+                    + List.of(logger.getHandlers()));
+        }
+        logger.addHandler(new TestHandler());
+        LOGGERS.add(logger);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module test.handlers {
+    requires transitive java.logging;
+    // makes it possible for java.logging and test.config to instantiate
+    // test.handlers.TestHandler;
+    // this doesn't need to be a qualified export, but making it so will prevent
+    // any other module from being able to instantiate the provided classes.
+    exports test.handlers to java.logging, test.config;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/test/handlers/TestHandler.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test.handlers;
+
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+
+/**
+ * A dummy Handler that does nothing.
+ * @author danielfuchs
+ */
+public class TestHandler extends Handler {
+
+    @Override
+    public void publish(LogRecord record) {
+    }
+
+    @Override
+    public void flush() {
+    }
+
+    @Override
+    public void close() throws SecurityException {
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module test.logmanager {
+    requires java.logging;
+    // makes it possible for java.logging to instantiate
+    // test.logmanager.TestLogManager;
+    // this doesn't need to be a qualified export, but making it so will prevent
+    // any other module from being able to instantiate the provided classes.
+    exports test.logmanager to java.logging;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/test/logmanager/TestLogManager.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test.logmanager;
+
+import java.util.logging.LogManager;
+
+/**
+ * A dummy LogManager that simply extends the standard class.
+ * @author danielfuchs
+ */
+public class TestLogManager extends LogManager {
+
+}
--- a/jdk/test/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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
@@ -31,7 +31,7 @@
  * @bug 7188657
  * @summary There should be a way to reorder the JSSE ciphers
  * @run main/othervm UseCipherSuitesOrder
- *     TLS_RSA_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA
+ *     TLS_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA
  */
 
 import java.io.*;
--- a/jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,25 +21,12 @@
  * questions.
  */
 
-grant codeBase "jrt:/java.corba" {
-        permission java.security.AllPermission;
+grant {
+  permission java.util.PropertyPermission "*", "read";
+  permission java.io.FilePermission "<<ALL FILES>>", "read, execute";
 };
 
-
-
-grant {
-  permission java.io.FilePermission "./-", "read,write,execute";
-  permission java.io.FilePermission "*", "read";
+grant codeBase "file:${test.classes}/*" {
   permission java.net.SocketPermission "*:*", "connect, accept, listen, resolve";
-  permission java.util.PropertyPermission "*", "read, write";
-  permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
-  permission java.io.SerializablePermission "enableSubclassImplementation";
-  permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc";
-  permission java.lang.RuntimePermission "accessClassInPackage.sun.corba";
-  permission java.lang.RuntimePermission "defineClassInPackage.sun.corba";
-  permission java.lang.RuntimePermission "reflectionFactoryAccess";
-  permission sun.corba.BridgePermission "getBridge";
-  permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.reflect";
-  permission java.util.PropertyPermission "*", "read, write";
-  permission java.io.FilePermission "<<ALL FILES>>", "read,write,execute";
+  permission java.lang.RuntimePermission "accessClassInPackage.com.sun.jndi.cosnaming";
 };
--- a/jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,23 +21,12 @@
  * questions.
  */
 
-grant codeBase "jrt:/java.corba" {
-        permission java.security.AllPermission;
+grant {
+  permission java.util.PropertyPermission "*", "read";
+  permission java.io.FilePermission "<<ALL FILES>>", "read, execute";
 };
 
-grant {
-  permission java.io.FilePermission "./-", "read,write,execute";
-  permission java.io.FilePermission "*", "read";
+grant codeBase "file:${test.classes}/*" {
   permission java.net.SocketPermission "*:*", "connect, accept, listen, resolve";
-  permission java.util.PropertyPermission "*", "read, write";
-  permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
-  permission java.io.SerializablePermission "enableSubclassImplementation";
-  permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc";
-  permission java.lang.RuntimePermission "accessClassInPackage.sun.corba";
-  permission java.lang.RuntimePermission "defineClassInPackage.sun.corba";
-  permission java.lang.RuntimePermission "reflectionFactoryAccess";
-  permission sun.corba.BridgePermission "getBridge";
-  permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.reflect";
-  permission java.util.PropertyPermission "*", "read, write";
-  permission java.io.FilePermission "<<ALL FILES>>", "read,write,execute";
+  permission java.lang.RuntimePermission "accessClassInPackage.com.sun.jndi.cosnaming";
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTable/8133919/DrawGridLinesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,103 @@
+/*
+ * 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.Graphics2D;
+import java.awt.image.BufferedImage;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableModel;
+
+/*
+ * @test
+ * @bug 8133919
+ * @summary [macosx] JTable grid lines are incorrectly positioned on HiDPI display
+ * @run main DrawGridLinesTest
+ */
+public class DrawGridLinesTest {
+
+    private static final int WIDTH = 300;
+    private static final int HEIGHT = 150;
+    private static final Color GRID_COLOR = Color.BLACK;
+    private static final Color TABLE_BACKGROUND_COLOR = Color.BLUE;
+    private static final Color CELL_RENDERER_BACKGROUND_COLOR = Color.YELLOW;
+    private static final int SCALE = 2;
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(DrawGridLinesTest::checkTableGridLines);
+    }
+
+    private static void checkTableGridLines() {
+
+        TableModel dataModel = new AbstractTableModel() {
+            public int getColumnCount() {
+                return 10;
+            }
+
+            public int getRowCount() {
+                return 10;
+            }
+
+            public Object getValueAt(int row, int col) {
+                return " ";
+            }
+        };
+
+        DefaultTableCellRenderer r = new DefaultTableCellRenderer();
+        r.setOpaque(true);
+        r.setBackground(CELL_RENDERER_BACKGROUND_COLOR);
+
+        JTable table = new JTable(dataModel);
+        table.setSize(WIDTH, HEIGHT);
+        table.setDefaultRenderer(Object.class, r);
+        table.setGridColor(GRID_COLOR);
+        table.setShowGrid(true);
+        table.setShowHorizontalLines(true);
+        table.setShowVerticalLines(true);
+        table.setBackground(TABLE_BACKGROUND_COLOR);
+
+        checkTableGridLines(table);
+    }
+
+    private static void checkTableGridLines(JTable table) {
+
+        int w = SCALE * WIDTH;
+        int h = SCALE * HEIGHT;
+
+        BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = img.createGraphics();
+        g.scale(SCALE, SCALE);
+        table.paint(g);
+        g.dispose();
+
+        int size = Math.min(w, h);
+        int rgb = TABLE_BACKGROUND_COLOR.getRGB();
+
+        for (int i = 0; i < size; i++) {
+            if (img.getRGB(i, i) == rgb || img.getRGB(i, size - i - 1) == rgb) {
+                throw new RuntimeException("Artifacts in the table background color!");
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,218 @@
+/*
+ * 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 8170349
+ * @summary  Verify if printed content is within border and all columns are
+ *           printed for PrintMode.FIT_WIDTH
+ * @run main/manual PrintManualTest_FitWidthMultiple
+ */
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.text.MessageFormat;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableModel;
+
+public class PrintManualTest_FitWidthMultiple extends JTable implements Runnable {
+
+    static boolean testPassed;
+    static JFrame fr = null;
+    static JFrame instructFrame = null;
+    private final CountDownLatch latch;
+
+    public PrintManualTest_FitWidthMultiple(CountDownLatch latch){
+        this.latch = latch;
+    }
+
+    @Override
+    public void run() {
+        try {
+            createUIandTest();
+        } catch (Exception ex) {
+            dispose();
+            latch.countDown();
+            throw new RuntimeException(ex.getMessage());
+        }
+    }
+
+    private void createUIandTest() throws Exception {
+        /*Message Format Header and Footer */
+        final MessageFormat header=new MessageFormat("JTable Printing Header {0}");
+        final MessageFormat footer = new MessageFormat("JTable Printing Footer {0}");
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                /* Instructions Section */
+                String info =
+                    " \nThis test case brings up JTable with more Columns and Rows \n"+
+                    "Press the Print Button. It Prints in PRINT_MODE_FIT_WIDTH \n" +
+                    "It Pops up the Print Dialog. Check if Job/Print Attributes in the\n" +
+                    "Print Dialog are configurable. Default Print out will be in Landscape \n"+
+                    "The Print out should have JTable Centered on the Print out with thin borders \n"+
+                    "Prints out with Header and Footer. \n"+
+                    "The JTable should have all columns printed within border";
+
+                instructFrame=new JFrame("PrintManualTest_NormalSingle");
+                JPanel panel=new JPanel(new BorderLayout());
+                JButton button1 = new JButton("Pass");
+                JButton button2 = new JButton("Fail");
+                button1.addActionListener((e) -> {
+                    testPassed = true;
+                    dispose();
+                    latch.countDown();
+                });
+                button2.addActionListener((e) -> {
+                    testPassed = false;
+                    dispose();
+                    latch.countDown();
+                });
+                JPanel btnpanel1 = new JPanel();
+                btnpanel1.add(button1);
+                btnpanel1.add(button2);
+                panel.add(addInfo(info),BorderLayout.CENTER);
+                panel.add(btnpanel1, BorderLayout.SOUTH);
+                instructFrame.getContentPane().add(panel);
+                instructFrame.setBounds(600,100,350,350);
+
+                /* Print Button */
+                final JButton printButton=new JButton("Print");
+
+                /* Table Model */
+                final TableModel datamodel=new AbstractTableModel(){
+                    @Override
+                    public int getColumnCount() { return 50;}
+                    @Override
+                    public int getRowCount() { return 50; }
+                    @Override
+                    public Object getValueAt(int row, int column){ return new Integer(row*column);}
+                };
+
+                /* Constructing the JTable */
+                final JTable table=new JTable(datamodel);
+
+                /* Putting the JTable in ScrollPane and Frame Container */
+                JScrollPane scrollpane=new JScrollPane(table);
+                fr = new JFrame("PrintManualTest_FitWidthMultiple");
+                fr.getContentPane().add(scrollpane);
+
+                /* Light Weight Panel for holding Print and other buttons */
+                JPanel btnpanel=new JPanel();
+                btnpanel.add(printButton);
+                fr.getContentPane().add(btnpanel,BorderLayout.SOUTH);
+                fr.setBounds(0,0,400,400);
+                fr.setSize(500,500);
+
+                /* Binding the KeyStroke to Print Button Action */
+                fr.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl P"), "printButton");
+                fr.getRootPane().getActionMap().put("printButton", new AbstractAction(){
+                    @Override
+                    public void actionPerformed(ActionEvent e){
+                        printButton.doClick();
+                    }
+                });
+
+                /* Container and Component Listeners */
+                fr.addWindowListener(new WindowAdapter() {
+                    @Override
+                    public void windowClosing(WindowEvent e) {
+                        dispose();
+                        if (testPassed == false) {
+                            throw new RuntimeException(" User has not executed the test");
+                        }
+                    }
+                });
+
+                final PrintRequestAttributeSet prattr=new HashPrintRequestAttributeSet();
+                prattr.add(javax.print.attribute.standard.OrientationRequested.LANDSCAPE);
+
+                printButton.addActionListener(new ActionListener(){
+                    @Override
+                    public void actionPerformed(ActionEvent ae){
+                        try{
+                            table.print(JTable.PrintMode.FIT_WIDTH, header,footer,true,prattr,true);
+                        } catch(Exception e){}
+                    }
+                });
+                instructFrame.setVisible(true);
+                fr.setVisible(true);
+            }
+        });
+    }
+
+    public void dispose() {
+        instructFrame.dispose();
+        fr.dispose();
+    }
+
+    public JScrollPane addInfo(String info) {
+        JTextArea jta = new JTextArea(info,8,20);
+        jta.setEditable(false);
+        jta.setLineWrap(true);
+        JScrollPane sp = new JScrollPane(jta);
+        return sp;
+
+    }
+
+    /* Main Method */
+
+    public static void main(String[] argv) throws Exception {
+        final CountDownLatch latch = new CountDownLatch(1);
+        PrintManualTest_FitWidthMultiple test = new PrintManualTest_FitWidthMultiple(latch);
+        Thread T1 = new Thread(test);
+        T1.start();
+
+        // wait for latch to complete
+        boolean ret = false;
+        try {
+            ret = latch.await(60, TimeUnit.SECONDS);
+        } catch (InterruptedException ie) {
+            throw ie;
+        }
+        if (!ret) {
+            test.dispose();
+            throw new RuntimeException(" User has not executed the test");
+        }
+        if (test.testPassed == false) {
+            throw new RuntimeException("printed contents is beyond borders");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/* @test
+   @bug 4633594 8172012
+   @summary No way to pass focus from a JTree to a GUI placed inside the tree node
+   @run main JTreeFocusTest
+*/
+import java.awt.Component;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.KeyEvent;
+import java.util.EventObject;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.LineBorder;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellEditor;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
+
+public class JTreeFocusTest {
+
+    private static DefaultMutableTreeNode root;
+    Robot robot;
+    static boolean passed = false;
+    boolean rootSelected = false;
+    boolean keysTyped = false;
+    private volatile Point p = null;
+    private static JFrame fr;
+    private static volatile JTree tree = null;
+
+    public static void main(String[] args) throws Exception{
+         new JTreeFocusTest();
+    }
+
+    void blockTillDisplayed(JComponent comp) throws Exception {
+        while (p == null) {
+            try {
+                SwingUtilities.invokeAndWait(() -> {
+                    p = comp.getLocationOnScreen();
+                });
+            } catch (IllegalStateException e) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ie) {
+                }
+            }
+        }
+    }
+
+    public JTreeFocusTest() throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            fr = new JFrame("Test");
+
+            root = new DefaultMutableTreeNode("root");
+            JPanel p = new JPanel();
+            p.setBorder(new CompoundBorder(new BevelBorder(BevelBorder.RAISED),
+                    new LineBorder(UIManager.getColor("control"), 7)));
+            p.setLayout(new GridLayout(2,2));
+            p.add(new JLabel("one"));
+            JTextField tf1  = new JTextField(10);
+            p.add(tf1);
+            p.add(new JLabel("two"));
+            p.add(new JTextField(10));
+            root.add(new DefaultMutableTreeNode(p));
+
+            tf1.addFocusListener(new FocusAdapter() {
+                public void focusGained(FocusEvent e) {
+                    setPassed(true);
+                }
+            });
+
+            DefaultTreeModel model = new DefaultTreeModel(root);
+            tree = new JTree(model) {
+                public void processKeyEvent(KeyEvent e) {
+                    super.processKeyEvent(e);
+                    if (e.getKeyCode()==KeyEvent.VK_F2) {
+                        synchronized (JTreeFocusTest.this) {
+                            keysTyped = true;
+                            JTreeFocusTest.this.notifyAll();
+                        }
+                    }
+                }
+            };
+
+            tree.addTreeSelectionListener(new TreeSelectionListener() {
+                public void valueChanged(TreeSelectionEvent e) {
+                    if ( root.equals(e.getPath().getLastPathComponent()) ) {
+                        synchronized (JTreeFocusTest.this) {
+                            rootSelected = true;
+                            JTreeFocusTest.this.notifyAll();
+                        }
+                    }
+                }
+            });
+
+            tree.setEditable(true);
+            DefaultTreeCellRenderer renderer = new FormRenderer();
+            tree.setCellRenderer(renderer);
+            DefaultTreeCellEditor editor = new FormEditor(tree, renderer);
+            tree.setCellEditor(editor);
+            fr.getContentPane().add(tree);
+
+            fr.setSize(300,400);
+            fr.setVisible(true);
+        });
+        blockTillDisplayed(tree);
+        SwingUtilities.invokeAndWait(() -> {
+            tree.requestFocus();
+            tree.setSelectionRow(0);
+        });
+
+        try {
+            synchronized (this) {
+                while (!rootSelected) {
+                    JTreeFocusTest.this.wait();
+                }
+            }
+
+            robot = new Robot();
+            robot.setAutoDelay(50);
+            robot.delay(150);
+            robot.keyPress(KeyEvent.VK_DOWN);
+            robot.keyRelease(KeyEvent.VK_DOWN);
+            robot.keyPress(KeyEvent.VK_RIGHT);
+            robot.keyRelease(KeyEvent.VK_RIGHT);
+            robot.keyPress(KeyEvent.VK_F2);
+            robot.keyRelease(KeyEvent.VK_F2);
+
+            synchronized (this) {
+                while (!keysTyped) {
+                    JTreeFocusTest.this.wait();
+                }
+            }
+            Thread.sleep(3000);
+        } catch(Throwable t) {
+            t.printStackTrace();
+        }
+        destroy();
+    }
+
+    public void destroy() throws Exception {
+        SwingUtilities.invokeAndWait(()->fr.dispose());
+        if ( !isPassed() ) {
+            throw new RuntimeException("Focus wasn't transferred to the proper component");
+        }
+    }
+
+    synchronized void setPassed(boolean passed) {
+        this.passed = passed;
+    }
+
+    synchronized boolean isPassed() {
+        return passed;
+    }
+
+    static JTree createTree() {
+        return tree;
+    }
+
+    class FormRenderer extends DefaultTreeCellRenderer {
+        public Component getTreeCellRendererComponent(JTree tree, Object value,
+                                                      boolean sel,
+                                                      boolean expanded,
+                                                      boolean leaf, int row,
+                                                      boolean hasFocus) {
+            Object obj = ((DefaultMutableTreeNode)value).getUserObject();
+            if (obj instanceof Component){
+                return (Component)((DefaultMutableTreeNode)value).getUserObject();
+            }
+            return super.getTreeCellRendererComponent(tree, value, sel,
+                                                      expanded, leaf, row,
+                                                      hasFocus);
+        }
+    }
+
+    class FormEditor extends DefaultTreeCellEditor {
+        public FormEditor(JTree tree, DefaultTreeCellRenderer renderer) {
+            super(tree, renderer);
+        }
+
+        public Component getTreeCellEditorComponent(JTree tree, Object value,
+                                                      boolean sel,
+                                                      boolean expanded,
+                                                      boolean leaf, int row) {
+            Object obj = ((DefaultMutableTreeNode)value).getUserObject();
+            if (obj instanceof Component){
+                return (Component)((DefaultMutableTreeNode)value).getUserObject();
+            }
+            return super.getTreeCellEditorComponent(tree, value, sel,
+                                                    expanded, leaf, row);
+        }
+
+        public boolean shouldSelectCell(EventObject anEvent) {
+            //return super.shouldSelectCell(anEvent);
+            return true;
+        }
+    }
+}
--- a/jdk/test/javax/swing/text/View/8156217/FPMethodCalledTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/javax/swing/text/View/8156217/FPMethodCalledTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -42,7 +42,7 @@
 
 /**
  * @test
- * @bug 8156217
+ * @bug 8156217 8169922
  * @key headful
  * @summary Selected text is shifted on HiDPI display
  * @run main FPMethodCalledTest
--- a/jdk/test/jdk/nio/zipfs/PathOps.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/jdk/nio/zipfs/PathOps.java	Tue Jan 24 00:30:25 2017 +0100
@@ -31,7 +31,7 @@
 /**
  *
  * @test
- * @bug 8038500 8040059 8139956 8146754
+ * @bug 8038500 8040059 8139956 8146754 8172921
  * @summary Tests path operations for zip provider.
  *
  * @run main PathOps
@@ -180,6 +180,13 @@
         return this;
     }
 
+    PathOps resolvePath(String other, String expected) {
+        out.format("test resolve %s\n", other);
+        checkPath();
+        check(path.resolve(fs.getPath(other)), expected);
+        return this;
+    }
+
     PathOps resolveSibling(String other, String expected) {
         out.format("test resolveSibling %s\n", other);
         checkPath();
@@ -384,6 +391,30 @@
             .resolve("", "")
             .resolve("foo", "foo")
             .resolve("/foo", "/foo");
+        test("/")
+            .resolve("", "/")
+            .resolve("foo", "/foo")
+            .resolve("/foo", "/foo")
+            .resolve("/foo/", "/foo");
+
+        // resolve(Path)
+        test("/tmp")
+            .resolvePath("foo", "/tmp/foo")
+            .resolvePath("/foo", "/foo")
+            .resolvePath("", "/tmp");
+        test("tmp")
+            .resolvePath("foo", "tmp/foo")
+            .resolvePath("/foo", "/foo")
+            .resolvePath("", "tmp");
+        test("")
+            .resolvePath("", "")
+            .resolvePath("foo", "foo")
+            .resolvePath("/foo", "/foo");
+        test("/")
+            .resolvePath("", "/")
+            .resolvePath("foo", "/foo")
+            .resolvePath("/foo", "/foo")
+            .resolvePath("/foo/", "/foo");
 
         // resolveSibling
         test("foo")
--- a/jdk/test/lib/security/SecurityTools.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +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.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
-
-public class SecurityTools {
-
-    public static final String NO_ALIAS = null;
-
-    // keytool
-
-    public static OutputAnalyzer keytool(List<String> options)
-            throws Throwable {
-
-        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("keytool")
-                .addVMArg("-Duser.language=en")
-                .addVMArg("-Duser.country=US");
-        for (String option : options) {
-            if (option.startsWith("-J")) {
-                launcher.addVMArg(option.substring(2));
-            } else {
-                launcher.addToolArg(option);
-            }
-        }
-        return ProcessTools.executeCommand(launcher.getCommand());
-    }
-
-    public static OutputAnalyzer keytool(String options) throws Throwable {
-        return keytool(options.split("\\s+"));
-    }
-
-    public static OutputAnalyzer keytool(String... options) throws Throwable {
-        return keytool(List.of(options));
-    }
-
-    // jarsigner
-
-    public static OutputAnalyzer jarsigner(String jar, String alias,
-            List<String> options) throws Throwable {
-        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jarsigner")
-                .addVMArg("-Duser.language=en")
-                .addVMArg("-Duser.country=US");
-        for (String option : options) {
-            if (option.startsWith("-J")) {
-                launcher.addVMArg(option.substring(2));
-            } else {
-                launcher.addToolArg(option);
-            }
-        }
-        launcher.addToolArg(jar);
-        if (alias != null) {
-            launcher.addToolArg(alias);
-        }
-        return ProcessTools.executeCommand(launcher.getCommand());
-    }
-
-    public static OutputAnalyzer jarsigner(String jar, String alias,
-            String options) throws Throwable {
-
-        return jarsigner(jar, alias, options.split("\\s+"));
-    }
-
-    public static OutputAnalyzer jarsigner(String jar, String alias,
-            String... options) throws Throwable {
-
-        return jarsigner(jar, alias, List.of(options));
-    }
-
-    public static OutputAnalyzer sign(String jar, String alias, String... options)
-            throws Throwable {
-
-        return jarsigner(jar, alias,
-                mergeOptions("-J-Djava.security.egd=file:/dev/./urandom", options));
-    }
-
-    public static OutputAnalyzer verify(String jar, String... options)
-            throws Throwable {
-
-        return jarsigner(jar, NO_ALIAS, mergeOptions("-verify", options));
-    }
-
-    // helper methods
-
-    private static List<String> mergeOptions(
-            String firstOption, String... secondPart) {
-
-        return mergeOptions(List.of(firstOption), secondPart);
-    }
-
-    private static List<String> mergeOptions(
-            List<String> firstPart, String... secondPart) {
-
-        List<String> options = new ArrayList<>(firstPart);
-        Collections.addAll(options, secondPart);
-        return options;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/LoggingTest/LoggingTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.management.ManagementFactory;
+import java.util.List;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+public class LoggingTest {
+
+    static class TestStream extends PrintStream {
+        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        private volatile boolean recording;
+        public TestStream(PrintStream wrapped) {
+            super(wrapped);
+        }
+
+        void startRecording() {
+            recording = true;
+        }
+
+        void stopRecording() {
+            recording = false;
+        }
+
+        @Override
+        public void write(int b) {
+            if (recording) {
+                bos.write(b);
+            }
+            super.write(b);
+        }
+
+        @Override
+        public void write(byte[] buf, int off, int len) {
+            if (recording) {
+                bos.write(buf, off, len);
+            }
+            super.write(buf, off, len);
+        }
+
+        @Override
+        public void write(byte[] buf) throws IOException {
+            if (recording) {
+                bos.write(buf);
+            }
+            super.write(buf);
+        }
+
+    }
+
+    public void run(TestStream ts) {
+
+        // start recording traces and trigger creation of the platform
+        // MBeanServer to produce some. This won't work if the platform
+        // MBeanServer was already initialized - so it's important to
+        // run this test in its own JVM.
+        ts.startRecording();
+        MBeanServer platform = ManagementFactory.getPlatformMBeanServer();
+        ts.stopRecording();
+        String printed = ts.bos.toString();
+        ts.bos.reset();
+
+        // Check that the Platform MBeanServer is emitting the expected
+        // log traces. This can be a bit fragile because debug traces
+        // could be changed without notice - in which case this test will
+        // need to be updated.
+        // For each registered MBean we expect to see three traces.
+        // If the messages logged by the MBeanServer change then these checks
+        // may need to be revisited.
+        List<String> checkTraces =
+                List.of("ObjectName = %s", "name = %s", "JMX.mbean.registered %s");
+
+        for (ObjectName o : platform.queryNames(ObjectName.WILDCARD, null)) {
+            String n = o.toString();
+            System.out.println("Checking log for: " + n);
+            for (String check : checkTraces) {
+                String s = String.format(check, n);
+                if (!printed.contains(s)) {
+                    throw new RuntimeException("Trace not found: " + s);
+                }
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/LoggingTest/LoggingWithJULTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.nio.file.Paths;
+
+/**
+ * @test
+ * @bug 8172971
+ * @modules java.management java.logging
+ * @summary Smoke test to check that logging in java.management works as expected.
+ * @build LoggingTest LoggingWithJULTest
+ * @run main/othervm LoggingWithJULTest
+ * @author danielfuchs
+ */
+public class LoggingWithJULTest {
+
+    public static void main(String[] args) {
+        // Replace System.err
+        LoggingTest.TestStream ts = new LoggingTest.TestStream(System.err);
+        System.setErr(ts);
+
+        // activate the javax.management traces
+        String properties = Paths.get(System.getProperty("test.src", "src"),
+                                      "logging.properties").toString();
+        System.setProperty("java.util.logging.config.file", properties);
+
+        // run the test
+        new LoggingTest().run(ts);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/LoggingTest/LoggingWithLoggerFinderTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8172971
+ * @modules java.management
+ * @summary Smoke test to check that logging in java.management is performed
+ *          through System.Logger. This test installs a LoggerFinder service
+ *          provider and verifies that it gets the traces.
+ * @build test.loggerfinder/test.loggerfinder.TestLoggerFinder LoggingTest LoggingWithLoggerFinderTest
+ * @run main/othervm --add-modules test.loggerfinder LoggingWithLoggerFinderTest
+ * @author danielfuchs
+ */
+public class LoggingWithLoggerFinderTest {
+
+    public static void main(String[] args) {
+        // Replace System.err
+        LoggingTest.TestStream ts = new LoggingTest.TestStream(System.err);
+        System.setErr(ts);
+
+        // run the test
+        new LoggingTest().run(ts);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/LoggingTest/logging.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,55 @@
+############################################################
+#  	Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler 
+# classes.  These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the INFO and above levels.
+handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers.  For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level= INFO
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = %h/java%u.log
+java.util.logging.FileHandler.limit = 50000
+java.util.logging.FileHandler.count = 1
+# Default number of locks FileHandler can obtain synchronously.
+# This specifies maximum number of attempts to obtain lock file by FileHandler
+# implemented by incrementing the unique field %u as per FileHandler API documentation.
+java.util.logging.FileHandler.maxLocks = 100
+java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to INFO and above.
+java.util.logging.ConsoleHandler.level = ALL
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+# Example to customize the SimpleFormatter output format 
+# to print one-line log message like this:
+#     <level>: <log message> [<date/time>]
+#
+# java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+
+# For example, set the com.xyz.foo logger to only log SEVERE
+# messages:
+javax.management.level = ALL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/LoggingTest/test.loggerfinder/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module test.loggerfinder {
+    // Install a LoggerFinder that will direct traces directly to System.err,
+    // without involving java.util.logging
+    provides java.lang.System.LoggerFinder with test.loggerfinder.TestLoggerFinder;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/management/LoggingTest/test.loggerfinder/test/loggerfinder/TestLoggerFinder.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test.loggerfinder;
+
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
+import java.lang.System.LoggerFinder;
+import java.lang.reflect.Module;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Optional;
+import java.util.ResourceBundle;
+import java.util.function.Predicate;
+import java.lang.StackWalker.StackFrame;
+import java.text.MessageFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * A LoggerFinder that provides System.Logger which print directly
+ * on System.err, without involving java.logging.
+ * For the purpose of the test, loggers whose name start with java.management.
+ * will log all messages, and other loggers will only log level > INFO.
+ * @author danielfuchs
+ */
+public class TestLoggerFinder extends LoggerFinder {
+
+    static class TestLogger implements Logger {
+
+        final String name;
+
+        public TestLogger(String name) {
+            this.name = name;
+        }
+
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public boolean isLoggable(Level level) {
+            return name.equals("javax.management")
+                    || name.startsWith("javax.management.")
+                    || level.getSeverity() >= Level.INFO.getSeverity();
+        }
+
+        @Override
+        public void log(Level level, ResourceBundle bundle, String msg, Throwable thrown) {
+            if (!isLoggable(level)) return;
+            publish(level, bundle, msg, thrown);
+        }
+
+        @Override
+        public void log(Level level, ResourceBundle bundle, String format, Object... params) {
+            if (!isLoggable(level)) return;
+            publish(level, bundle, format, params);
+        }
+
+        static void publish(Level level, ResourceBundle bundle, String msg, Throwable thrown) {
+            StackFrame sf = new CallerFinder().get().get();
+
+            if (bundle != null && msg != null) {
+                msg = bundle.getString(msg);
+            }
+            if (msg == null) msg = "";
+            LocalDateTime ldt = LocalDateTime.now();
+            String date = DateTimeFormatter.ISO_DATE_TIME.format(ldt);
+            System.err.println(date + " "
+                    + sf.getClassName() + " " + sf.getMethodName() + "\n"
+                    + String.valueOf(level) + ": " + msg);
+            thrown.printStackTrace(System.err);
+        }
+
+        static void publish(Level level, ResourceBundle bundle, String format, Object... params) {
+            StackFrame sf = new CallerFinder().get().get();
+            if (bundle != null && format != null) {
+                format = bundle.getString(format);
+            }
+            String msg = format(format, params);
+            LocalDateTime ldt = LocalDateTime.now();
+            String date = DateTimeFormatter.ISO_DATE_TIME.format(ldt);
+            System.err.println(date + " "
+                    + sf.getClassName() + " " + sf.getMethodName() + "\n"
+                    + String.valueOf(level) + ": " + msg);
+        }
+
+        static String format(String format, Object... args) {
+            if (format == null) return "";
+            int index = 0, len = format.length();
+            while ((index = format.indexOf(index, '{')) >= 0) {
+                if (index >= len - 2) break;
+                char c = format.charAt(index+1);
+                if (c >= '0' && c <= '9') {
+                    return MessageFormat.format(format, args);
+                }
+                index++;
+            }
+            return format;
+        }
+
+    }
+
+     /*
+     * CallerFinder is a stateful predicate.
+     */
+    static final class CallerFinder implements Predicate<StackWalker.StackFrame> {
+        private static final StackWalker WALKER;
+        static {
+            PrivilegedAction<StackWalker> pa =
+                () -> StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
+            WALKER = AccessController.doPrivileged(pa);
+        }
+
+        /**
+         * Returns StackFrame of the caller's frame.
+         * @return StackFrame of the caller's frame.
+         */
+        Optional<StackWalker.StackFrame> get() {
+            return WALKER.walk((s) -> s.filter(this).findFirst());
+        }
+
+        private boolean lookingForLogger = true;
+        /**
+         * Returns true if we have found the caller's frame, false if the frame
+         * must be skipped.
+         *
+         * @param t The frame info.
+         * @return true if we have found the caller's frame, false if the frame
+         * must be skipped.
+         */
+        @Override
+        public boolean test(StackWalker.StackFrame s) {
+            // We should skip all frames until we have found the logger,
+            // because these frames could be frames introduced by e.g. custom
+            // sub classes of Handler.
+            Class<?> c = s.getDeclaringClass();
+            boolean isLogger = System.Logger.class.isAssignableFrom(c);
+            if (lookingForLogger) {
+                // Skip all frames until we have found the first logger frame.
+                lookingForLogger = c != TestLogger.class;
+                return false;
+            }
+            // Continue walking until we've found the relevant calling frame.
+            // Skips logging/logger infrastructure.
+            return !isLogger;
+        }
+    }
+
+    @Override
+    public Logger getLogger(String name, Module module) {
+        return new TestLogger(name);
+    }
+
+}
--- a/jdk/test/sun/net/www/protocol/http/SetIfModifiedSince.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/sun/net/www/protocol/http/SetIfModifiedSince.java	Tue Jan 24 00:30:25 2017 +0100
@@ -22,7 +22,7 @@
  */
 
 /* @test
-   @bug 4213164
+   @bug 4213164 8172253
    @summary setIfModifiedSince mehtod in HttpURLConnection sometimes fails
    */
 import java.util.*;
@@ -88,7 +88,7 @@
      //url = new URL(args[0]);
      url = new URL("http://localhost:" + String.valueOf(port) +
                    "/anything");
-     con = (HttpURLConnection)url.openConnection();
+     con = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
 
      con.setIfModifiedSince(date.getTime());
      con.connect();
--- a/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
 
 import java.security.*;
 import java.security.cert.*;
-import java.security.cert.Certificate;
 
 import javax.net.ssl.*;
 
@@ -61,6 +60,8 @@
 
     private static PeerFactory peerFactory;
 
+    static final CountDownLatch clientCondition = new CountDownLatch(1);
+
     static abstract class Server implements Runnable {
 
         final CipherTest cipherTest;
@@ -313,6 +314,10 @@
             }
             threads[i].start();
         }
+
+        // The client threads are ready.
+        clientCondition.countDown();
+
         try {
             for (int i = 0; i < THREADS; i++) {
                 threads[i].join();
@@ -367,6 +372,10 @@
                 try {
                     runTest(params);
                     System.out.println("Passed " + params);
+                } catch (SocketTimeoutException ste) {
+                    System.out.println("The client connects to the server timeout, "
+                            + "so ignore the test.");
+                    break;
                 } catch (Exception e) {
                     cipherTest.setFailed();
                     System.out.println("** Failed " + params + "**");
--- a/jdk/test/sun/security/pkcs11/sslecc/JSSEClient.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/sun/security/pkcs11/sslecc/JSSEClient.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,7 @@
 
 import java.io.*;
 import java.net.*;
-import java.util.*;
 
-import java.security.*;
-import java.security.cert.*;
 import java.security.cert.Certificate;
 
 import javax.net.ssl.*;
@@ -46,10 +43,30 @@
         SSLSocket socket = null;
         try {
             keyManager.setAuthType(params.clientAuth);
-            sslContext.init(new KeyManager[] {keyManager}, new TrustManager[] {cipherTest.trustManager}, cipherTest.secureRandom);
-            SSLSocketFactory factory = (SSLSocketFactory)sslContext.getSocketFactory();
-            socket = (SSLSocket)factory.createSocket("127.0.0.1", cipherTest.serverPort);
-            socket.setSoTimeout(cipherTest.TIMEOUT);
+            sslContext.init(
+                    new KeyManager[] { keyManager },
+                    new TrustManager[] { CipherTest.trustManager },
+                    CipherTest.secureRandom);
+            SSLSocketFactory factory
+                    = (SSLSocketFactory) sslContext.getSocketFactory();
+
+            socket = (SSLSocket) factory.createSocket();
+            try {
+                socket.connect(new InetSocketAddress("127.0.0.1",
+                        CipherTest.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;
+            }
+
+            socket.setSoTimeout(CipherTest.TIMEOUT);
             socket.setEnabledCipherSuites(new String[] {params.cipherSuite});
             socket.setEnabledProtocols(new String[] {params.protocol});
             InputStream in = socket.getInputStream();
--- a/jdk/test/sun/security/pkcs11/sslecc/JSSEServer.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/sun/security/pkcs11/sslecc/JSSEServer.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,11 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.SocketTimeoutException;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLServerSocket;
@@ -40,24 +43,37 @@
     JSSEServer(CipherTest cipherTest) throws Exception {
         super(cipherTest);
         SSLContext serverContext = SSLContext.getInstance("TLS");
-        serverContext.init(new KeyManager[] {cipherTest.keyManager}, new TrustManager[] {cipherTest.trustManager}, cipherTest.secureRandom);
+        serverContext.init(
+                new KeyManager[] { CipherTest.keyManager },
+                new TrustManager[] { CipherTest.trustManager },
+                CipherTest.secureRandom);
 
         SSLServerSocketFactory factory = (SSLServerSocketFactory)serverContext.getServerSocketFactory();
         serverSocket = (SSLServerSocket)factory.createServerSocket(0);
-        cipherTest.serverPort = serverSocket.getLocalPort();
+        serverSocket.setSoTimeout(CipherTest.TIMEOUT);
+        CipherTest.serverPort = serverSocket.getLocalPort();
         serverSocket.setEnabledCipherSuites(factory.getSupportedCipherSuites());
         serverSocket.setWantClientAuth(true);
     }
 
     @Override
     public void run() {
-        System.out.println("JSSE Server listening on port " + cipherTest.serverPort);
+        System.out.println("JSSE Server listening on port " + CipherTest.serverPort);
         Executor exec = Executors.newFixedThreadPool
                             (CipherTest.THREADS, DaemonThreadFactory.INSTANCE);
+
         try {
+            if (!CipherTest.clientCondition.await(CipherTest.TIMEOUT,
+                    TimeUnit.MILLISECONDS)) {
+                System.out.println(
+                        "The client is not the expected one or timeout. "
+                                + "Ignore in server side.");
+                return;
+            }
+
             while (true) {
                 final SSLSocket socket = (SSLSocket)serverSocket.accept();
-                socket.setSoTimeout(cipherTest.TIMEOUT);
+                socket.setSoTimeout(CipherTest.TIMEOUT);
                 Runnable r = new Runnable() {
                     @Override
                     public void run() {
@@ -86,11 +102,12 @@
                 };
                 exec.execute(r);
             }
-        } catch (IOException e) {
+        } catch (SocketTimeoutException ste) {
+            System.out.println("The server got timeout for waiting for the connection, "
+                    + "so ignore the test.");
+        } catch (Exception e) {
             cipherTest.setFailed();
             e.printStackTrace();
-            //
         }
     }
-
 }
--- a/jdk/test/sun/security/provider/PolicyFile/TokenStore.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/sun/security/provider/PolicyFile/TokenStore.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -250,10 +250,9 @@
         Enumeration perms = p.getPermissions(pd).elements();
         while (perms.hasMoreElements()) {
             Permission perm = (Permission)perms.nextElement();
-            if (!(perm instanceof AllPermission)) {
-                throw new SecurityException("expected AllPermission");
-            } else {
+            if (perm instanceof AllPermission) {
                 foundIt = true;
+                break;
             }
         }
         if (!foundIt) {
--- a/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh	Tue Jan 24 00:30:25 2017 +0100
@@ -22,7 +22,7 @@
 #
 
 # @test
-# @bug 6802846
+# @bug 6802846 8172529
 # @summary jarsigner needs enhanced cert validation(options)
 #
 # @run shell/timeout=240 concise_jarsigner.sh
@@ -52,7 +52,7 @@
 KS=js.ks
 KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa -keysize 1024"
 JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -debug"
 JAVAC="$TESTJAVA${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}"
 
 rm $KS
@@ -138,7 +138,7 @@
 [ $LINES = 4 ] || exit $LINENO
 
 # ==========================================================
-# Second part: exit code 2, 4, 8
+# Second part: exit code 2, 4, 8.
 # 16 and 32 already covered in the first part
 # ==========================================================
 
@@ -174,11 +174,14 @@
 $JARSIGNER -strict -keystore $KS -storepass changeit a.jar goodeku
 [ $? = 0 ] || exit $LINENO
 
-# badchain signed by ca, but ca is removed later
+# badchain signed by ca1, but ca1 is removed later
 $KT -genkeypair -alias badchain -dname CN=badchain -validity 365
-$KT -certreq -alias badchain | $KT -gencert -alias ca -validity 365 | \
+$KT -genkeypair -alias ca1 -dname CN=ca1 -ext bc -validity 365
+$KT -certreq -alias badchain | $KT -gencert -alias ca1 -validity 365 | \
         $KT -importcert -alias badchain
-$KT -delete -alias ca
+# save ca1.cert for easy replay
+$KT -exportcert -file ca1.cert -alias ca1
+$KT -delete -alias ca1
 
 $JARSIGNER -strict -keystore $KS -storepass changeit a.jar badchain
 [ $? = 4 ] || exit $LINENO
@@ -204,13 +207,41 @@
 $JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain
 [ $? = 0 ] || exit $LINENO
 
-# but if ca2 is removed, -certchain does not work
+# if ca2 is removed, -certchain still work because altchain is a self-signed entry and
+# it is trusted by jarsigner
+# save ca2.cert for easy replay
+$KT -exportcert -file ca2.cert -alias ca2
 $KT -delete -alias ca2
 $JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain
+[ $? = 0 ] || exit $LINENO
+
+# if cert is imported, -certchain won't work because this certificate entry is not trusted
+$KT -importcert -file certchain -alias altchain -noprompt
+$JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain
 [ $? = 4 ] || exit $LINENO
 
 $JARSIGNER -verify a.jar
 [ $? = 0 ] || exit $LINENO
 
+# ==========================================================
+# 8172529
+# ==========================================================
+
+$KT -genkeypair -alias ee -dname CN=ee
+$KT -genkeypair -alias caone -dname CN=caone
+$KT -genkeypair -alias catwo -dname CN=catwo
+
+$KT -certreq -alias ee | $KT -gencert -alias catwo -rfc > ee.cert
+$KT -certreq -alias catwo | $KT -gencert -alias caone -sigalg MD5withRSA -rfc > catwo.cert
+
+# This certchain contains a cross-signed weak catwo.cert
+cat ee.cert catwo.cert | $KT -importcert -alias ee
+
+$JAR cvf a.jar A1.class
+$JARSIGNER -strict -keystore $KS -storepass changeit a.jar ee
+[ $? = 0 ] || exit $LINENO
+$JARSIGNER -strict -keystore $KS -storepass changeit -verify a.jar
+[ $? = 0 ] || exit $LINENO
+
 echo OK
 exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/tools/keytool/ImportPrompt.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.io.File;
+import java.security.KeyStore;
+
+/**
+ * @test
+ * @bug 8172975
+ * @summary SecurityTools.keytool() needs to accept user input
+ * @library /test/lib
+ */
+
+public class ImportPrompt {
+
+    private static final String COMMON =
+            "-storetype jks -storepass changeit -keypass changeit -debug";
+
+    public static void main(String[] args) throws Throwable {
+
+        kt("-keystore ks1 -genkeypair -alias a -dname CN=A");
+        kt("-keystore ks1 -exportcert -alias a -file a.cert");
+
+        // Just create a keystore
+        kt("-keystore ks2 -genkeypair -alias b -dname CN=B");
+
+        // no response text, assume no
+        kt("-keystore ks2 -importcert -alias a -file a.cert");
+        Asserts.assertFalse(hasA());
+
+        // no reply is no
+        SecurityTools.setResponse("no");
+        kt("-keystore ks2 -importcert -alias a -file a.cert");
+        Asserts.assertFalse(hasA());
+
+        // explicit yes
+        SecurityTools.setResponse("yes");
+        kt("-keystore ks2 -importcert -alias a -file a.cert");
+        Asserts.assertTrue(hasA());
+
+        // remove it
+        kt("-keystore ks2 -delete -alias a");
+        Asserts.assertFalse(hasA());
+
+        // the previous "yes" will not be remembered
+        kt("-keystore ks2 -importcert -alias a -file a.cert");
+        Asserts.assertFalse(hasA());
+
+        // add with -noprompt
+        SecurityTools.setResponse("");
+        kt("-keystore ks2 -importcert -alias a -file a.cert -noprompt");
+        Asserts.assertTrue(hasA());
+    }
+
+    private static OutputAnalyzer kt(String cmd) throws Throwable {
+        return SecurityTools.keytool(COMMON + " " + cmd)
+                .shouldHaveExitValue(0);
+    }
+
+    private static boolean hasA() throws Exception {
+        return KeyStore.getInstance(new File("ks2"), "changeit".toCharArray())
+                .containsAlias("a");
+    }
+}
--- a/jdk/test/sun/security/tools/keytool/PrintSSL.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/sun/security/tools/keytool/PrintSSL.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,7 @@
  * @test
  * @bug 6480981 8160624
  * @summary keytool should be able to import certificates from remote SSL server
- * @library /lib/security
- * @library /lib/testlibrary
+ * @library /test/lib
  * @run main/othervm PrintSSL
  */
 
@@ -36,7 +35,8 @@
 import java.util.concurrent.CountDownLatch;
 import javax.net.ssl.SSLServerSocketFactory;
 import javax.net.ssl.SSLSocket;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 public class PrintSSL {
 
--- a/jdk/test/sun/security/tools/keytool/ReadJar.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/sun/security/tools/keytool/ReadJar.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,15 @@
  * @test
  * @bug 6890872 8168882
  * @summary keytool -printcert to recognize signed jar files
- * @library /lib/security
+ * @library /test/lib
  * @library /lib/testlibrary
  */
 
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.testlibrary.JarUtils;
-import jdk.testlibrary.OutputAnalyzer;
 
 public class ReadJar {
 
@@ -56,16 +57,15 @@
         System.out.println(out.getOutput());
         out.shouldHaveExitValue(0);
 
-        out = SecurityTools.jarsigner("test_rsa.jar", "rsa_alias",
-                "-keystore keystore -storepass password ");
+        out = SecurityTools.jarsigner("-keystore keystore -storepass password "
+                + "test_rsa.jar rsa_alias");
         System.out.println(out.getOutput());
         out.shouldHaveExitValue(0);
 
         printCert("test_rsa.jar");
 
-        out = SecurityTools.jarsigner("test_md5.jar", "rsa_alias",
-                "-keystore keystore -storepass password "
-                        + "-sigalg MD5withRSA -digestalg MD5");
+        out = SecurityTools.jarsigner("-keystore keystore -storepass password "
+                + "-sigalg MD5withRSA -digestalg MD5 test_md5.jar rsa_alias");
         System.out.println(out.getOutput());
         out.shouldHaveExitValue(0);
 
--- a/jdk/test/tools/jar/InputFilesTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jar/InputFilesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -102,6 +102,7 @@
                 "META-INF/MANIFEST.MF" + nl +
                 "testfile1" + nl +
                 "testfile2" + nl +
+                "META-INF/versions/9/" + nl +
                 "META-INF/versions/9/testfile3" + nl +
                 "META-INF/versions/9/testfile4" + nl;
         rm("test.jar test1 test2 test3 test4");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/mmrjar/Basic.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,466 @@
+/*
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8146486 8172432
+ * @summary Fail to create a MR modular JAR with a versioned entry in
+ *          base-versioned empty package
+ * @modules java.base/jdk.internal.module
+ *          jdk.compiler
+ *          jdk.jartool
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.FileUtils
+ * @run testng Basic
+ */
+
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.UncheckedIOException;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleDescriptor.Version;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.Set;
+import java.util.spi.ToolProvider;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.zip.ZipFile;
+
+import jdk.internal.module.ModuleInfoExtender;
+import jdk.testlibrary.FileUtils;
+
+public class Basic {
+    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 final String linesep = System.lineSeparator();
+    private final Path testsrc;
+    private final Path userdir;
+    private final ByteArrayOutputStream outbytes = new ByteArrayOutputStream();
+    private final PrintStream out = new PrintStream(outbytes, true);
+    private final ByteArrayOutputStream errbytes = new ByteArrayOutputStream();
+    private final PrintStream err = new PrintStream(errbytes, true);
+
+    public Basic() throws IOException {
+        testsrc = Paths.get(System.getProperty("test.src"));
+        userdir = Paths.get(System.getProperty("user.dir", "."));
+
+        // compile the classes directory
+        Path source = testsrc.resolve("src").resolve("classes");
+        Path destination = Paths.get("classes");
+        javac(source, destination);
+
+        // compile the mr9 directory including module-info.java
+        source = testsrc.resolve("src").resolve("mr9");
+        destination = Paths.get("mr9");
+        javac(source, destination);
+
+        // move module-info.class for later use
+        Files.move(destination.resolve("module-info.class"),
+                Paths.get("module-info.class"));
+    }
+
+    private void javac(Path source, Path destination) throws IOException {
+        String[] args = Stream.concat(
+                Stream.of("-d", destination.toString()),
+                Files.walk(source)
+                        .map(Path::toString)
+                        .filter(s -> s.endsWith(".java"))
+        ).toArray(String[]::new);
+        JAVAC_TOOL.run(System.out, System.err, args);
+    }
+
+    private int jar(String cmd) {
+        outbytes.reset();
+        errbytes.reset();
+        return JAR_TOOL.run(out, err, cmd.split(" +"));
+    }
+
+    @AfterClass
+    public void cleanup() throws IOException {
+        Files.walk(userdir, 1)
+                .filter(p -> !p.equals(userdir))
+                .forEach(p -> {
+                    try {
+                        if (Files.isDirectory(p)) {
+                            FileUtils.deleteFileTreeWithRetry(p);
+                        } else {
+                            FileUtils.deleteFileIfExistsWithRetry(p);
+                        }
+                    } catch (IOException x) {
+                        throw new UncheckedIOException(x);
+                    }
+                });
+    }
+
+    // updates a valid multi-release jar with a new public class in
+    // versioned section and fails
+    @Test
+    public void test1() {
+        // successful build of multi-release jar
+        int rc = jar("-cf mmr.jar -C classes . --release 9 -C mr9 p/Hi.class");
+        Assert.assertEquals(rc, 0);
+
+        jar("-tf mmr.jar");
+
+        Set<String> actual = lines(outbytes);
+        Set<String> expected = Set.of(
+                "META-INF/",
+                "META-INF/MANIFEST.MF",
+                "p/",
+                "p/Hi.class",
+                "META-INF/versions/9/p/Hi.class"
+        );
+        Assert.assertEquals(actual, expected);
+
+        // failed build because of new public class
+        rc = jar("-uf mmr.jar --release 9 -C mr9 p/internal/Bar.class");
+        Assert.assertEquals(rc, 1);
+
+        String s = new String(errbytes.toByteArray());
+        Assert.assertTrue(Message.NOT_FOUND_IN_BASE_ENTRY.match(s, "p/internal/Bar.class"));
+    }
+
+    // updates a valid multi-release jar with a module-info class and new
+    // concealed public class in versioned section and succeeds
+    @Test
+    public void test2() {
+        // successful build of multi-release jar
+        int rc = jar("-cf mmr.jar -C classes . --release 9 -C mr9 p/Hi.class");
+        Assert.assertEquals(rc, 0);
+
+        // successful build because of module-info and new public class
+        rc = jar("-uf mmr.jar module-info.class --release 9 -C mr9 p/internal/Bar.class");
+        Assert.assertEquals(rc, 0);
+
+        String s = new String(errbytes.toByteArray());
+        Assert.assertTrue(Message.NEW_CONCEALED_PACKAGE_WARNING.match(s, "p/internal/Bar.class"));
+
+        jar("-tf mmr.jar");
+
+        Set<String> actual = lines(outbytes);
+        Set<String> expected = Set.of(
+                "META-INF/",
+                "META-INF/MANIFEST.MF",
+                "p/",
+                "p/Hi.class",
+                "META-INF/versions/9/p/Hi.class",
+                "META-INF/versions/9/p/internal/Bar.class",
+                "module-info.class"
+        );
+        Assert.assertEquals(actual, expected);
+    }
+
+    // jar tool fails building mmr.jar because of new public class
+    @Test
+    public void test3() {
+        int rc = jar("-cf mmr.jar -C classes . --release 9 -C mr9 .");
+        Assert.assertEquals(rc, 1);
+
+        String s = new String(errbytes.toByteArray());
+        Assert.assertTrue(Message.NOT_FOUND_IN_BASE_ENTRY.match(s, "p/internal/Bar.class"));
+    }
+
+    // jar tool succeeds building mmr.jar because of concealed package
+    @Test
+    public void test4() {
+        int rc = jar("-cf mmr.jar module-info.class -C classes . " +
+                "--release 9 module-info.class -C mr9 .");
+        Assert.assertEquals(rc, 0);
+
+        String s = new String(errbytes.toByteArray());
+        Assert.assertTrue(Message.NEW_CONCEALED_PACKAGE_WARNING.match(s, "p/internal/Bar.class"));
+
+        jar("-tf mmr.jar");
+
+        Set<String> actual = lines(outbytes);
+        Set<String> expected = Set.of(
+                "META-INF/",
+                "META-INF/MANIFEST.MF",
+                "module-info.class",
+                "META-INF/versions/9/module-info.class",
+                "p/",
+                "p/Hi.class",
+                "META-INF/versions/9/",
+                "META-INF/versions/9/p/",
+                "META-INF/versions/9/p/Hi.class",
+                "META-INF/versions/9/p/internal/",
+                "META-INF/versions/9/p/internal/Bar.class"
+        );
+        Assert.assertEquals(actual, expected);
+    }
+
+    // jar tool does two updates, no exported packages, all concealed
+    @Test
+    public void test5() throws IOException {
+        // compile the mr10 directory
+        Path source = testsrc.resolve("src").resolve("mr10");
+        Path destination = Paths.get("mr10");
+        javac(source, destination);
+
+        // create a directory for this tests special files
+        Files.createDirectory(Paths.get("test5"));
+
+        // create an empty module-info.java
+        String hi = "module hi {" + linesep + "}" + linesep;
+        Path modinfo = Paths.get("test5", "module-info.java");
+        Files.write(modinfo, hi.getBytes());
+
+        // and compile it
+        javac(modinfo, Paths.get("test5"));
+
+        int rc = jar("--create --file mr.jar -C classes .");
+        Assert.assertEquals(rc, 0);
+
+        rc = jar("--update --file mr.jar -C test5 module-info.class"
+                + " --release 9 -C mr9 .");
+        Assert.assertEquals(rc, 0);
+
+        jar("tf mr.jar");
+
+        Set<String> actual = lines(outbytes);
+        Set<String> expected = Set.of(
+                "META-INF/",
+                "META-INF/MANIFEST.MF",
+                "p/",
+                "p/Hi.class",
+                "META-INF/versions/9/",
+                "META-INF/versions/9/p/",
+                "META-INF/versions/9/p/Hi.class",
+                "META-INF/versions/9/p/internal/",
+                "META-INF/versions/9/p/internal/Bar.class",
+                "module-info.class"
+        );
+        Assert.assertEquals(actual, expected);
+
+        jar("-d --file mr.jar");
+
+        actual = lines(outbytes);
+        expected = Set.of(
+                "hi",
+                "requires mandated java.base",
+                "contains p",
+                "contains p.internal"
+        );
+        Assert.assertEquals(actual, expected);
+
+        rc = jar("--update --file mr.jar --release 10 -C mr10 .");
+        Assert.assertEquals(rc, 0);
+
+        jar("tf mr.jar");
+
+        actual = lines(outbytes);
+        expected = Set.of(
+                "META-INF/",
+                "META-INF/MANIFEST.MF",
+                "p/",
+                "p/Hi.class",
+                "META-INF/versions/9/",
+                "META-INF/versions/9/p/",
+                "META-INF/versions/9/p/Hi.class",
+                "META-INF/versions/9/p/internal/",
+                "META-INF/versions/9/p/internal/Bar.class",
+                "META-INF/versions/10/",
+                "META-INF/versions/10/p/",
+                "META-INF/versions/10/p/internal/",
+                "META-INF/versions/10/p/internal/bar/",
+                "META-INF/versions/10/p/internal/bar/Gee.class",
+                "module-info.class"
+        );
+        Assert.assertEquals(actual, expected);
+
+        jar("-d --file mr.jar");
+
+        actual = lines(outbytes);
+        expected = Set.of(
+                "hi",
+                "requires mandated java.base",
+                "contains p",
+                "contains p.internal",
+                "contains p.internal.bar"
+        );
+        Assert.assertEquals(actual, expected);
+    }
+
+    // root and versioned module-info entries have different main-class, version
+    // attributes
+    @Test
+    public void test6() throws IOException {
+        // create a directory for this tests special files
+        Files.createDirectory(Paths.get("test6"));
+        Files.createDirectory(Paths.get("test6-v9"));
+
+        // compile the classes directory
+        Path src = testsrc.resolve("src").resolve("classes");
+        Path dst = Paths.get("test6");
+        javac(src, dst);
+
+        byte[] mdBytes = Files.readAllBytes(Paths.get("module-info.class"));
+
+        ModuleInfoExtender mie = ModuleInfoExtender.newExtender(
+            new ByteArrayInputStream(mdBytes));
+
+        mie.mainClass("foo.main");
+        mie.version(Version.parse("1.0"));
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        mie.write(baos);
+        Files.write(Paths.get("test6", "module-info.class"), baos.toByteArray());
+        Files.write(Paths.get("test6-v9", "module-info.class"), baos.toByteArray());
+
+        int rc = jar("--create --file mmr.jar -C test6 . --release 9 -C test6-v9 .");
+        Assert.assertEquals(rc, 0);
+
+
+        // different main-class
+        mie = ModuleInfoExtender.newExtender(new ByteArrayInputStream(mdBytes));
+        mie.mainClass("foo.main2");
+        mie.version(Version.parse("1.0"));
+        baos.reset();
+        mie.write(baos);
+        Files.write(Paths.get("test6-v9", "module-info.class"), baos.toByteArray());
+
+        rc = jar("--create --file mmr.jar -C test6 . --release 9 -C test6-v9 .");
+        Assert.assertEquals(rc, 1);
+
+        Assert.assertTrue(Message.CONTAINS_DIFFERENT_MAINCLASS.match(
+            new String(errbytes.toByteArray()),
+            "META-INF/versions/9/module-info.class"));
+
+        // different version
+        mie = ModuleInfoExtender.newExtender(new ByteArrayInputStream(mdBytes));
+        mie.mainClass("foo.main");
+        mie.version(Version.parse("2.0"));
+        baos.reset();
+        mie.write(baos);
+        Files.write(Paths.get("test6-v9", "module-info.class"), baos.toByteArray());
+
+        rc = jar("--create --file mmr.jar -C test6 . --release 9 -C test6-v9 .");
+        Assert.assertEquals(rc, 1);
+
+        Assert.assertTrue(Message.CONTAINS_DIFFERENT_VERSION.match(
+            new String(errbytes.toByteArray()),
+            "META-INF/versions/9/module-info.class"));
+
+    }
+
+    // versioned mmr without root module-info.class
+    @Test
+    public void test7() throws IOException {
+        // create a directory for this tests special files
+        Files.createDirectory(Paths.get("test7"));
+        Files.createDirectory(Paths.get("test7-v9"));
+        Files.createDirectory(Paths.get("test7-v10"));
+
+        // compile the classes directory
+        Path src = testsrc.resolve("src").resolve("classes");
+        Path dst = Paths.get("test7");
+        javac(src, dst);
+
+        // move module-info.class to v9 later use
+        Files.copy(Paths.get("module-info.class"),
+                   Paths.get("test7-v9", "module-info.class"));
+
+        Files.copy(Paths.get("test7-v9", "module-info.class"),
+                   Paths.get("test7-v10", "module-info.class"));
+
+        int rc = jar("--create --file mmr.jar --main-class=foo.main -C test7 . --release 9 -C test7-v9 . --release 10 -C test7-v10 .");
+
+System.out.println("-----------------------");
+System.out.println( new String(errbytes.toByteArray()));
+
+
+        Assert.assertEquals(rc, 0);
+
+
+        jar("-tf mmr.jar");
+
+System.out.println("-----------------------");
+System.out.println( new String(outbytes.toByteArray()));
+
+        Optional<String> exp = Optional.of("foo.main");
+        try (ZipFile zf = new ZipFile("mmr.jar")) {
+            Assert.assertTrue(zf.getEntry("module-info.class") == null);
+
+            ModuleDescriptor md = ModuleDescriptor.read(
+                zf.getInputStream(zf.getEntry("META-INF/versions/9/module-info.class")));
+            Assert.assertEquals(md.mainClass(), exp);
+
+            md = ModuleDescriptor.read(
+                zf.getInputStream(zf.getEntry("META-INF/versions/10/module-info.class")));
+            Assert.assertEquals(md.mainClass(), exp);
+        }
+    }
+
+    private static Set<String> lines(ByteArrayOutputStream baos) {
+        String s = new String(baos.toByteArray());
+        return Arrays.stream(s.split("\\R"))
+                     .map(l -> l.trim())
+                     .filter(l -> l.length() > 0)
+                     .collect(Collectors.toSet());
+    }
+
+    static enum Message {
+        CONTAINS_DIFFERENT_MAINCLASS(
+          ": module-info.class in a versioned directory contains different \"main-class\""
+        ),
+        CONTAINS_DIFFERENT_VERSION(
+          ": module-info.class in a versioned directory contains different \"version\""
+        ),
+        NOT_FOUND_IN_BASE_ENTRY(
+          ", contains a new public class not found in base entries"
+        ),
+        NEW_CONCEALED_PACKAGE_WARNING(
+            " is a public class" +
+            " in a concealed package, placing this jar on the class path will result" +
+            " in incompatible public interfaces"
+        );
+
+        final String msg;
+        Message(String msg) {
+            this.msg = msg;
+        }
+
+        /*
+         * Test if the given output contains this message ignoring the line break.
+         */
+        boolean match(String output, String entry) {
+            System.out.println("Expected: " + entry + msg);
+            System.out.println("Found: " + output);
+            return Arrays.stream(output.split("\\R"))
+                         .collect(Collectors.joining(" "))
+                         .contains(entry + msg);
+        }
+    }
+}
--- a/jdk/test/tools/jar/mmrjar/ConcealedPackage.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,339 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8146486
- * @summary Fail to create a MR modular JAR with a versioned entry in
- *          base-versioned empty package
- * @modules jdk.compiler
- *          jdk.jartool
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
- * @run testng ConcealedPackage
- */
-
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.UncheckedIOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.Set;
-import java.util.spi.ToolProvider;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import jdk.testlibrary.FileUtils;
-
-public class ConcealedPackage {
-    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 final String linesep = System.lineSeparator();
-    private final Path testsrc;
-    private final Path userdir;
-    private final ByteArrayOutputStream outbytes = new ByteArrayOutputStream();
-    private final PrintStream out = new PrintStream(outbytes, true);
-    private final ByteArrayOutputStream errbytes = new ByteArrayOutputStream();
-    private final PrintStream err = new PrintStream(errbytes, true);
-
-    public ConcealedPackage() throws IOException {
-        testsrc = Paths.get(System.getProperty("test.src"));
-        userdir = Paths.get(System.getProperty("user.dir", "."));
-
-        // compile the classes directory
-        Path source = testsrc.resolve("src").resolve("classes");
-        Path destination = Paths.get("classes");
-        javac(source, destination);
-
-        // compile the mr9 directory including module-info.java
-        source = testsrc.resolve("src").resolve("mr9");
-        destination = Paths.get("mr9");
-        javac(source, destination);
-
-        // move module-info.class for later use
-        Files.move(destination.resolve("module-info.class"),
-                Paths.get("module-info.class"));
-    }
-
-    private void javac(Path source, Path destination) throws IOException {
-        String[] args = Stream.concat(
-                Stream.of("-d", destination.toString()),
-                Files.walk(source)
-                        .map(Path::toString)
-                        .filter(s -> s.endsWith(".java"))
-        ).toArray(String[]::new);
-        JAVAC_TOOL.run(System.out, System.err, args);
-    }
-
-    private int jar(String cmd) {
-        outbytes.reset();
-        errbytes.reset();
-        return JAR_TOOL.run(out, err, cmd.split(" +"));
-    }
-
-    @AfterClass
-    public void cleanup() throws IOException {
-        Files.walk(userdir, 1)
-                .filter(p -> !p.equals(userdir))
-                .forEach(p -> {
-                    try {
-                        if (Files.isDirectory(p)) {
-                            FileUtils.deleteFileTreeWithRetry(p);
-                        } else {
-                            FileUtils.deleteFileIfExistsWithRetry(p);
-                        }
-                    } catch (IOException x) {
-                        throw new UncheckedIOException(x);
-                    }
-                });
-    }
-
-    // updates a valid multi-release jar with a new public class in
-    // versioned section and fails
-    @Test
-    public void test1() {
-        // successful build of multi-release jar
-        int rc = jar("-cf mmr.jar -C classes . --release 9 -C mr9 p/Hi.class");
-        Assert.assertEquals(rc, 0);
-
-        jar("-tf mmr.jar");
-
-        Set<String> actual = lines(outbytes);
-        Set<String> expected = Set.of(
-                "META-INF/",
-                "META-INF/MANIFEST.MF",
-                "p/",
-                "p/Hi.class",
-                "META-INF/versions/9/p/Hi.class"
-        );
-        Assert.assertEquals(actual, expected);
-
-        // failed build because of new public class
-        rc = jar("-uf mmr.jar --release 9 -C mr9 p/internal/Bar.class");
-        Assert.assertEquals(rc, 1);
-
-        String s = new String(errbytes.toByteArray());
-        Assert.assertTrue(Message.NOT_FOUND_IN_BASE_ENTRY.match(s, "p/internal/Bar.class"));
-    }
-
-    // updates a valid multi-release jar with a module-info class and new
-    // concealed public class in versioned section and succeeds
-    @Test
-    public void test2() {
-        // successful build of multi-release jar
-        int rc = jar("-cf mmr.jar -C classes . --release 9 -C mr9 p/Hi.class");
-        Assert.assertEquals(rc, 0);
-
-        // successful build because of module-info and new public class
-        rc = jar("-uf mmr.jar module-info.class --release 9 -C mr9 p/internal/Bar.class");
-        Assert.assertEquals(rc, 0);
-
-        String s = new String(errbytes.toByteArray());
-        Assert.assertTrue(Message.NEW_CONCEALED_PACKAGE_WARNING.match(s, "p/internal/Bar.class"));
-
-        jar("-tf mmr.jar");
-
-        Set<String> actual = lines(outbytes);
-        Set<String> expected = Set.of(
-                "META-INF/",
-                "META-INF/MANIFEST.MF",
-                "p/",
-                "p/Hi.class",
-                "META-INF/versions/9/p/Hi.class",
-                "META-INF/versions/9/p/internal/Bar.class",
-                "module-info.class"
-        );
-        Assert.assertEquals(actual, expected);
-    }
-
-    // jar tool fails building mmr.jar because of new public class
-    @Test
-    public void test3() {
-        int rc = jar("-cf mmr.jar -C classes . --release 9 -C mr9 .");
-        Assert.assertEquals(rc, 1);
-
-        String s = new String(errbytes.toByteArray());
-        Assert.assertTrue(Message.NOT_FOUND_IN_BASE_ENTRY.match(s, "p/internal/Bar.class"));
-    }
-
-    // jar tool succeeds building mmr.jar because of concealed package
-    @Test
-    public void test4() {
-        int rc = jar("-cf mmr.jar module-info.class -C classes . " +
-                "--release 9 module-info.class -C mr9 .");
-        Assert.assertEquals(rc, 0);
-
-        String s = new String(errbytes.toByteArray());
-        Assert.assertTrue(Message.NEW_CONCEALED_PACKAGE_WARNING.match(s, "p/internal/Bar.class"));
-
-        jar("-tf mmr.jar");
-
-        Set<String> actual = lines(outbytes);
-        Set<String> expected = Set.of(
-                "META-INF/",
-                "META-INF/MANIFEST.MF",
-                "module-info.class",
-                "META-INF/versions/9/module-info.class",
-                "p/",
-                "p/Hi.class",
-                "META-INF/versions/9/p/",
-                "META-INF/versions/9/p/Hi.class",
-                "META-INF/versions/9/p/internal/",
-                "META-INF/versions/9/p/internal/Bar.class"
-        );
-        Assert.assertEquals(actual, expected);
-    }
-
-    // jar tool does two updates, no exported packages, all concealed
-    @Test
-    public void test5() throws IOException {
-        // compile the mr10 directory
-        Path source = testsrc.resolve("src").resolve("mr10");
-        Path destination = Paths.get("mr10");
-        javac(source, destination);
-
-        // create a directory for this tests special files
-        Files.createDirectory(Paths.get("test5"));
-
-        // create an empty module-info.java
-        String hi = "module hi {" + linesep + "}" + linesep;
-        Path modinfo = Paths.get("test5", "module-info.java");
-        Files.write(modinfo, hi.getBytes());
-
-        // and compile it
-        javac(modinfo, Paths.get("test5"));
-
-        int rc = jar("--create --file mr.jar -C classes .");
-        Assert.assertEquals(rc, 0);
-
-        rc = jar("--update --file mr.jar -C test5 module-info.class"
-                + " --release 9 -C mr9 .");
-        Assert.assertEquals(rc, 0);
-
-        jar("tf mr.jar");
-
-        Set<String> actual = lines(outbytes);
-        Set<String> expected = Set.of(
-                "META-INF/",
-                "META-INF/MANIFEST.MF",
-                "p/",
-                "p/Hi.class",
-                "META-INF/versions/9/p/",
-                "META-INF/versions/9/p/Hi.class",
-                "META-INF/versions/9/p/internal/",
-                "META-INF/versions/9/p/internal/Bar.class",
-                "module-info.class"
-        );
-        Assert.assertEquals(actual, expected);
-
-        jar("-d --file mr.jar");
-
-        actual = lines(outbytes);
-        expected = Set.of(
-                "hi",
-                "requires mandated java.base",
-                "contains p",
-                "contains p.internal"
-        );
-        Assert.assertEquals(actual, expected);
-
-        rc = jar("--update --file mr.jar --release 10 -C mr10 .");
-        Assert.assertEquals(rc, 0);
-
-        jar("tf mr.jar");
-
-        actual = lines(outbytes);
-        expected = Set.of(
-                "META-INF/",
-                "META-INF/MANIFEST.MF",
-                "p/",
-                "p/Hi.class",
-                "META-INF/versions/9/p/",
-                "META-INF/versions/9/p/Hi.class",
-                "META-INF/versions/9/p/internal/",
-                "META-INF/versions/9/p/internal/Bar.class",
-                "META-INF/versions/10/p/",
-                "META-INF/versions/10/p/internal/",
-                "META-INF/versions/10/p/internal/bar/",
-                "META-INF/versions/10/p/internal/bar/Gee.class",
-                "module-info.class"
-        );
-        Assert.assertEquals(actual, expected);
-
-        jar("-d --file mr.jar");
-
-        actual = lines(outbytes);
-        expected = Set.of(
-                "hi",
-                "requires mandated java.base",
-                "contains p",
-                "contains p.internal",
-                "contains p.internal.bar"
-        );
-        Assert.assertEquals(actual, expected);
-    }
-
-    private static Set<String> lines(ByteArrayOutputStream baos) {
-        String s = new String(baos.toByteArray());
-        return Arrays.stream(s.split("\\R"))
-                     .map(l -> l.trim())
-                     .filter(l -> l.length() > 0)
-                     .collect(Collectors.toSet());
-    }
-
-    static enum Message {
-        NOT_FOUND_IN_BASE_ENTRY(
-          ", contains a new public class not found in base entries"
-        ),
-        NEW_CONCEALED_PACKAGE_WARNING(
-            " is a public class" +
-            " in a concealed package, placing this jar on the class path will result" +
-            " in incompatible public interfaces"
-        );
-
-        final String msg;
-        Message(String msg) {
-            this.msg = msg;
-        }
-
-        /*
-         * Test if the given output contains this message ignoring the line break.
-         */
-        boolean match(String output, String entry) {
-            System.out.println("Expected: " + entry + msg);
-            System.out.println("Found: " + output);
-            return Arrays.stream(output.split("\\R"))
-                         .collect(Collectors.joining(" "))
-                         .contains(entry + msg);
-        }
-    }
-}
--- a/jdk/test/tools/jar/modularJar/Basic.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jar/modularJar/Basic.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
 
 /*
  * @test
- * @bug 8167328
+ * @bug 8167328 8171830
  * @library /lib/testlibrary
  * @modules jdk.compiler
  *          jdk.jartool
@@ -241,6 +241,11 @@
 
         java(mp, FOO.moduleName + "/" + FOO.mainClass)
             .assertSuccess()
+.resultChecker(r -> {
+        System.out.println("===================================");
+        System.out.println(r.output);
+        System.out.println("===================================");
+})
             .resultChecker(r -> assertModuleData(r, FOO));
         try (InputStream fis = Files.newInputStream(modularJar);
              JarInputStream jis = new JarInputStream(fis)) {
@@ -417,6 +422,7 @@
         jar("--update",
             "--file=" + modularJar.toString(),
             "--main-class=" + FOO.mainClass,
+            "--module-version=" + FOO.version,
             "-m", mrjarDir.resolve("META-INF/MANIFEST.MF").toRealPath().toString(),
             "-C", mrjarDir.toString(), "META-INF/versions/9/module-info.class")
             .assertSuccess();
@@ -734,6 +740,25 @@
     }
 
     @Test
+    public void exportCreateWithMissingPkg() throws IOException {
+
+        Path foobar = TEST_SRC.resolve("src").resolve("foobar");
+        Path dst = Files.createDirectories(MODULE_CLASSES.resolve("foobar"));
+        javac(dst, null, sourceList(foobar));
+
+        Path mp = Paths.get("exportWithMissingPkg");
+        createTestDir(mp);
+        Path modClasses = dst;
+        Path modularJar = mp.resolve("foofoo.jar");
+
+        jar("--create",
+            "--file=" + modularJar.toString(),
+            "-C", modClasses.toString(), "module-info.class",
+            "-C", modClasses.toString(), "jdk/test/foo/Foo.class")
+            .assertFailure();
+    }
+
+    @Test
     public void printModuleDescriptorFoo() throws IOException {
         Path mp = Paths.get("printModuleDescriptorFoo");
         createTestDir(mp);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/modularJar/src/foobar/Bar.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.bar;
+
+public class Bar {
+    public static void main(String[] args) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/modularJar/src/foobar/Foo.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.foo;
+
+public class Foo {
+    public static void main(String[] args) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/modularJar/src/foobar/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module foo {
+    exports jdk.test.foo;
+    exports jdk.test.bar;
+    opens jdk.test.foo;
+    opens jdk.test.bar;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Tests for API validator.
+ * @library /test/lib /lib/testlibrary
+ * @modules java.base/jdk.internal.misc
+ *          jdk.compiler
+ *          jdk.jartool
+ * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.*
+ * @build jdk.testlibrary.FileUtils
+ * @build MRTestBase
+ * @run testng ApiValidatorTest
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.testlibrary.FileUtils;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class ApiValidatorTest extends MRTestBase {
+
+    @Test(dataProvider = "signatureChange")
+    public void changeMethodSignature(String sigBase, String sigV10,
+                                      boolean isAcceptable,
+                                      Method method) throws Throwable {
+        Path root = Paths.get(method.getName());
+        Path classes = root.resolve("classes");
+
+        String METHOD_SIG = "#SIG";
+        String classTemplate =
+                "public class C { \n" +
+                        "    " + METHOD_SIG + "{ throw new RuntimeException(); };\n" +
+                        "}\n";
+        String base = classTemplate.replace(METHOD_SIG, sigBase);
+        String v10 = classTemplate.replace(METHOD_SIG, sigV10);
+
+        compileTemplate(classes.resolve("base"), base);
+        compileTemplate(classes.resolve("v10"), v10);
+
+        String jarfile = root.resolve("test.jar").toString();
+        OutputAnalyzer result = jar("cf", jarfile,
+                "-C", classes.resolve("base").toString(), ".",
+                "--release", "10", "-C", classes.resolve("v10").toString(),
+                ".");
+        if (isAcceptable) {
+            result.shouldHaveExitValue(SUCCESS)
+                    .shouldBeEmpty();
+        } else {
+            result.shouldNotHaveExitValue(SUCCESS)
+                    .shouldContain("contains a class with different api from earlier version");
+        }
+
+        FileUtils.deleteFileTreeWithRetry(root);
+    }
+
+    @DataProvider
+    Object[][] signatureChange() {
+        return new Object[][]{
+                {"public int m()", "protected int m()", false},
+                {"protected int m()", "public int m()", false},
+                {"public int m()", "int m()", false},
+                {"protected int m()", "private int m()", false},
+                {"private int m()", "int m()", true},
+                {"int m()", "private int m()", true},
+                {"int m()", "private int m(boolean b)", true},
+                {"public int m()", "public int m(int i)", false},
+                {"public int m()", "public int k()", false},
+                {"public int m()", "private int k()", false},
+// @ignore JDK-8172147   {"public int m()", "public boolean m()", false},
+// @ignore JDK-8172147   {"public boolean", "public Boolean", false},
+// @ignore JDK-8172147   {"public <T> T", "public <T extends String> T", false},
+        };
+    }
+
+    @Test(dataProvider = "publicAPI")
+    public void introducingPublicMembers(String publicAPI,
+                                         Method method) throws Throwable {
+        Path root = Paths.get(method.getName());
+        Path classes = root.resolve("classes");
+
+        String API = "#API";
+        String classTemplate =
+                "public class C { \n" +
+                        "    " + API + "\n" +
+                        "    public void method(){ };\n" +
+                        "}\n";
+        String base = classTemplate.replace(API, "");
+        String v10 = classTemplate.replace(API, publicAPI);
+
+        compileTemplate(classes.resolve("base"), base);
+        compileTemplate(classes.resolve("v10"), v10);
+
+        String jarfile = root.resolve("test.jar").toString();
+        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+                "--release", "10", "-C", classes.resolve("v10").toString(), ".")
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("contains a class with different api from earlier version");
+
+        FileUtils.deleteFileTreeWithRetry(root);
+    }
+
+    @DataProvider
+    Object[][] publicAPI() {
+        return new Object[][]{
+// @ignore JDK-8172148  {"protected class Inner { public void m(){ } } "}, // protected inner class
+// @ignore JDK-8172148  {"public class Inner { public void m(){ } }"},  // public inner class
+// @ignore JDK-8172148  {"public enum E { A; }"},  // public enum
+                {"public void m(){ }"}, // public method
+                {"protected void m(){ }"}, // protected method
+        };
+    }
+
+    @Test(dataProvider = "privateAPI")
+    public void introducingPrivateMembers(String privateAPI,
+                                          Method method) throws Throwable {
+        Path root = Paths.get(method.getName());
+        Path classes = root.resolve("classes");
+
+        String API = "#API";
+        String classTemplate =
+                "public class C { \n" +
+                        "    " + API + "\n" +
+                        "    public void method(){ };\n" +
+                        "}\n";
+        String base = classTemplate.replace(API, "");
+        String v10 = classTemplate.replace(API, privateAPI);
+
+        compileTemplate(classes.resolve("base"), base);
+        compileTemplate(classes.resolve("v10"), v10);
+
+        String jarfile = root.resolve("test.jar").toString();
+        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+                "--release", "10", "-C", classes.resolve("v10").toString(), ".")
+                .shouldHaveExitValue(SUCCESS);
+        // add release
+        jar("uf", jarfile,
+                "--release", "11", "-C", classes.resolve("v10").toString(), ".")
+                .shouldHaveExitValue(SUCCESS);
+        // replace release
+        jar("uf", jarfile,
+                "--release", "11", "-C", classes.resolve("v10").toString(), ".")
+                .shouldHaveExitValue(SUCCESS);
+
+        FileUtils.deleteFileTreeWithRetry(root);
+    }
+
+    @DataProvider
+    Object[][] privateAPI() {
+        return new Object[][]{
+                {"private class Inner { public void m(){ } } "}, // private inner class
+                {"class Inner { public void m(){ } }"},  // package private inner class
+                {"enum E { A; }"},  // package private enum
+                // Local class and private method
+                {"private void m(){ class Inner { public void m(){} } Inner i = null; }"},
+                {"void m(){ }"}, // package private method
+        };
+    }
+
+    private void compileTemplate(Path classes, String template) throws Throwable {
+        Path classSourceFile = Files.createDirectories(
+                classes.getParent().resolve("src").resolve(classes.getFileName()))
+                .resolve("C.java");
+        Files.write(classSourceFile, template.getBytes());
+        javac(classes, classSourceFile);
+    }
+}
\ No newline at end of file
--- a/jdk/test/tools/jar/multiRelease/Basic.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jar/multiRelease/Basic.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,69 +23,59 @@
 
 /*
  * @test
- * @library /test/lib
+ * @library /test/lib /lib/testlibrary
  * @modules java.base/jdk.internal.misc
  *          jdk.compiler
  *          jdk.jartool
- * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils
+ * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.*
+ * @build jdk.testlibrary.FileUtils
+ * @build MRTestBase
  * @run testng Basic
  */
 
 import static org.testng.Assert.*;
 
+import jdk.testlibrary.FileUtils;
 import org.testng.annotations.*;
 
-import java.io.*;
+import java.io.File;
 import java.nio.file.*;
-import java.nio.file.attribute.*;
 import java.util.*;
-import java.util.function.Consumer;
-import java.util.jar.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.zip.*;
+import java.util.jar.JarFile;
+import java.util.zip.ZipFile;
 
-import jdk.test.lib.JDKToolFinder;
-import jdk.test.lib.Utils;
-
-
-import static java.lang.String.format;
-import static java.lang.System.out;
-
-public class Basic {
-    private final String src = System.getProperty("test.src", ".");
-    private final String usr = System.getProperty("user.dir", ".");
+public class Basic extends MRTestBase {
 
     @Test
     // create a regular, non-multi-release jar
-    public void test00() throws IOException {
+    public void test00() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
 
         Path classes = Paths.get("classes");
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".")
-                .assertSuccess();
+                .shouldHaveExitValue(SUCCESS);
 
         checkMultiRelease(jarfile, false);
 
-        Map<String,String[]> names = Map.of(
+        Map<String, String[]> names = Map.of(
                 "version/Main.class",
-                new String[] {"base", "version", "Main.class"},
+                new String[]{"base", "version", "Main.class"},
 
                 "version/Version.class",
-                new String[] {"base", "version", "Version.class"}
+                new String[]{"base", "version", "Version.class"}
         );
 
         compare(jarfile, names);
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // create a multi-release jar
-    public void test01() throws IOException {
+    public void test01() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");
@@ -94,68 +84,96 @@
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".",
                 "--release", "10", "-C", classes.resolve("v10").toString(), ".")
-                .assertSuccess();
+                .shouldHaveExitValue(SUCCESS);
 
         checkMultiRelease(jarfile, true);
 
-        Map<String,String[]> names = Map.of(
+        Map<String, String[]> names = Map.of(
                 "version/Main.class",
-                new String[] {"base", "version", "Main.class"},
+                new String[]{"base", "version", "Main.class"},
 
                 "version/Version.class",
-                new String[] {"base", "version", "Version.class"},
+                new String[]{"base", "version", "Version.class"},
 
                 "META-INF/versions/9/version/Version.class",
-                new String[] {"v9", "version", "Version.class"},
+                new String[]{"v9", "version", "Version.class"},
 
                 "META-INF/versions/10/version/Version.class",
-                new String[] {"v10", "version", "Version.class"}
+                new String[]{"v10", "version", "Version.class"}
         );
 
         compare(jarfile, names);
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
+    }
+
+    @Test
+    public void versionFormat() throws Throwable {
+        String jarfile = "test.jar";
+
+        compile("test01");
+
+        Path classes = Paths.get("classes");
+
+        // valid
+        for (String release : List.of("10000", "09", "00010", "10")) {
+            jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+                    "--release", release, "-C", classes.resolve("v10").toString(), ".")
+                    .shouldHaveExitValue(SUCCESS)
+                    .shouldBeEmpty();
+        }
+        // invalid
+        for (String release : List.of("9.0", "8", "v9",
+                "9v", "0", "-10")) {
+            jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+                    "--release", release, "-C", classes.resolve("v10").toString(), ".")
+                    .shouldNotHaveExitValue(SUCCESS)
+                    .shouldContain("release " + release + " not valid");
+        }
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // update a regular jar to a multi-release jar
-    public void test02() throws IOException {
+    public void test02() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
 
         Path classes = Paths.get("classes");
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".")
-                .assertSuccess();
+                .shouldHaveExitValue(SUCCESS);
 
         checkMultiRelease(jarfile, false);
 
-        jar("uf", jarfile, "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertSuccess();
+        jar("uf", jarfile,
+                "--release", "9", "-C", classes.resolve("v9").toString(), ".")
+                .shouldHaveExitValue(SUCCESS);
 
         checkMultiRelease(jarfile, true);
 
-        Map<String,String[]> names = Map.of(
+        Map<String, String[]> names = Map.of(
                 "version/Main.class",
-                new String[] {"base", "version", "Main.class"},
+                new String[]{"base", "version", "Main.class"},
 
                 "version/Version.class",
-                new String[] {"base", "version", "Version.class"},
+                new String[]{"base", "version", "Version.class"},
 
                 "META-INF/versions/9/version/Version.class",
-                new String[] {"v9", "version", "Version.class"}
+                new String[]{"v9", "version", "Version.class"}
         );
 
         compare(jarfile, names);
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // replace a base entry and a versioned entry
-    public void test03() throws IOException {
+    public void test03() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -163,19 +181,19 @@
         Path classes = Paths.get("classes");
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertSuccess();
+                .shouldHaveExitValue(SUCCESS);
 
         checkMultiRelease(jarfile, true);
 
-        Map<String,String[]> names = Map.of(
+        Map<String, String[]> names = Map.of(
                 "version/Main.class",
-                new String[] {"base", "version", "Main.class"},
+                new String[]{"base", "version", "Main.class"},
 
                 "version/Version.class",
-                new String[] {"base", "version", "Version.class"},
+                new String[]{"base", "version", "Version.class"},
 
                 "META-INF/versions/9/version/Version.class",
-                new String[] {"v9", "version", "Version.class"}
+                new String[]{"v9", "version", "Version.class"}
         );
 
         compare(jarfile, names);
@@ -184,25 +202,25 @@
         // version/Version.class entry in versions/9 section
         jar("uf", jarfile, "-C", classes.resolve("v9").toString(), "version",
                 "--release", "9", "-C", classes.resolve("v10").toString(), ".")
-                .assertSuccess();
+                .shouldHaveExitValue(SUCCESS);
 
         checkMultiRelease(jarfile, true);
 
         names = Map.of(
                 "version/Main.class",
-                new String[] {"base", "version", "Main.class"},
+                new String[]{"base", "version", "Main.class"},
 
                 "version/Version.class",
-                new String[] {"v9", "version", "Version.class"},
+                new String[]{"v9", "version", "Version.class"},
 
                 "META-INF/versions/9/version/Version.class",
-                new String[] {"v10", "version", "Version.class"}
+                new String[]{"v10", "version", "Version.class"}
         );
 
         compare(jarfile, names);
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     /*
@@ -211,7 +229,7 @@
 
     @Test
     // META-INF/versions/9 class has different api than base class
-    public void test04() throws IOException {
+    public void test04() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -224,18 +242,16 @@
 
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertFailure()
-                .resultChecker(r ->
-                    assertTrue(r.output.contains("different api from earlier"), r.output)
-                );
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("different api from earlier");
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // META-INF/versions/9 contains an extra public class
-    public void test05() throws IOException {
+    public void test05() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -248,18 +264,16 @@
 
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertFailure()
-                .resultChecker(r ->
-                        assertTrue(r.output.contains("contains a new public class"), r.output)
-                );
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("contains a new public class");
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // META-INF/versions/9 contains an extra package private class -- this is okay
-    public void test06() throws IOException {
+    public void test06() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -272,16 +286,16 @@
 
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertSuccess();
+                .shouldHaveExitValue(SUCCESS);
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // META-INF/versions/9 contains an identical class to base entry class
     // this is okay but produces warning
-    public void test07() throws IOException {
+    public void test07() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -294,19 +308,42 @@
 
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertSuccess()
-                .resultChecker(r ->
-                        assertTrue(r.outputContains("contains a class that is identical"), r.output)
-                );
+                .shouldHaveExitValue(SUCCESS)
+                .shouldContain("contains a class that")
+                .shouldContain("is identical");
+
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
+    }
+
+    @Test
+    // META-INF/versions/9 contains an identical class to previous version entry class
+    // this is okay but produces warning
+    public void identicalClassToPreviousVersion() throws Throwable {
+        String jarfile = "test.jar";
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        compile("test01");  //use same data as test01
+
+        Path classes = Paths.get("classes");
+
+        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+                "--release", "9", "-C", classes.resolve("v9").toString(), ".")
+                .shouldHaveExitValue(SUCCESS)
+                .shouldBeEmpty();
+        jar("uf", jarfile,
+                "--release", "10", "-C", classes.resolve("v9").toString(), ".")
+                .shouldHaveExitValue(SUCCESS)
+                .shouldContain("contains a class that")
+                .shouldContain("is identical");
+
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // resources with same name in different versions
     // this is okay but produces warning
-    public void test08() throws IOException {
+    public void test08() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -320,10 +357,8 @@
 
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertSuccess()
-                .resultChecker(r ->
-                        assertTrue(r.output.isEmpty(), r.output)
-                );
+                .shouldHaveExitValue(SUCCESS)
+                .shouldBeEmpty();
 
         // now add a different resource with same name to META-INF/version/9
         Files.copy(source.resolve("Main.java"), classes.resolve("v9")
@@ -331,18 +366,16 @@
 
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertSuccess()
-                .resultChecker(r ->
-                        assertTrue(r.output.contains("multiple resources with same name"), r.output)
-                );
+                .shouldHaveExitValue(SUCCESS)
+                .shouldContain("multiple resources with same name");
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // a class with an internal name different from the external name
-    public void test09() throws IOException {
+    public void test09() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -355,18 +388,16 @@
 
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertFailure()
-                .resultChecker(r ->
-                        assertTrue(r.output.contains("names do not match"), r.output)
-                );
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("names do not match");
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // assure that basic nested classes are acceptable
-    public void test10() throws IOException {
+    public void test10() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -383,15 +414,15 @@
 
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertSuccess();
+                .shouldHaveExitValue(SUCCESS);
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // a base entry contains a nested class that doesn't have a matching top level class
-    public void test11() throws IOException {
+    public void test11() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -409,30 +440,29 @@
         source = Paths.get(src, "data", "test10", "v9", "version");
         javac(classes.resolve("v9"), source.resolve("Nested.java"));
 
-        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+        List<String> output = jar("cf", jarfile,
+                "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertFailure()
-                .resultChecker(r -> {
-                    String[] msg = r.output.split("\\R");
-                    // There should be 3 error messages, cascading from the first.  Once we
-                    // remove the base top level class, the base nested class becomes isolated,
-                    // also the versioned top level class becomes a new public class, thus ignored
-                    // for subsequent checks, leading to the associated versioned nested class
-                    // becoming an isolated nested class
-                    assertTrue(msg.length == 4);
-                    assertTrue(msg[0].contains("an isolated nested class"), msg[0]);
-                    assertTrue(msg[1].contains("contains a new public class"), msg[1]);
-                    assertTrue(msg[2].contains("an isolated nested class"), msg[2]);
-                    assertTrue(msg[3].contains("invalid multi-release jar file"), msg[3]);
-                });
+                .shouldNotHaveExitValue(SUCCESS)
+                .asLines();
 
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
+        assertTrue(output.size() == 4);
+        assertTrue(output.get(0).contains("an isolated nested class"),
+                output.get(0));
+        assertTrue(output.get(1).contains("contains a new public class"),
+                output.get(1));
+        assertTrue(output.get(2).contains("an isolated nested class"),
+                output.get(2));
+        assertTrue(output.get(3).contains("invalid multi-release jar file"),
+                output.get(3));
+
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
     @Test
     // a versioned entry contains a nested class that doesn't have a matching top level class
-    public void test12() throws IOException {
+    public void test12() throws Throwable {
         String jarfile = "test.jar";
 
         compile("test01");  //use same data as test01
@@ -452,178 +482,59 @@
 
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
-                .assertFailure()
-                .resultChecker(r ->
-                        assertTrue(r.outputContains("an isolated nested class"), r.output)
-                );
-
-        delete(jarfile);
-        deleteDir(Paths.get(usr, "classes"));
-    }
-
-    /*
-     *  Test Infrastructure
-     */
-    private void compile(String test) throws IOException {
-        Path classes = Paths.get(usr, "classes", "base");
-        Files.createDirectories(classes);
-        Path source = Paths.get(src, "data", test, "base", "version");
-        javac(classes, source.resolve("Main.java"), source.resolve("Version.java"));
-
-        classes = Paths.get(usr, "classes", "v9");
-        Files.createDirectories(classes);
-        source = Paths.get(src, "data", test, "v9", "version");
-        javac(classes, source.resolve("Version.java"));
-
-        classes = Paths.get(usr, "classes", "v10");
-        Files.createDirectories(classes);
-        source = Paths.get(src, "data", test, "v10", "version");
-        javac(classes, source.resolve("Version.java"));
-    }
-
-    private void checkMultiRelease(String jarFile, boolean expected) throws IOException {
-        try (JarFile jf = new JarFile(new File(jarFile), true, ZipFile.OPEN_READ,
-                JarFile.runtimeVersion())) {
-            assertEquals(jf.isMultiRelease(), expected);
-        }
-    }
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("an isolated nested class");
 
-    // compares the bytes found in the jar entries with the bytes found in the
-    // corresponding data files used to create the entries
-    private void compare(String jarfile, Map<String,String[]> names) throws IOException {
-        try (JarFile jf = new JarFile(jarfile)) {
-            for (String name : names.keySet()) {
-                Path path = Paths.get("classes", names.get(name));
-                byte[] b1 = Files.readAllBytes(path);
-                byte[] b2;
-                JarEntry je = jf.getJarEntry(name);
-                try (InputStream is = jf.getInputStream(je)) {
-                    b2 = is.readAllBytes();
-                }
-                assertEquals(b1,b2);
-            }
-        }
-    }
-
-    private void delete(String name) throws IOException {
-        Files.deleteIfExists(Paths.get(usr, name));
-    }
-
-    private void deleteDir(Path dir) throws IOException {
-        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
-            @Override
-            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
-                Files.delete(file);
-                return FileVisitResult.CONTINUE;
-            }
-
-            @Override
-            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
-                Files.delete(dir);
-                return FileVisitResult.CONTINUE;
-            }
-        });
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 
-    /*
-     * The following methods were taken from modular jar and other jar tests
-     */
+    @Test
+    public void testCustomManifest() throws Throwable {
+        String jarfile = "test.jar";
 
-    void javac(Path dest, Path... sourceFiles) throws IOException {
-        String javac = JDKToolFinder.getJDKTool("javac");
+        compile("test01");
 
-        List<String> commands = new ArrayList<>();
-        commands.add(javac);
-        String opts = System.getProperty("test.compiler.opts");
-        if (!opts.isEmpty()) {
-            commands.addAll(Arrays.asList(opts.split(" +")));
-        }
-        commands.add("-d");
-        commands.add(dest.toString());
-        Stream.of(sourceFiles).map(Object::toString).forEach(x -> commands.add(x));
+        Path classes = Paths.get("classes");
+        Path manifest = Paths.get("Manifest.txt");
 
-        quickFail(run(new ProcessBuilder(commands)));
-    }
+        // create
+        Files.write(manifest, "Class-Path: MyUtils.jar\n".getBytes());
 
-    Result jarWithStdin(File stdinSource, String... args) {
-        String jar = JDKToolFinder.getJDKTool("jar");
-        List<String> commands = new ArrayList<>();
-        commands.add(jar);
-        commands.addAll(Utils.getForwardVmOptions());
-        Stream.of(args).forEach(x -> commands.add(x));
-        ProcessBuilder p = new ProcessBuilder(commands);
-        if (stdinSource != null)
-            p.redirectInput(stdinSource);
-        return run(p);
-    }
+        jar("cfm", jarfile, manifest.toString(),
+                "-C", classes.resolve("base").toString(), ".",
+                "--release", "10", "-C", classes.resolve("v10").toString(), ".")
+                .shouldHaveExitValue(SUCCESS)
+                .shouldBeEmpty();
 
-    Result jar(String... args) {
-        return jarWithStdin(null, args);
-    }
-
-    void quickFail(Result r) {
-        if (r.ec != 0)
-            throw new RuntimeException(r.output);
-    }
-
-    Result run(ProcessBuilder pb) {
-        Process p;
-        out.printf("Running: %s%n", pb.command());
-        try {
-            p = pb.start();
-        } catch (IOException e) {
-            throw new RuntimeException(
-                    format("Couldn't start process '%s'", pb.command()), e);
+        try (JarFile jf = new JarFile(new File(jarfile), true,
+                ZipFile.OPEN_READ, JarFile.runtimeVersion())) {
+            assertTrue(jf.isMultiRelease(), "Not multi-release jar");
+            assertEquals(jf.getManifest()
+                            .getMainAttributes()
+                            .getValue("Class-Path"),
+                    "MyUtils.jar");
         }
 
-        String output;
-        try {
-            output = toString(p.getInputStream(), p.getErrorStream());
-        } catch (IOException e) {
-            throw new RuntimeException(
-                    format("Couldn't read process output '%s'", pb.command()), e);
+        // update
+        Files.write(manifest, "Multi-release: false\n".getBytes());
+
+        jar("ufm", jarfile, manifest.toString(),
+                "-C", classes.resolve("base").toString(), ".",
+                "--release", "9", "-C", classes.resolve("v10").toString(), ".")
+                .shouldHaveExitValue(SUCCESS)
+                .shouldContain("WARNING: Duplicate name in Manifest: Multi-release.");
+
+        try (JarFile jf = new JarFile(new File(jarfile), true,
+                ZipFile.OPEN_READ, JarFile.runtimeVersion())) {
+            assertTrue(jf.isMultiRelease(), "Not multi-release jar");
+            assertEquals(jf.getManifest()
+                            .getMainAttributes()
+                            .getValue("Class-Path"),
+                    "MyUtils.jar");
         }
 
-        try {
-            p.waitFor();
-        } catch (InterruptedException e) {
-            throw new RuntimeException(
-                    format("Process hasn't finished '%s'", pb.command()), e);
-        }
-        return new Result(p.exitValue(), output);
-    }
-
-    String toString(InputStream in1, InputStream in2) throws IOException {
-        try (ByteArrayOutputStream dst = new ByteArrayOutputStream();
-             InputStream concatenated = new SequenceInputStream(in1, in2)) {
-            concatenated.transferTo(dst);
-            return new String(dst.toByteArray(), "UTF-8");
-        }
-    }
-
-    static class Result {
-        final int ec;
-        final String output;
-
-        private Result(int ec, String output) {
-            this.ec = ec;
-            this.output = output;
-        }
-
-        boolean outputContains(String msg) {
-            return Arrays.stream(output.split("\\R"))
-                         .collect(Collectors.joining(" "))
-                         .contains(msg);
-        }
-
-        Result assertSuccess() {
-            assertTrue(ec == 0, format("ec: %d, output: %s", ec, output));
-            return this;
-        }
-        Result assertFailure() {
-            assertTrue(ec != 0, format("ec: %d, output: %s", ec, output));
-            return this;
-        }
-        Result resultChecker(Consumer<Result> r) { r.accept(this); return this; }
+        FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
+        FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
     }
 }
--- a/jdk/test/tools/jar/multiRelease/Basic1.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jar/multiRelease/Basic1.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,218 +28,86 @@
  *          jdk.compiler
  *          jdk.jartool
  * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils
+ * @build MRTestBase
  * @run testng Basic1
  */
 
-import static org.testng.Assert.*;
-
 import org.testng.annotations.*;
 
-import java.io.*;
 import java.nio.file.*;
 import java.util.*;
-import java.util.function.Consumer;
-import java.util.jar.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.zip.*;
 
-import jdk.test.lib.JDKToolFinder;
-import jdk.test.lib.Utils;
-
-
-import static java.lang.String.format;
-import static java.lang.System.out;
-
-public class Basic1 {
-    private final String src = System.getProperty("test.src", ".");
+public class Basic1 extends MRTestBase {
 
     @BeforeTest
-    public void setup() throws IOException {
+    public void setup() throws Throwable {
         String test = "test01";
-        Path classes = Paths.get("classes", "base");
-        Files.createDirectories(classes);
+        Path classes = Paths.get("classes");
+
+        Path base = classes.resolve("base");
+        Files.createDirectories(base);
         Path source = Paths.get(src, "data", test, "base", "version");
-        javac(classes, source.resolve("Main.java"), source.resolve("Version.java"));
+        javac(base, source.resolve("Main.java"), source.resolve("Version.java"));
 
-        Path v9 = Paths.get("v9").resolve("META-INF").resolve("versions").resolve("9");
+        Path v9 = classes.resolve("v9");
         Files.createDirectories(v9);
         source = Paths.get(src, "data", test, "v9", "version");
         javac(v9, source.resolve("Version.java"));
 
-        Path v10 = Paths.get("v10").resolve("META-INF").resolve("versions").resolve("10");
+        Path v10 = classes.resolve("v10");
         Files.createDirectories(v10);
         source = Paths.get(src, "data", test, "v10", "version");
         javac(v10, source.resolve("Version.java"));
+
+        Path v10_1 = classes.resolve("v10_1").resolve("META-INF").resolve("versions").resolve("v10");
+        Files.createDirectories(v10_1);
+        source = Paths.get(src, "data", test, "v10", "version");
+        javac(v10_1, source.resolve("Version.java"));
     }
 
     @Test
-    public void test() throws IOException {
+    public void test() throws Throwable {
         String jarfile = "test.jar";
         Path classes = Paths.get("classes");
-        Path v9 = Paths.get("v9");
-        Path v10 = Paths.get("v10");
+
+        Path base = classes.resolve("base");
+        Path v9 = classes.resolve("v9");
+        Path v10 = classes.resolve("v10");
 
-        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
-            "--release", "9", "-C", v9.toString(), ".",
-            "--release", "10", "-C", v10.toString(), ".")
-            .assertSuccess();
+        jar("cf", jarfile, "-C", base.toString(), ".",
+                "--release", "9", "-C", v9.toString(), ".",
+                "--release", "10", "-C", v10.toString(), ".")
+                .shouldHaveExitValue(SUCCESS);
 
         checkMultiRelease(jarfile, true);
 
-        Map<String,String[]> names = Map.of(
-            "version/Main.class",
-            new String[] {"classes", "base", "version", "Main.class"},
+        Map<String, String[]> names = Map.of(
+                "version/Main.class",
+                new String[]{"base", "version", "Main.class"},
 
-            "version/Version.class",
-            new String[] {"classes", "base", "version", "Version.class"},
+                "version/Version.class",
+                new String[]{"base", "version", "Version.class"},
 
             "META-INF/versions/9/version/Version.class",
-            new String[] {"v9", "META-INF", "versions", "9", "version", "Version.class"},
+            new String[] {"v9", "version", "Version.class"},
 
             "META-INF/versions/10/version/Version.class",
-            new String[] {"v10", "META-INF", "versions", "10", "version", "Version.class"}
+            new String[] {"v10", "version", "Version.class"}
         );
 
         compare(jarfile, names);
     }
 
     @Test
-    public void testFail() throws IOException {
+    public void testFail() throws Throwable {
         String jarfile = "test.jar";
         Path classes = Paths.get("classes");
-        Path v9 = Paths.get("v9");
-        Path v10 = Paths.get("v10");
-
-        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
-            "--release", "9", "-C", v10.toString(), ".")
-            .assertFailure()
-            .outputContains("unexpected versioned entry META-INF/versions/");
-    }
-
-    private void checkMultiRelease(String jarFile, boolean expected) throws IOException {
-        try (JarFile jf = new JarFile(new File(jarFile), true, ZipFile.OPEN_READ,
-                JarFile.runtimeVersion())) {
-            assertEquals(jf.isMultiRelease(), expected);
-        }
-    }
-
-    // compares the bytes found in the jar entries with the bytes found in the
-    // corresponding data files used to create the entries
-    private void compare(String jarfile, Map<String,String[]> names) throws IOException {
-        try (JarFile jf = new JarFile(jarfile)) {
-            for (String name : names.keySet()) {
-                Path path = Paths.get("", names.get(name));
-                byte[] b1 = Files.readAllBytes(path);
-                byte[] b2;
-                JarEntry je = jf.getJarEntry(name);
-                try (InputStream is = jf.getInputStream(je)) {
-                    b2 = is.readAllBytes();
-                }
-                assertEquals(b1,b2);
-            }
-        }
-    }
-
-    /*
-     * The following methods were taken from modular jar and other jar tests
-     */
-
-    void javac(Path dest, Path... sourceFiles) throws IOException {
-        String javac = JDKToolFinder.getJDKTool("javac");
-
-        List<String> commands = new ArrayList<>();
-        commands.add(javac);
-        String opts = System.getProperty("test.compiler.opts");
-        if (!opts.isEmpty()) {
-            commands.addAll(Arrays.asList(opts.split(" +")));
-        }
-        commands.add("-d");
-        commands.add(dest.toString());
-        Stream.of(sourceFiles).map(Object::toString).forEach(x -> commands.add(x));
-
-        quickFail(run(new ProcessBuilder(commands)));
-    }
-
-    Result jarWithStdin(File stdinSource, String... args) {
-        String jar = JDKToolFinder.getJDKTool("jar");
-        List<String> commands = new ArrayList<>();
-        commands.add(jar);
-        commands.addAll(Utils.getForwardVmOptions());
-        Stream.of(args).forEach(x -> commands.add(x));
-        ProcessBuilder p = new ProcessBuilder(commands);
-        if (stdinSource != null)
-            p.redirectInput(stdinSource);
-        return run(p);
-    }
+        Path base = classes.resolve("base");
+        Path v10 = classes.resolve("v10_1");
 
-    Result jar(String... args) {
-        return jarWithStdin(null, args);
-    }
-
-    void quickFail(Result r) {
-        if (r.ec != 0)
-            throw new RuntimeException(r.output);
-    }
-
-    Result run(ProcessBuilder pb) {
-        Process p;
-        out.printf("Running: %s%n", pb.command());
-        try {
-            p = pb.start();
-        } catch (IOException e) {
-            throw new RuntimeException(
-                    format("Couldn't start process '%s'", pb.command()), e);
-        }
-
-        String output;
-        try {
-            output = toString(p.getInputStream(), p.getErrorStream());
-        } catch (IOException e) {
-            throw new RuntimeException(
-                    format("Couldn't read process output '%s'", pb.command()), e);
-        }
-
-        try {
-            p.waitFor();
-        } catch (InterruptedException e) {
-            throw new RuntimeException(
-                    format("Process hasn't finished '%s'", pb.command()), e);
-        }
-        return new Result(p.exitValue(), output);
-    }
-
-    String toString(InputStream in1, InputStream in2) throws IOException {
-        try (ByteArrayOutputStream dst = new ByteArrayOutputStream();
-             InputStream concatenated = new SequenceInputStream(in1, in2)) {
-            concatenated.transferTo(dst);
-            return new String(dst.toByteArray(), "UTF-8");
-        }
-    }
-
-    static class Result {
-        final int ec;
-        final String output;
-
-        private Result(int ec, String output) {
-            this.ec = ec;
-            this.output = output;
-        }
-
-        boolean outputContains(String msg) {
-            return Arrays.stream(output.split("\\R"))
-                         .collect(Collectors.joining(" "))
-                         .contains(msg);
-        }
-
-        Result assertSuccess() {
-            assertTrue(ec == 0, format("ec: %d, output: %s", ec, output));
-            return this;
-        }
-        Result assertFailure() {
-            assertTrue(ec != 0, format("ec: %d, output: %s", ec, output));
-            return this;
-        }
-        Result resultChecker(Consumer<Result> r) { r.accept(this); return this; }
+        jar("cf", jarfile, "-C", base.toString(), ".",
+                "--release", "10", "-C", v10.toString(), ".")
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("unexpected versioned entry META-INF/versions/");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/multiRelease/MRTestBase.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.*;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.stream.Stream;
+import java.util.zip.ZipFile;
+
+import static org.testng.Assert.assertEquals;
+
+public class MRTestBase {
+
+    public static final int SUCCESS = 0;
+
+    protected final String src = System.getProperty("test.src", ".");
+    protected final String usr = System.getProperty("user.dir", ".");
+
+    protected void compile(String test) throws Throwable {
+        Path classes = Paths.get(usr, "classes", "base");
+        Files.createDirectories(classes);
+        Path source = Paths.get(src, "data", test, "base", "version");
+        javac(classes, source.resolve("Main.java"), source.resolve("Version.java"));
+
+        classes = Paths.get(usr, "classes", "v9");
+        Files.createDirectories(classes);
+        source = Paths.get(src, "data", test, "v9", "version");
+        javac(classes, source.resolve("Version.java"));
+
+        classes = Paths.get(usr, "classes", "v10");
+        Files.createDirectories(classes);
+        source = Paths.get(src, "data", test, "v10", "version");
+        javac(classes, source.resolve("Version.java"));
+    }
+
+    protected void checkMultiRelease(String jarFile,
+                                     boolean expected) throws IOException {
+        try (JarFile jf = new JarFile(new File(jarFile), true,
+                ZipFile.OPEN_READ, JarFile.runtimeVersion())) {
+            assertEquals(jf.isMultiRelease(), expected);
+        }
+    }
+
+    // compares the bytes found in the jar entries with the bytes found in the
+    // corresponding data files used to create the entries
+    protected void compare(String jarfile,
+                           Map<String, String[]> names) throws IOException {
+        try (JarFile jf = new JarFile(jarfile)) {
+            for (String name : names.keySet()) {
+                Path path = Paths.get("classes", names.get(name));
+                byte[] b1 = Files.readAllBytes(path);
+                byte[] b2;
+                JarEntry je = jf.getJarEntry(name);
+                try (InputStream is = jf.getInputStream(je)) {
+                    b2 = is.readAllBytes();
+                }
+                assertEquals(b1, b2);
+            }
+        }
+    }
+
+    void javac(Path dest, Path... sourceFiles) throws Throwable {
+        String javac = JDKToolFinder.getJDKTool("javac");
+
+        List<String> commands = new ArrayList<>();
+        commands.add(javac);
+        String opts = System.getProperty("test.compiler.opts");
+        if (!opts.isEmpty()) {
+            commands.addAll(Arrays.asList(opts.split(" +")));
+        }
+        commands.addAll(Utils.getForwardVmOptions());
+        commands.add("-d");
+        commands.add(dest.toString());
+        Stream.of(sourceFiles)
+                .map(Object::toString)
+                .forEach(x -> commands.add(x));
+
+        ProcessTools.executeCommand(new ProcessBuilder(commands))
+                .shouldHaveExitValue(SUCCESS);
+    }
+
+    OutputAnalyzer jarWithStdin(File stdinSource,
+                                String... args) throws Throwable {
+
+        String jar = JDKToolFinder.getJDKTool("jar");
+        List<String> commands = new ArrayList<>();
+        commands.add(jar);
+        commands.addAll(Utils.getForwardVmOptions());
+        Stream.of(args).forEach(x -> commands.add(x));
+        ProcessBuilder p = new ProcessBuilder(commands);
+        if (stdinSource != null)
+            p.redirectInput(stdinSource);
+        return ProcessTools.executeCommand(p);
+    }
+
+    OutputAnalyzer jar(String... args) throws Throwable {
+        return jarWithStdin(null, args);
+    }
+}
\ No newline at end of file
--- a/jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java	Tue Jan 24 00:30:25 2017 +0100
@@ -8,7 +8,7 @@
     protected void doNothing() {
     }
 
-    // extra publc method
+    // extra public method
     public void anyName() {
     }
 }
--- a/jdk/test/tools/jlink/DefaultProviderTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/DefaultProviderTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -44,6 +44,7 @@
  * @modules java.base/jdk.internal.jimage
  *          jdk.jdeps/com.sun.tools.classfile
  *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          jdk.jlink/jdk.tools.jmod
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
--- a/jdk/test/tools/jlink/ImageFileCreatorTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/ImageFileCreatorTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -48,6 +48,7 @@
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.builder
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          java.base/jdk.internal.jimage
  * @run main/othervm -verbose:gc -Xmx1g ImageFileCreatorTest
  */
--- a/jdk/test/tools/jlink/ImageFilePoolTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/ImageFilePoolTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -26,6 +26,7 @@
  * @summary Test a pool containing external files.
  * @author Andrei Eremeev
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  * @run build ImageFilePoolTest
  * @run main ImageFilePoolTest
  */
--- a/jdk/test/tools/jlink/IntegrationTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/IntegrationTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -62,6 +62,7 @@
  *          jdk.jlink/jdk.tools.jlink.builder
  *          jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          jdk.jlink/jdk.tools.jmod
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
--- a/jdk/test/tools/jlink/JLink2Test.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/JLink2Test.java	Tue Jan 24 00:30:25 2017 +0100
@@ -29,6 +29,7 @@
  * @modules java.base/jdk.internal.jimage
  *          jdk.jdeps/com.sun.tools.classfile
  *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          jdk.jlink/jdk.tools.jmod
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
--- a/jdk/test/tools/jlink/JLinkOptionsTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/JLinkOptionsTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -39,6 +39,7 @@
  * @modules java.base/jdk.internal.jimage
  *          jdk.jdeps/com.sun.tools.classfile
  *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          jdk.jlink/jdk.tools.jmod
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
--- a/jdk/test/tools/jlink/JLinkPostProcessingTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/JLinkPostProcessingTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -46,6 +46,7 @@
  * @modules java.base/jdk.internal.jimage
  *          jdk.jdeps/com.sun.tools.classfile
  *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          jdk.jlink/jdk.tools.jmod
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
--- a/jdk/test/tools/jlink/JLinkTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/JLinkTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -48,6 +48,7 @@
  * @modules java.base/jdk.internal.jimage
  *          jdk.jdeps/com.sun.tools.classfile
  *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
  * @build tests.*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/ResourceDuplicateCheckTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8168254
+ * @summary Detect duplicated resources in packaged modules
+ * @modules jdk.jlink/jdk.tools.jlink.builder
+ *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
+ * @run build ResourceDuplicateCheckTest
+ * @run main ResourceDuplicateCheckTest
+ */
+
+import java.net.URI;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import jdk.tools.jlink.builder.DefaultImageBuilder;
+import jdk.tools.jlink.internal.ResourcePoolEntryFactory;
+import jdk.tools.jlink.internal.ResourcePoolManager;
+import jdk.tools.jlink.plugin.PluginException;
+import jdk.tools.jlink.plugin.ResourcePoolEntry;
+
+public class ResourceDuplicateCheckTest {
+    public static void main(String[] args) throws Exception {
+        new ResourceDuplicateCheckTest().test();
+    }
+
+    public void test() throws Exception {
+        ResourcePoolManager input = new ResourcePoolManager();
+        // need java.base module info because OS name is retrieved from it from storeFiles
+        input.add(ResourcePoolEntryFactory.create("/java.base/module-info.class",
+                    ResourcePoolEntry.Type.CLASS_OR_RESOURCE, getJavaBaseModuleInfo()));
+
+        // same NATIVE_CMD from two different modules
+        input.add(newInMemoryImageFile("/com.acme/bin/myexec",
+                    ResourcePoolEntry.Type.NATIVE_CMD, "mylib"));
+        input.add(newInMemoryImageFile("/com.foo/bin/myexec",
+                    ResourcePoolEntry.Type.NATIVE_CMD, "mylib"));
+        Path root = Paths.get(System.getProperty("test.classes"));
+        DefaultImageBuilder writer = new DefaultImageBuilder(root, Collections.emptyMap());
+        try {
+            writer.storeFiles(input.resourcePool());
+        } catch (PluginException pe) {
+            if (! pe.getMessage().contains("Duplicate resources:")) {
+                throw new AssertionError("expected duplicate resources message");
+            }
+        }
+    }
+
+    private byte[] getJavaBaseModuleInfo() throws Exception {
+        Path path = FileSystems.
+                getFileSystem(URI.create("jrt:/")).
+                getPath("/modules/java.base/module-info.class");
+        return Files.readAllBytes(path);
+    }
+
+    private static ResourcePoolEntry newInMemoryImageFile(String path,
+            ResourcePoolEntry.Type type, String content) {
+        return ResourcePoolEntryFactory.create(path, type, content.getBytes());
+    }
+}
--- a/jdk/test/tools/jlink/ResourcePoolTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/ResourcePoolTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -26,6 +26,7 @@
  * @summary Test a pool containing jimage resources and classes.
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  * @run build ResourcePoolTest
  * @run main ResourcePoolTest
  */
--- a/jdk/test/tools/jlink/plugins/CompressorPluginTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/CompressorPluginTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -28,6 +28,7 @@
  * @modules java.base/jdk.internal.jimage.decompressor
  *          jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
+ *          jdk.jlink/jdk.tools.jlink.plugin
  * @run main CompressorPluginTest
  */
 import java.net.URI;
--- a/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -27,6 +27,7 @@
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
+ *          jdk.jlink/jdk.tools.jlink.plugin
  * @run main ExcludeFilesPluginTest
  */
 
--- a/jdk/test/tools/jlink/plugins/ExcludePluginTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/ExcludePluginTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -27,6 +27,7 @@
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
+ *          jdk.jlink/jdk.tools.jlink.plugin
  * @run main ExcludePluginTest
  */
 
--- a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -27,6 +27,7 @@
  * @author Jean-Francois Denise
  * @modules jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
+ *          jdk.jlink/jdk.tools.jlink.plugin
  * @run main ExcludeVMPluginTest
  */
 import java.io.ByteArrayInputStream;
--- a/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -48,6 +48,7 @@
  *          jdk.jdeps/com.sun.tools.classfile
  *          jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          jdk.jlink/jdk.tools.jmod
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
--- a/jdk/test/tools/jlink/plugins/LastSorterTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/LastSorterTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -25,8 +25,9 @@
  * @test
  * @summary Test last sorter property
  * @author Jean-Francois Denise
- * @modules jdk.jlink/jdk.tools.jlink.internal
- *          jdk.jlink/jdk.tools.jlink
+ * @modules jdk.jlink/jdk.tools.jlink
+ *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  * @run main/othervm LastSorterTest
  */
 
--- a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -25,8 +25,9 @@
  * @test
  * @summary Negative test for ImagePluginStack.
  * @author Andrei Eremeev
- * @modules jdk.jlink/jdk.tools.jlink.internal
- *          jdk.jlink/jdk.tools.jlink
+ * @modules jdk.jlink/jdk.tools.jlink
+ *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  * @run main/othervm PluginsNegativeTest
  */
 import java.lang.reflect.Layer;
--- a/jdk/test/tools/jlink/plugins/PrevisitorTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/PrevisitorTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -25,8 +25,9 @@
  * @test
  * @summary Test previsitor
  * @author Andrei Eremeev
- * @modules jdk.jlink/jdk.tools.jlink.internal
- *          jdk.jlink/jdk.tools.jlink
+ * @modules jdk.jlink/jdk.tools.jlink
+ *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.plugin
  * @run main/othervm PrevisitorTest
  */
 import java.nio.ByteOrder;
--- a/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -30,6 +30,7 @@
  *          java.base/jdk.internal.jimage.decompressor
  *          jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          jdk.jlink/jdk.tools.jmod
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.jdeps/com.sun.tools.classfile
--- a/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -30,6 +30,7 @@
  * @modules java.base/jdk.internal.jimage
  *          jdk.jlink/jdk.tools.jlink.internal
  *          jdk.jlink/jdk.tools.jlink.internal.plugins
+ *          jdk.jlink/jdk.tools.jlink.plugin
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.jlink/jdk.tools.jmod
  *          jdk.jdeps/com.sun.tools.classfile
--- a/jdk/test/tools/jmod/JmodTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jmod/JmodTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -23,13 +23,13 @@
 
 /*
  * @test
- * @bug 8142968 8166568 8166286 8170618
+ * @bug 8142968 8166568 8166286 8170618 8168149
  * @summary Basic test for jmod
  * @library /lib/testlibrary
  * @modules jdk.compiler
  *          jdk.jlink
  * @build jdk.testlibrary.FileUtils CompilerUtils
- * @run testng JmodTest
+ * @run testng/othervm -Djava.io.tmpdir=. JmodTest
  */
 
 import java.io.*;
@@ -40,6 +40,7 @@
 import java.util.function.Consumer;
 import java.util.regex.Pattern;
 import java.util.spi.ToolProvider;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import jdk.testlibrary.FileUtils;
 import org.testng.annotations.BeforeTest;
@@ -459,6 +460,76 @@
     }
 
     @Test
+    public void testLastOneWins() throws IOException {
+        Path workDir = Paths.get("lastOneWins");
+        if (Files.exists(workDir))
+            FileUtils.deleteFileTreeWithRetry(workDir);
+        Files.createDirectory(workDir);
+        Path jmod = MODS_DIR.resolve("lastOneWins.jmod");
+        FileUtils.deleteFileIfExistsWithRetry(jmod);
+        Path cp = EXPLODED_DIR.resolve("foo").resolve("classes");
+        Path bp = EXPLODED_DIR.resolve("foo").resolve("bin");
+        Path lp = EXPLODED_DIR.resolve("foo").resolve("lib");
+        Path cf = EXPLODED_DIR.resolve("foo").resolve("conf");
+
+        Path shouldNotBeAdded = workDir.resolve("shouldNotBeAdded");
+        Files.createDirectory(shouldNotBeAdded);
+        Files.write(shouldNotBeAdded.resolve("aFile"), "hello".getBytes(UTF_8));
+
+        // Pairs of options. For options with required arguments the last one
+        // should win ( first should be effectively ignored, but may still be
+        // validated ).
+        jmod("create",
+             "--conf", shouldNotBeAdded.toString(),
+             "--conf", cf.toString(),
+             "--cmds", shouldNotBeAdded.toString(),
+             "--cmds", bp.toString(),
+             "--libs", shouldNotBeAdded.toString(),
+             "--libs", lp.toString(),
+             "--class-path", shouldNotBeAdded.toString(),
+             "--class-path", cp.toString(),
+             "--main-class", "does.NotExist",
+             "--main-class", "jdk.test.foo.Foo",
+             "--module-version", "00001",
+             "--module-version", "5.4.3",
+             "--do-not-resolve-by-default",
+             "--do-not-resolve-by-default",
+             "--warn-if-resolved=incubating",
+             "--warn-if-resolved=deprecated",
+             MODS_DIR.resolve("lastOneWins.jmod").toString())
+            .assertSuccess()
+            .resultChecker(r -> {
+                ModuleDescriptor md = getModuleDescriptor(jmod);
+                Optional<String> omc = md.mainClass();
+                assertTrue(omc.isPresent());
+                assertEquals(omc.get(), "jdk.test.foo.Foo");
+                Optional<Version> ov = md.version();
+                assertTrue(ov.isPresent());
+                assertEquals(ov.get().toString(), "5.4.3");
+
+                try (Stream<String> s1 = findFiles(lp).map(p -> LIBS_PREFIX + p);
+                     Stream<String> s2 = findFiles(cp).map(p -> CLASSES_PREFIX + p);
+                     Stream<String> s3 = findFiles(bp).map(p -> CMDS_PREFIX + p);
+                     Stream<String> s4 = findFiles(cf).map(p -> CONFIGS_PREFIX + p)) {
+                    Set<String> expectedFilenames = Stream.concat(Stream.concat(s1,s2),
+                                                                  Stream.concat(s3, s4))
+                                                          .collect(toSet());
+                    assertJmodContent(jmod, expectedFilenames);
+                }
+            });
+
+        jmod("extract",
+             "--dir", "blah",
+             "--dir", "lastOneWinsExtractDir",
+             jmod.toString())
+            .assertSuccess()
+            .resultChecker(r -> {
+                assertTrue(Files.exists(Paths.get("lastOneWinsExtractDir")));
+                assertTrue(Files.notExists(Paths.get("blah")));
+            });
+    }
+
+    @Test
     public void testPackagesAttribute() throws IOException {
         Path jmod = MODS_DIR.resolve("foo.jmod");
         FileUtils.deleteFileIfExistsWithRetry(jmod);
@@ -510,34 +581,13 @@
     }
 
     @Test
-    public void testTmpFileAlreadyExists() throws IOException {
-        // Implementation detail: jmod tool creates <jmod-file>.tmp
-        // Ensure that there are no problems if existing
-
-        Path jmod = MODS_DIR.resolve("testTmpFileAlreadyExists.jmod");
-        Path tmp = MODS_DIR.resolve("testTmpFileAlreadyExists.jmod.tmp");
-        FileUtils.deleteFileIfExistsWithRetry(jmod);
-        FileUtils.deleteFileIfExistsWithRetry(tmp);
-        Files.createFile(tmp);
-        String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString();
-
-        jmod("create",
-             "--class-path", cp,
-             jmod.toString())
-            .assertSuccess()
-            .resultChecker(r ->
-                assertTrue(Files.notExists(tmp), "Unexpected tmp file:" + tmp)
-            );
-    }
-
-    @Test
     public void testTmpFileRemoved() throws IOException {
         // Implementation detail: jmod tool creates <jmod-file>.tmp
         // Ensure that it is removed in the event of a failure.
         // The failure in this case is a class in the unnamed package.
 
         Path jmod = MODS_DIR.resolve("testTmpFileRemoved.jmod");
-        Path tmp = MODS_DIR.resolve("testTmpFileRemoved.jmod.tmp");
+        Path tmp = MODS_DIR.resolve(".testTmpFileRemoved.jmod.tmp");
         FileUtils.deleteFileIfExistsWithRetry(jmod);
         FileUtils.deleteFileIfExistsWithRetry(tmp);
         String cp = EXPLODED_DIR.resolve("foo").resolve("classes") + File.pathSeparator +
@@ -547,11 +597,11 @@
         jmod("create",
              "--class-path", cp,
              jmod.toString())
-             .assertFailure()
-             .resultChecker(r -> {
-                 assertContains(r.output, "unnamed package");
-                 assertTrue(Files.notExists(tmp), "Unexpected tmp file:" + tmp);
-             });
+            .assertFailure()
+            .resultChecker(r -> {
+                assertContains(r.output, "unnamed package");
+                assertTrue(Files.notExists(tmp), "Unexpected tmp file:" + tmp);
+            });
     }
 
     // ---
--- a/jdk/test/tools/jmod/hashes/HashesTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/jmod/hashes/HashesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,19 +23,22 @@
 
 /*
  * @test
+ * @bug 8160286
  * @summary Test the recording and checking of module hashes
- * @author Andrei Eremeev
  * @library /lib/testlibrary
  * @modules java.base/jdk.internal.misc
  *          java.base/jdk.internal.module
+ *          jdk.compiler
+ *          jdk.jartool
  *          jdk.jlink
- *          jdk.compiler
- * @build CompilerUtils
+ * @build CompilerUtils ModuleInfoMaker
  * @run testng HashesTest
  */
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UncheckedIOException;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReader;
@@ -53,109 +56,311 @@
 import java.util.Set;
 import java.util.spi.ToolProvider;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import jdk.internal.module.ModuleInfo;
 import jdk.internal.module.ModuleHashes;
 import jdk.internal.module.ModulePath;
 
-import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
 import static org.testng.Assert.*;
+import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;
 
 public class HashesTest {
     static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
         .orElseThrow(() ->
             new RuntimeException("jmod tool not found")
         );
+    static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+        .orElseThrow(() ->
+            new RuntimeException("jar tool not found")
+        );
 
-    private final Path testSrc = Paths.get(System.getProperty("test.src"));
-    private final Path modSrc = testSrc.resolve("src");
-    private final Path mods = Paths.get("mods");
-    private final Path jmods = Paths.get("jmods");
-    private final String[] modules = new String[] { "m1", "m2", "m3"};
+    private final Path mods;
+    private final Path srcDir;
+    private final Path lib;
+    private final ModuleInfoMaker builder;
+    HashesTest(Path dest) throws IOException {
+        if (Files.exists(dest)) {
+            deleteDirectory(dest);
+        }
+        this.mods = dest.resolve("mods");
+        this.srcDir = dest.resolve("src");
+        this.lib = dest.resolve("lib");
+        this.builder = new ModuleInfoMaker(srcDir);
+
+        Files.createDirectories(lib);
+        Files.createDirectories(mods);
+    }
+
+    @Test
+    public static void test() throws IOException {
+        Path dest = Paths.get("test");
+        HashesTest ht = new HashesTest(dest);
 
-    @BeforeTest
-    private void setup() throws Exception {
-        if (Files.exists(jmods)) {
-            deleteDirectory(jmods);
-        }
-        Files.createDirectories(jmods);
+        // create modules for test cases
+        ht.makeModule("m2");
+        ht.makeModule("m3");
+        ht.makeModule("m1", "m2", "m3");
+
+        ht.makeModule("org.bar", TRANSITIVE, "m1");
+        ht.makeModule("org.foo", TRANSITIVE, "org.bar");
+
+        // create JMOD for m1, m2, m3
+        ht.makeJmod("m2");
+        ht.makeJmod("m3");
+
+        // no hash is recorded since m1 has outgoing edges
+        ht.jmodHashModules("m1", ".*");
+
+        // no hash is recorded in m1, m2, m3
+        assertTrue(ht.hashes("m1") == null);
+        assertTrue(ht.hashes("m2") == null);
+        assertTrue(ht.hashes("m3") == null);
+
+        // hash m1 in m2
+        ht.jmodHashModules("m2",  "m1");
+        ht.checkHashes("m2", "m1");
+
+        // hash m1 in m2
+        ht.jmodHashModules("m2",  ".*");
+        ht.checkHashes("m2", "m1");
 
-        // build m2, m3 required by m1
-        compileModule("m2", modSrc);
-        jmod("m2");
+        // create m2.jmod with no hash
+        ht.makeJmod("m2");
+        // run jmod hash command to hash m1 in m2 and m3
+        runJmod(List.of("hash", "--module-path", ht.lib.toString(),
+                        "--hash-modules", ".*"));
+        ht.checkHashes("m2", "m1");
+        ht.checkHashes("m3", "m1");
+
+        // check transitive requires
+        ht.makeJmod("org.bar");
+        ht.makeJmod("org.foo");
 
-        compileModule("m3", modSrc);
-        jmod("m3");
+        ht.jmodHashModules("org.bar", "org.*");
+        ht.checkHashes("org.bar", "org.foo");
+
+        ht.jmodHashModules( "m3", ".*");
+        ht.checkHashes("m3", "org.foo", "org.bar", "m1");
+    }
+
+    @Test
+    public static void multiBaseModules() throws IOException {
+        Path dest = Paths.get("test2");
+        HashesTest ht = new HashesTest(dest);
 
-        // build m1
-        compileModule("m1", modSrc);
-        // no hash is recorded since m1 has outgoing edges
-        jmod("m1", "--module-path", jmods.toString(), "--hash-modules", ".*");
+        /*
+         * y2 -----------> y1
+         *    |______
+         *    |      |
+         *    V      V
+         *    z3 -> z2
+         *    |      |
+         *    |      V
+         *    |---> z1
+         */
+
+        ht.makeModule("z1");
+        ht.makeModule("z2", "z1");
+        ht.makeModule("z3", "z1", "z2");
+
+        ht.makeModule("y1");
+        ht.makeModule("y2", "y1", "z2", "z3");
 
-        // compile org.bar and org.foo
-        compileModule("org.bar", modSrc);
-        compileModule("org.foo", modSrc);
+        Set<String> ys = Set.of("y1", "y2");
+        Set<String> zs = Set.of("z1", "z2", "z3");
+
+        // create JMOD files
+        Stream.concat(ys.stream(), zs.stream()).forEach(ht::makeJmod);
+
+        // run jmod hash command
+        runJmod(List.of("hash", "--module-path", ht.lib.toString(),
+                        "--hash-modules", ".*"));
+
+        /*
+         * z1 and y1 are the modules with hashes recorded.
+         */
+        ht.checkHashes("y1", "y2");
+        ht.checkHashes("z1", "z2", "z3", "y2");
+        Stream.concat(ys.stream(), zs.stream())
+              .filter(mn -> !mn.equals("y1") && !mn.equals("z1"))
+              .forEach(mn -> assertTrue(ht.hashes(mn) == null));
     }
 
     @Test
-    public void test() throws Exception {
-        for (String mn : modules) {
-            assertTrue(hashes(mn) == null);
+    public static void mixJmodAndJarFile() throws IOException {
+        Path dest = Paths.get("test3");
+        HashesTest ht = new HashesTest(dest);
+
+        /*
+         * j3 -----------> j2
+         *    |______
+         *    |      |
+         *    V      V
+         *    m3 -> m2
+         *    |      |
+         *    |      V
+         *    |---> m1 -> j1 -> jdk.jlink
+         */
+
+        ht.makeModule("j1");
+        ht.makeModule("j2");
+        ht.makeModule("m1", "j1");
+        ht.makeModule("m2", "m1");
+        ht.makeModule("m3", "m1", "m2");
+
+        ht.makeModule("j3", "j2", "m2", "m3");
+
+        Set<String> jars = Set.of("j1", "j2", "j3");
+        Set<String> jmods = Set.of("m1", "m2", "m3");
+
+        // create JMOD and JAR files
+        jars.forEach(ht::makeJar);
+        jmods.forEach(ht::makeJmod);
+
+        // run jmod hash command
+        runJmod(List.of("hash", "--module-path", ht.lib.toString(),
+                        "--hash-modules", "^j.*|^m.*"));
+
+        /*
+         * j1 and j2 are the modules with hashes recorded.
+         */
+        ht.checkHashes("j2", "j3");
+        ht.checkHashes("j1", "m1", "m2", "m3", "j3");
+        Stream.concat(jars.stream(), jmods.stream())
+              .filter(mn -> !mn.equals("j1") && !mn.equals("j2"))
+              .forEach(mn -> assertTrue(ht.hashes(mn) == null));
+    }
+
+    @Test
+    public static void upgradeableModule() throws IOException {
+        Path mpath = Paths.get(System.getProperty("java.home"), "jmods");
+        if (!Files.exists(mpath)) {
+            return;
         }
 
-        // hash m1 in m2
-        jmod("m2", "--module-path", jmods.toString(), "--hash-modules", "m1");
-        checkHashes(hashes("m2"), "m1");
-
-        // hash m1 in m2
-        jmod("m2", "--module-path", jmods.toString(), "--hash-modules", ".*");
-        checkHashes(hashes("m2"), "m1");
+        Path dest = Paths.get("test4");
+        HashesTest ht = new HashesTest(dest);
+        ht.makeModule("m1");
+        ht.makeModule("java.xml.bind", "m1");
+        ht.makeModule("java.xml.ws", "java.xml.bind");
+        ht.makeModule("m2", "java.xml.ws");
 
-        // create m2.jmod with no hash
-        jmod("m2");
-        // run jmod hash command to hash m1 in m2 and m3
-        runJmod(Arrays.asList("hash", "--module-path", jmods.toString(),
-                "--hash-modules", ".*"));
-        checkHashes(hashes("m2"), "m1");
-        checkHashes(hashes("m3"), "m1");
+        ht.makeJmod("m1");
+        ht.makeJmod("m2");
+        ht.makeJmod("java.xml.ws");
+        ht.makeJmod("java.xml.bind",
+                    "--module-path",
+                    ht.lib.toString() + File.pathSeparator + mpath,
+                    "--hash-modules", "^java.xml.*|^m.*");
 
-        jmod("org.bar");
-        jmod("org.foo");
-
-        jmod("org.bar", "--module-path", jmods.toString(), "--hash-modules", "org.*");
-        checkHashes(hashes("org.bar"), "org.foo");
-
-        jmod("m3", "--module-path", jmods.toString(), "--hash-modules", ".*");
-        checkHashes(hashes("m3"), "org.foo", "org.bar", "m1");
+        ht.checkHashes("java.xml.bind", "java.xml.ws", "m2");
     }
 
-    private void checkHashes(ModuleHashes hashes, String... hashModules) {
+    @Test
+    public static void testImageJmods() throws IOException {
+        Path mpath = Paths.get(System.getProperty("java.home"), "jmods");
+        if (!Files.exists(mpath)) {
+            return;
+        }
+
+        Path dest = Paths.get("test5");
+        HashesTest ht = new HashesTest(dest);
+        ht.makeModule("m1", "jdk.compiler", "jdk.attach");
+        ht.makeModule("m2", "m1");
+        ht.makeModule("m3", "java.compiler");
+
+        ht.makeJmod("m1");
+        ht.makeJmod("m2");
+
+        runJmod(List.of("hash",
+                        "--module-path",
+                        mpath.toString() + File.pathSeparator + ht.lib.toString(),
+                        "--hash-modules", ".*"));
+
+        validateImageJmodsTest(ht, mpath);
+    }
+
+    @Test
+    public static void testImageJmods1() throws IOException {
+        Path mpath = Paths.get(System.getProperty("java.home"), "jmods");
+        if (!Files.exists(mpath)) {
+            return;
+        }
+
+        Path dest = Paths.get("test6");
+        HashesTest ht = new HashesTest(dest);
+        ht.makeModule("m1", "jdk.compiler", "jdk.attach");
+        ht.makeModule("m2", "m1");
+        ht.makeModule("m3", "java.compiler");
+
+        ht.makeJar("m2");
+        ht.makeJar("m1",
+                    "--module-path",
+                    mpath.toString() + File.pathSeparator + ht.lib.toString(),
+                    "--hash-modules", ".*");
+        validateImageJmodsTest(ht, mpath);
+    }
+
+    private static void validateImageJmodsTest(HashesTest ht, Path mpath)
+        throws IOException
+    {
+        // hash is recorded in m1 and not any other packaged modules on module path
+        ht.checkHashes("m1", "m2");
+        assertTrue(ht.hashes("m2") == null);
+
+        // should not override any JDK packaged modules
+        ModuleFinder finder = new ModulePath(Runtime.version(),
+                                             true,
+                                             mpath);
+        assertTrue(ht.hashes(finder,"jdk.compiler") == null);
+        assertTrue(ht.hashes(finder,"jdk.attach") == null);
+    }
+
+    private void checkHashes(String mn, String... hashModules) throws IOException {
+        ModuleHashes hashes = hashes(mn);
         assertTrue(hashes.names().equals(Set.of(hashModules)));
     }
 
-    private ModuleHashes hashes(String name) throws Exception {
+    private ModuleHashes hashes(String name) {
         ModuleFinder finder = new ModulePath(Runtime.version(),
                                              true,
-                                             jmods.resolve(name + ".jmod"));
+                                             lib);
+        return hashes(finder, name);
+    }
+
+    private ModuleHashes hashes(ModuleFinder finder, String name) {
         ModuleReference mref = finder.find(name).orElseThrow(RuntimeException::new);
-        ModuleReader reader = mref.open();
-        try (InputStream in = reader.open("module-info.class").get()) {
-            ModuleHashes hashes = ModuleInfo.read(in, null).recordedHashes();
-            System.out.format("hashes in module %s %s%n", name,
+        try {
+            ModuleReader reader = mref.open();
+            try (InputStream in = reader.open("module-info.class").get()) {
+                ModuleHashes hashes = ModuleInfo.read(in, null).recordedHashes();
+                System.out.format("hashes in module %s %s%n", name,
                     (hashes != null) ? "present" : "absent");
-            if (hashes != null) {
-                hashes.names().stream()
-                    .sorted()
-                    .forEach(n -> System.out.format("  %s %s%n", n, hashes.hashFor(n)));
+                if (hashes != null) {
+                    hashes.names().stream().sorted().forEach(n ->
+                        System.out.format("  %s %s%n", n, toHex(hashes.hashFor(n)))
+                    );
+                }
+                return hashes;
+            } finally {
+                reader.close();
             }
-            return hashes;
-        } finally {
-            reader.close();
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
         }
     }
 
+    private String toHex(byte[] ba) {
+        StringBuilder sb = new StringBuilder(ba.length);
+        for (byte b: ba) {
+            sb.append(String.format("%02x", b & 0xff));
+        }
+        return sb.toString();
+    }
+
     private void deleteDirectory(Path dir) throws IOException {
         Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
             @Override
@@ -176,31 +381,94 @@
         });
     }
 
+
+    private void makeModule(String mn, String... deps) throws IOException {
+        makeModule(mn, null, deps);
+    }
+
+    private void makeModule(String mn, ModuleDescriptor.Requires.Modifier mod,  String... deps)
+        throws IOException
+    {
+        if (mod != null && mod != TRANSITIVE && mod != STATIC) {
+            throw new IllegalArgumentException(mod.toString());
+        }
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("module " + mn + " {").append("\n");
+        Arrays.stream(deps).forEach(req -> {
+            sb.append("    requires ");
+            if (mod != null) {
+                sb.append(mod.toString().toLowerCase()).append(" ");
+            }
+            sb.append(req + ";\n");
+        });
+        sb.append("}\n");
+        builder.writeJavaFiles(mn, sb.toString());
+
+        compileModule(mn, srcDir);
+    }
+
     private void compileModule(String moduleName, Path src) throws IOException {
         Path msrc = src.resolve(moduleName);
         assertTrue(CompilerUtils.compile(msrc, mods, "--module-source-path", src.toString()));
     }
 
-    private void jmod(String moduleName, String... options) throws IOException {
+    private void jmodHashModules(String moduleName, String hashModulesPattern) {
+        makeJmod(moduleName, "--module-path", lib.toString(),
+                 "--hash-modules", hashModulesPattern);
+    }
+
+    private void makeJmod(String moduleName, String... options) {
         Path mclasses = mods.resolve(moduleName);
-        Path outfile = jmods.resolve(moduleName + ".jmod");
+        Path outfile = lib.resolve(moduleName + ".jmod");
         List<String> args = new ArrayList<>();
         args.add("create");
         Collections.addAll(args, options);
         Collections.addAll(args, "--class-path", mclasses.toString(),
                            outfile.toString());
 
-        if (Files.exists(outfile))
-            Files.delete(outfile);
-
+        if (Files.exists(outfile)) {
+            try {
+                Files.delete(outfile);
+            } catch (IOException e) {
+                throw new UncheckedIOException(e);
+            }
+        }
         runJmod(args);
     }
 
-    private void runJmod(List<String> args) {
+    private static void runJmod(List<String> args) {
         int rc = JMOD_TOOL.run(System.out, System.out, args.toArray(new String[args.size()]));
-        System.out.println("jmod options: " + args.stream().collect(Collectors.joining(" ")));
+        System.out.println("jmod " + args.stream().collect(Collectors.joining(" ")));
         if (rc != 0) {
-            throw new AssertionError("Jmod failed: rc = " + rc);
+            throw new AssertionError("jmod failed: rc = " + rc);
+        }
+    }
+
+    private void makeJar(String moduleName, String... options) {
+        Path mclasses = mods.resolve(moduleName);
+        Path outfile = lib.resolve(moduleName + ".jar");
+        List<String> args = new ArrayList<>();
+        Stream.concat(Stream.of("--create",
+                                "--file=" + outfile.toString()),
+                      Arrays.stream(options))
+              .forEach(args::add);
+        args.add("-C");
+        args.add(mclasses.toString());
+        args.add(".");
+
+        if (Files.exists(outfile)) {
+            try {
+                Files.delete(outfile);
+            } catch (IOException e) {
+                throw new UncheckedIOException(e);
+            }
+        }
+
+        int rc = JAR_TOOL.run(System.out, System.out, args.toArray(new String[args.size()]));
+        System.out.println("jar " + args.stream().collect(Collectors.joining(" ")));
+        if (rc != 0) {
+            throw new AssertionError("jar failed: rc = " + rc);
         }
     }
 }
--- a/jdk/test/tools/jmod/hashes/src/m1/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m1 {
-    requires m2;
-    requires m3;
-}
--- a/jdk/test/tools/jmod/hashes/src/m1/org/m1/Main.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package org.m1;
-
-import org.m2.Util;
-import org.m3.Name;
-
-public class Main {
-    public static void main(String[] args) {
-        System.out.println(Util.timeOfDay());
-        System.out.println(Name.name());
-    }
-}
--- a/jdk/test/tools/jmod/hashes/src/m2/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m2 {
-    exports org.m2;
-}
--- a/jdk/test/tools/jmod/hashes/src/m2/org/m2/Util.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package org.m2;
-
-public class Util {
-    private Util() { }
-
-    public static String timeOfDay() {
-        return "Time for lunch";
-    }
-}
--- a/jdk/test/tools/jmod/hashes/src/m3/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m3 {
-    exports org.m3;
-}
--- a/jdk/test/tools/jmod/hashes/src/m3/org/m3/Name.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package org.m3;
-
-public class Name {
-    private Name() { }
-
-    public static String name() {
-        return "m3";
-    }
-}
--- a/jdk/test/tools/jmod/hashes/src/org.bar/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +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.
- */
-
-module org.bar {
-    requires transitive m1;
-}
--- a/jdk/test/tools/jmod/hashes/src/org.foo/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +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.
- */
-
-module org.foo {
-    requires transitive org.bar;
-}
--- a/jdk/test/tools/launcher/VersionCheck.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/launcher/VersionCheck.java	Tue Jan 24 00:30:25 2017 +0100
@@ -60,7 +60,6 @@
         "jmc",
         "jmc.ini",
         "jweblauncher",
-        "jvisualvm",
         "packager",
         "ssvagent",
         "unpack200",
@@ -102,7 +101,6 @@
         "jstat",
         "jstatd",
         "jweblauncher",
-        "jvisualvm",
         "keytool",
         "kinit",
         "klist",
--- a/jdk/test/tools/pack200/Utils.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/jdk/test/tools/pack200/Utils.java	Tue Jan 24 00:30:25 2017 +0100
@@ -111,6 +111,7 @@
 
         compiler("-d",
                 XCLASSES.getName(),
+                "--add-modules=jdk.jdeps",
                 "--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED",
                 "@" + tmpFile.getAbsolutePath());
 
--- a/langtools/.hgtags	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/.hgtags	Tue Jan 24 00:30:25 2017 +0100
@@ -394,3 +394,5 @@
 4d4cd7cd731c1952d7330ea5bcfda8bd26820fa5 jdk-9+149
 e5a42ddaf633fde14b983f740ae0e7e490741fd1 jdk-9+150
 4f348bd05341581df84ff1510d5b3a9b5b488367 jdk-9+151
+5b6f12de6f9167a582fa2c6ac54e69c591b09e68 jdk-9+152
+03f48cd283f5dd6b7153fd7e0cf2df8582b14391 jdk-9+153
--- a/langtools/src/java.compiler/share/classes/javax/annotation/processing/Processor.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/annotation/processing/Processor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -243,9 +243,9 @@
      * Returns the names of the annotation types supported by this
      * processor.  An element of the result may be the canonical
      * (fully qualified) name of a supported annotation type.
-     * Alternately it may be of the form &quot;<tt><i>name</i>.*</tt>&quot;
+     * Alternately it may be of the form &quot;<code><i>name</i>.*</code>&quot;
      * representing the set of all annotation types with canonical
-     * names beginning with &quot;<tt><i>name.</i></tt>&quot;.
+     * names beginning with &quot;<code><i>name.</i></code>&quot;.
      *
      * In either of those cases, the name of the annotation type can
      * be optionally preceded by a module name followed by a {@code
@@ -267,13 +267,13 @@
      * <dl>
      * <dt><i>SupportedAnnotationTypeString:</i>
      * <dd><i>ModulePrefix</i><sub><i>opt</i></sub> <i>TypeName</i> <i>DotStar</i><sub><i>opt</i></sub>
-     * <dd><tt>*</tt>
+     * <dd><code>*</code>
      *
      * <dt><i>ModulePrefix:</i>
-     * <dd><i>TypeName</i> <tt>/</tt>
+     * <dd><i>TypeName</i> <code>/</code>
      *
      * <dt><i>DotStar:</i>
-     * <dd><tt>.</tt> <tt>*</tt>
+     * <dd><code>.</code> <code>*</code>
      * </dl>
      * </blockquote>
      *
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
  * implementing this interface are used to operate on a value when the
  * type of that value is unknown at compile time.  When a visitor is
  * passed to a value's {@link AnnotationValue#accept accept} method,
- * the <tt>visit<i>XYZ</i></tt> method applicable to that value is
+ * the <code>visit<i>Xyz</i></code> method applicable to that value is
  * invoked.
  *
  * <p> Classes implementing this interface may or may not throw a
@@ -65,9 +65,9 @@
  * be added in a source <em>compatible</em> way if they were added as
  * <em>default methods</em>.  However, default methods are only
  * available on Java SE 8 and higher releases and the {@code
- * javax.lang.model.*} packages bundled in Java SE 8 are required to
+ * javax.lang.model.*} packages bundled in Java SE 8 were required to
  * also be runnable on Java SE 7.  Therefore, default methods
- * <em>cannot</em> be used when extending {@code javax.lang.model.*}
+ * were <em>not</em> used when extending {@code javax.lang.model.*}
  * to cover Java SE 8 language features.  However, default methods may
  * be used in subsequent revisions of the {@code javax.lang.model.*}
  * packages that are only required to run on Java SE 8 and higher
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
  * pattern.  Classes implementing this interface are used to operate
  * on an element when the kind of element is unknown at compile time.
  * When a visitor is passed to an element's {@link Element#accept
- * accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable
+ * accept} method, the <code>visit<i>Xyz</i></code> method most applicable
  * to that element is invoked.
  *
  * <p> Classes implementing this interface may or may not throw a
@@ -56,9 +56,9 @@
  * be added in a source <em>compatible</em> way if they were added as
  * <em>default methods</em>.  However, default methods are only
  * available on Java SE 8 and higher releases and the {@code
- * javax.lang.model.*} packages bundled in Java SE 8 are required to
+ * javax.lang.model.*} packages bundled in Java SE 8 were required to
  * also be runnable on Java SE 7.  Therefore, default methods
- * <em>cannot</em> be used when extending {@code javax.lang.model.*}
+ * were <em>not</em> used when extending {@code javax.lang.model.*}
  * to cover Java SE 8 language features.  However, default methods may
  * be used in subsequent revisions of the {@code javax.lang.model.*}
  * packages that are only required to run on Java SE 8 and higher
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
  * visitor design pattern.  Classes implementing this
  * interface are used to operate on a type when the kind of
  * type is unknown at compile time.  When a visitor is passed to a
- * type's {@link TypeMirror#accept accept} method, the <tt>visit<i>XYZ</i></tt>
+ * type's {@link TypeMirror#accept accept} method, the <code>visit<i>Xyz</i></code>
  * method most applicable to that type is invoked.
  *
  * <p> Classes implementing this interface may or may not throw a
@@ -56,9 +56,9 @@
  * be added in a source <em>compatible</em> way if they were added as
  * <em>default methods</em>.  However, default methods are only
  * available on Java SE 8 and higher releases and the {@code
- * javax.lang.model.*} packages bundled in Java SE 8 are required to
+ * javax.lang.model.*} packages bundled in Java SE 8 were required to
  * also be runnable on Java SE 7.  Therefore, default methods
- * <em>cannot</em> be used when extending {@code javax.lang.model.*}
+ * were <em>not</em> used when extending {@code javax.lang.model.*}
  * to cover Java SE 8 language features.  However, default methods may
  * be used in subsequent revisions of the {@code javax.lang.model.*}
  * packages that are only required to run on Java SE 8 and higher
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/type/WildcardType.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/type/WildcardType.java	Tue Jan 24 00:30:25 2017 +0100
@@ -28,11 +28,11 @@
 
 /**
  * Represents a wildcard type argument.
- * Examples include:    <pre><tt>
+ * Examples include:    <pre><code>
  *   ?
  *   ? extends Number
  *   ? super T
- * </tt></pre>
+ * </code></pre>
  *
  * <p> A wildcard may have its upper bound explicitly set by an
  * {@code extends} clause, its lower bound explicitly set by a
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,15 +54,6 @@
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,15 +51,6 @@
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,15 +51,6 @@
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,15 +53,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,15 +52,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor8.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor8.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,15 +52,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,15 +52,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,15 +52,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,15 +52,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,10 +36,10 @@
  * A visitor of program elements based on their {@linkplain
  * ElementKind kind} with default behavior appropriate for the {@link
  * SourceVersion#RELEASE_6 RELEASE_6} source version.  For {@linkplain
- * Element elements} <tt><i>XYZ</i></tt> that may have more than one
- * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
- * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
- * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * Element elements} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind.  The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
  * call {@link #defaultAction defaultAction}, passing their arguments
  * to {@code defaultAction}'s corresponding parameters.
  *
@@ -67,15 +67,6 @@
  * for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,10 @@
  * A visitor of program elements based on their {@linkplain
  * ElementKind kind} with default behavior appropriate for the {@link
  * SourceVersion#RELEASE_7 RELEASE_7} source version.  For {@linkplain
- * Element elements} <tt><i>XYZ</i></tt> that may have more than one
- * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
- * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
- * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * Element elements} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind.  The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
  * call {@link #defaultAction defaultAction}, passing their arguments
  * to {@code defaultAction}'s corresponding parameters.
  *
@@ -65,15 +65,6 @@
  * for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,10 @@
  * A visitor of program elements based on their {@linkplain
  * ElementKind kind} with default behavior appropriate for the {@link
  * SourceVersion#RELEASE_8 RELEASE_8} source version.  For {@linkplain
- * Element elements} <tt><i>XYZ</i></tt> that may have more than one
- * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
- * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
- * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * Element elements} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind.  The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
  * call {@link #defaultAction defaultAction}, passing their arguments
  * to {@code defaultAction}'s corresponding parameters.
  *
@@ -65,15 +65,6 @@
  * for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,10 @@
  * A visitor of program elements based on their {@linkplain
  * ElementKind kind} with default behavior appropriate for the {@link
  * SourceVersion#RELEASE_9 RELEASE_9} source version.  For {@linkplain
- * Element elements} <tt><i>XYZ</i></tt> that may have more than one
- * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
- * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
- * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * Element elements} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind.  The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
  * call {@link #defaultAction defaultAction}, passing their arguments
  * to {@code defaultAction}'s corresponding parameters.
  *
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,26 +34,26 @@
 /**
  * A scanning visitor of program elements with default behavior
  * appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
- * source version.  The <tt>visit<i>XYZ</i></tt> methods in this
+ * source version.  The <code>visit<i>Xyz</i></code> methods in this
  * class scan their component elements by calling {@code scan} on
  * their {@linkplain Element#getEnclosedElements enclosed elements},
  * {@linkplain ExecutableElement#getParameters parameters}, etc., as
  * indicated in the individual method specifications.  A subclass can
  * control the order elements are visited by overriding the
- * <tt>visit<i>XYZ</i></tt> methods.  Note that clients of a scanner
+ * <code>visit<i>Xyz</i></code> methods.  Note that clients of a scanner
  * may get the desired behavior be invoking {@code v.scan(e, p)} rather
  * than {@code v.visit(e, p)} on the root objects of interest.
  *
- * <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
+ * <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the
  * new method can cause the enclosed elements to be scanned in the
- * default way by calling <tt>super.visit<i>XYZ</i></tt>.  In this
+ * default way by calling <code>super.visit<i>Xyz</i></code>.  In this
  * fashion, the concrete visitor can control the ordering of traversal
  * over the component elements with respect to the additional
  * processing; for example, consistently calling
- * <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
+ * <code>super.visit<i>Xyz</i></code> at the start of the overridden
  * methods will yield a preorder traversal, etc.  If the component
  * elements should be traversed in some other order, instead of
- * calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
+ * calling <code>super.visit<i>Xyz</i></code>, an overriding visit method
  * should call {@code scan} with the elements in the desired order.
  *
  * <p> Methods in this class may be overridden subject to their
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,26 +34,26 @@
 /**
  * A scanning visitor of program elements with default behavior
  * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
- * source version.  The <tt>visit<i>XYZ</i></tt> methods in this
+ * source version.  The <code>visit<i>Xyz</i></code> methods in this
  * class scan their component elements by calling {@code scan} on
  * their {@linkplain Element#getEnclosedElements enclosed elements},
  * {@linkplain ExecutableElement#getParameters parameters}, etc., as
  * indicated in the individual method specifications.  A subclass can
  * control the order elements are visited by overriding the
- * <tt>visit<i>XYZ</i></tt> methods.  Note that clients of a scanner
+ * <code>visit<i>Xyz</i></code> methods.  Note that clients of a scanner
  * may get the desired behavior be invoking {@code v.scan(e, p)} rather
  * than {@code v.visit(e, p)} on the root objects of interest.
  *
- * <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
+ * <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the
  * new method can cause the enclosed elements to be scanned in the
- * default way by calling <tt>super.visit<i>XYZ</i></tt>.  In this
+ * default way by calling <code>super.visit<i>Xyz</i></code>.  In this
  * fashion, the concrete visitor can control the ordering of traversal
  * over the component elements with respect to the additional
  * processing; for example, consistently calling
- * <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
+ * <code>super.visit<i>Xyz</i></code> at the start of the overridden
  * methods will yield a preorder traversal, etc.  If the component
  * elements should be traversed in some other order, instead of
- * calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
+ * calling <code>super.visit<i>Xyz</i></code>, an overriding visit method
  * should call {@code scan} with the elements in the desired order.
  *
  * <p> Methods in this class may be overridden subject to their
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,26 +34,26 @@
 /**
  * A scanning visitor of program elements with default behavior
  * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
- * source version.  The <tt>visit<i>XYZ</i></tt> methods in this
+ * source version.  The <code>visit<i>Xyz</i></code> methods in this
  * class scan their component elements by calling {@code scan} on
  * their {@linkplain Element#getEnclosedElements enclosed elements},
  * {@linkplain ExecutableElement#getParameters parameters}, etc., as
  * indicated in the individual method specifications.  A subclass can
  * control the order elements are visited by overriding the
- * <tt>visit<i>XYZ</i></tt> methods.  Note that clients of a scanner
+ * <code>visit<i>Xyz</i></code> methods.  Note that clients of a scanner
  * may get the desired behavior be invoking {@code v.scan(e, p)} rather
  * than {@code v.visit(e, p)} on the root objects of interest.
  *
- * <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
+ * <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the
  * new method can cause the enclosed elements to be scanned in the
- * default way by calling <tt>super.visit<i>XYZ</i></tt>.  In this
+ * default way by calling <code>super.visit<i>Xyz</i></code>.  In this
  * fashion, the concrete visitor can control the ordering of traversal
  * over the component elements with respect to the additional
  * processing; for example, consistently calling
- * <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
+ * <code>super.visit<i>Xyz</i></code> at the start of the overridden
  * methods will yield a preorder traversal, etc.  If the component
  * elements should be traversed in some other order, instead of
- * calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
+ * calling <code>super.visit<i>Xyz</i></code>, an overriding visit method
  * should call {@code scan} with the elements in the desired order.
  *
  * <p> Methods in this class may be overridden subject to their
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,26 +34,26 @@
 /**
  * A scanning visitor of program elements with default behavior
  * appropriate for the {@link SourceVersion#RELEASE_9 RELEASE_9}
- * source version.  The <tt>visit<i>XYZ</i></tt> methods in this
+ * source version.  The <code>visit<i>Xyz</i></code> methods in this
  * class scan their component elements by calling {@code scan} on
  * their {@linkplain Element#getEnclosedElements enclosed elements},
  * {@linkplain ExecutableElement#getParameters parameters}, etc., as
  * indicated in the individual method specifications.  A subclass can
  * control the order elements are visited by overriding the
- * <tt>visit<i>XYZ</i></tt> methods.  Note that clients of a scanner
+ * <code>visit<i>Xyz</i></code> methods.  Note that clients of a scanner
  * may get the desired behavior be invoking {@code v.scan(e, p)} rather
  * than {@code v.visit(e, p)} on the root objects of interest.
  *
- * <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
+ * <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the
  * new method can cause the enclosed elements to be scanned in the
- * default way by calling <tt>super.visit<i>XYZ</i></tt>.  In this
+ * default way by calling <code>super.visit<i>Xyz</i></code>.  In this
  * fashion, the concrete visitor can control the ordering of traversal
  * over the component elements with respect to the additional
  * processing; for example, consistently calling
- * <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
+ * <code>super.visit<i>Xyz</i></code> at the start of the overridden
  * methods will yield a preorder traversal, etc.  If the component
  * elements should be traversed in some other order, instead of
- * calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
+ * calling <code>super.visit<i>Xyz</i></code>, an overriding visit method
  * should call {@code scan} with the elements in the desired order.
  *
  * <p> Methods in this class may be overridden subject to their
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,15 +63,6 @@
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,15 +58,6 @@
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,15 +58,6 @@
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,15 +65,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@code Void}
  *             for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's methods.  Use {@code Void}
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,15 +62,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@code Void}
  *             for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's methods.  Use {@code Void}
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor8.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor8.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,15 +61,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@code Void}
  *             for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's methods.  Use {@code Void}
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,15 +64,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,15 +61,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,15 +61,6 @@
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,10 @@
  * A visitor of types based on their {@linkplain TypeKind kind} with
  * default behavior appropriate for the {@link SourceVersion#RELEASE_6
  * RELEASE_6} source version.  For {@linkplain
- * TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
- * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
- * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
- * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * TypeMirror types} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind.  The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
  * call {@link #defaultAction defaultAction}, passing their arguments
  * to {@code defaultAction}'s corresponding parameters.
  *
@@ -63,15 +63,6 @@
  * method in question.  When the new visitor is introduced, all or
  * portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,10 @@
  * A visitor of types based on their {@linkplain TypeKind kind} with
  * default behavior appropriate for the {@link SourceVersion#RELEASE_7
  * RELEASE_7} source version.  For {@linkplain
- * TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
- * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
- * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
- * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * TypeMirror types} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind.  The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
  * call {@link #defaultAction defaultAction}, passing their arguments
  * to {@code defaultAction}'s corresponding parameters.
  *
@@ -63,15 +63,6 @@
  * method in question.  When the new visitor is introduced, all or
  * portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,10 @@
  * A visitor of types based on their {@linkplain TypeKind kind} with
  * default behavior appropriate for the {@link SourceVersion#RELEASE_8
  * RELEASE_8} source version.  For {@linkplain
- * TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
- * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
- * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
- * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * TypeMirror types} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind.  The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
  * call {@link #defaultAction defaultAction}, passing their arguments
  * to {@code defaultAction}'s corresponding parameters.
  *
@@ -63,15 +63,6 @@
  * method in question.  When the new visitor is introduced, all or
  * portions of this visitor may be deprecated.
  *
- * <p>Note that adding a default implementation of a new visit method
- * in a visitor class will occur instead of adding a <em>default
- * method</em> directly in the visitor interface since a Java SE 8
- * language feature cannot be used to this version of the API since
- * this version is required to be runnable on Java SE 7
- * implementations.  Future versions of the API that are only required
- * to run on Java SE 8 and later may take advantage of default methods
- * in this situation.
- *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,10 @@
  * A visitor of types based on their {@linkplain TypeKind kind} with
  * default behavior appropriate for the {@link SourceVersion#RELEASE_9
  * RELEASE_9} source version.  For {@linkplain
- * TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
- * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
- * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
- * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * TypeMirror types} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind.  The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
  * call {@link #defaultAction defaultAction}, passing their arguments
  * to {@code defaultAction}'s corresponding parameters.
  *
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Jan 24 00:30:25 2017 +0100
@@ -921,6 +921,7 @@
 
         public PackageSymbol unnamedPackage;
         public Map<Name, PackageSymbol> visiblePackages;
+        public Set<ModuleSymbol> readModules;
         public List<Symbol> enclosedPackages = List.nil();
 
         public Completer usesProvidesCompleter = Completer.NULL_COMPLETER;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Tue Jan 24 00:30:25 2017 +0100
@@ -61,7 +61,6 @@
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
-import com.sun.tools.javac.util.Options;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
@@ -469,9 +468,7 @@
         scope.enter(errSymbol);
 
         Source source = Source.instance(context);
-        Options options = Options.instance(context);
-        boolean noModules = options.isSet("noModules");
-        if (source.allowModules() && !noModules) {
+        if (source.allowModules()) {
             java_base = enterModule(names.java_base);
             //avoid completing java.base during the Symtab initialization
             java_base.completer = Completer.NULL_COMPLETER;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,7 @@
 import static com.sun.tools.javac.code.Flags.SYNTHETIC;
 import static com.sun.tools.javac.code.Kinds.Kind.MDL;
 import static com.sun.tools.javac.code.Kinds.Kind.MTH;
+import static com.sun.tools.javac.code.Kinds.Kind.PCK;
 import static com.sun.tools.javac.code.Kinds.Kind.VAR;
 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
 import static com.sun.tools.javac.code.TypeTag.ARRAY;
@@ -228,7 +229,14 @@
         s.resetAnnotations(); // mark Annotations as incomplete for now
 
         normal(() -> {
-            Assert.check(s.annotationsPendingCompletion());
+            // Packages are unusual, in that they are the only type of declaration that can legally appear
+            // more than once in a compilation, and in all cases refer to the same underlying symbol.
+            // This means they are the only kind of declaration that syntactically may have multiple sets
+            // of annotations, each on a different package declaration, even though that is ultimately
+            // forbidden by JLS 8 section 7.4.
+            // The corollary here is that all of the annotations on a package symbol may have already
+            // been handled, meaning that the set of annotations pending completion is now empty.
+            Assert.check(s.kind == PCK || s.annotationsPendingCompletion());
             JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
             DiagnosticPosition prevLintPos =
                     deferPos != null
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Jan 24 00:30:25 2017 +0100
@@ -353,7 +353,7 @@
             @Override @DefinedBy(Api.COMPILER_TREE)
             public Symbol visitMemberSelect(MemberSelectTree node, Env<AttrContext> env) {
                 Symbol site = visit(node.getExpression(), env);
-                if (site.kind == ERR || site.kind == ABSENT_TYP)
+                if (site.kind == ERR || site.kind == ABSENT_TYP || site.kind == HIDDEN)
                     return site;
                 Name name = (Name)node.getIdentifier();
                 if (site.kind == PCK) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -436,8 +436,10 @@
     }
 
     void clearLocalClassNameIndexes(ClassSymbol c) {
-        localClassNameIndexes.remove(new Pair<>(
-                c.owner.enclClass().flatname, c.name));
+        if (c.owner != null && c.owner.kind != NIL) {
+            localClassNameIndexes.remove(new Pair<>(
+                    c.owner.enclClass().flatname, c.name));
+        }
     }
 
     public void newRound() {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Tue Jan 24 00:30:25 2017 +0100
@@ -792,6 +792,7 @@
             switch (tree.getTag()) {
                 case APPLY: ((JCMethodInvocation)tree).varargsElement = varargsElement; break;
                 case NEWCLASS: ((JCNewClass)tree).varargsElement = varargsElement; break;
+                case TYPECAST: setVarargsIfNeeded(((JCTypeCast) tree).expr, varargsElement); break;
                 default: throw new AssertionError();
             }
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1327,6 +1327,7 @@
         initAddExports();
 
         msym.visiblePackages = new LinkedHashMap<>();
+        msym.readModules = new HashSet<>(readable);
 
         Map<Name, ModuleSymbol> seen = new HashMap<>();
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Tue Jan 24 00:30:25 2017 +0100
@@ -54,14 +54,19 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.EnumSet;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Set;
+import java.util.function.BiFunction;
 import java.util.function.BiPredicate;
+import java.util.function.Predicate;
 import java.util.stream.Stream;
 
 import javax.lang.model.element.ElementVisitor;
 
+import com.sun.tools.javac.code.Directive.ExportsDirective;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Flags.BLOCK;
 import static com.sun.tools.javac.code.Flags.STATIC;
@@ -69,6 +74,8 @@
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** Helper class for name resolution, used mostly by the attribution phase.
@@ -89,6 +96,7 @@
     Check chk;
     Infer infer;
     ClassFinder finder;
+    ModuleFinder moduleFinder;
     Types types;
     JCDiagnostic.Factory diags;
     public final boolean allowMethodHandles;
@@ -98,8 +106,6 @@
     private final boolean compactMethodDiags;
     final EnumSet<VerboseResolutionMode> verboseResolutionMode;
 
-    private final boolean checkModuleAccess;
-
     WriteableScope polymorphicSignatureScope;
 
     protected Resolve(Context context) {
@@ -118,6 +124,7 @@
         chk = Check.instance(context);
         infer = Infer.instance(context);
         finder = ClassFinder.instance(context);
+        moduleFinder = ModuleFinder.instance(context);
         types = Types.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
         Source source = Source.instance(context);
@@ -135,10 +142,6 @@
         inapplicableMethodException = new InapplicableMethodException(diags);
 
         allowModules = source.allowModules();
-
-        // The following is required, for now, to support building
-        // Swing beaninfo via javadoc.
-        checkModuleAccess = !options.isSet("noModules");
     }
 
     /** error symbols, which are returned when resolution fails
@@ -321,8 +324,7 @@
                 isAccessible = true;
                 break;
             case PUBLIC:
-                isAccessible = true;
-                if (allowModules && checkModuleAccess) {
+                if (allowModules) {
                     ModuleSymbol currModule = env.toplevel.modle;
                     currModule.complete();
                     PackageSymbol p = c.packge();
@@ -497,7 +499,7 @@
         public Void visitClassType(ClassType t, Env<AttrContext> env) {
             visit(t.getTypeArguments(), env);
             if (!isAccessible(env, t, true)) {
-                accessBase(new AccessError(t.tsym), env.tree.pos(), env.enclClass.sym, t, t.tsym.name, true);
+                accessBase(new AccessError(env, null, t.tsym), env.tree.pos(), env.enclClass.sym, t, t.tsym.name, true);
             }
             return null;
         }
@@ -1971,7 +1973,7 @@
     Symbol loadClass(Env<AttrContext> env, Name name) {
         try {
             ClassSymbol c = finder.loadClass(env.toplevel.modle, name);
-            return isAccessible(env, c) ? c : new AccessError(c);
+            return isAccessible(env, c) ? c : new AccessError(env, null, c);
         } catch (ClassFinder.BadClassFile err) {
             throw err;
         } catch (CompletionFailure ex) {
@@ -1989,20 +1991,29 @@
         Symbol loadClass(Env<AttrContext> env, Name name);
     }
 
-    private RecoveryLoadClass recoveryLoadClass = (env, name) -> {
-        //even if a class cannot be found in the current module and packages in modules it depends on that
-        //are exported for any or this module, the class may exist internally in some of these modules,
-        //or may exist in a module on which this module does not depend. Provide better diagnostic in
-        //such cases by looking for the class in any module:
-        for (ModuleSymbol ms : syms.getAllModules()) {
-            //do not load currently unloaded classes, to avoid too eager completion of random things in other modules:
-            ClassSymbol clazz = syms.getClass(ms, name);
-
-            if (clazz != null) {
-                return new AccessError(clazz);
+    private RecoveryLoadClass recoveryLoadClass = new RecoveryLoadClass() {
+        @Override
+        public Symbol loadClass(Env<AttrContext> env, Name name) {
+            if (allowModules) {
+                Scope importScope = env.toplevel.namedImportScope;
+                Symbol existing = importScope.findFirst(Convert.shortName(name),
+                                                        sym -> sym.kind == TYP && sym.flatName() == name);
+
+                if (existing != null) {
+                    return new InvisibleSymbolError(env, true, existing);
+                }
+
+                return lookupInvisibleSymbol(env, name, syms::getClass, (ms, n) -> {
+                    try {
+                        return finder.loadClass(ms, n);
+                    } catch (CompletionFailure cf) {
+                        //ignore
+                        return null;
+                    }
+                }, sym -> sym.kind == Kind.TYP, false, typeNotFound);
             }
-        }
-        return null;
+            return null;
+        }
     };
 
     public RecoveryLoadClass setRecoveryLoadClass(RecoveryLoadClass recovery) {
@@ -2011,6 +2022,84 @@
         return prev;
     }
 
+    Symbol lookupPackage(Env<AttrContext> env, Name name) {
+        PackageSymbol pack = syms.lookupPackage(env.toplevel.modle, name);
+
+        if (allowModules && isImportOnDemand(env, name)) {
+            pack.complete();
+            if (!pack.exists()) {
+                Name nameAndDot = name.append('.', names.empty);
+                boolean prefixOfKnown =
+                        env.toplevel.modle.visiblePackages.values()
+                                                          .stream()
+                                                          .anyMatch(p -> p.fullname.startsWith(nameAndDot));
+
+                return lookupInvisibleSymbol(env, name, syms::getPackage, syms::enterPackage, sym -> {
+                    sym.complete();
+                    return sym.exists();
+                }, prefixOfKnown, pack);
+            }
+        }
+
+        return pack;
+    }
+
+    private boolean isImportOnDemand(Env<AttrContext> env, Name name) {
+        if (!env.tree.hasTag(IMPORT))
+            return false;
+
+        JCTree qualid = ((JCImport) env.tree).qualid;
+
+        if (!qualid.hasTag(SELECT))
+            return false;
+
+        if (TreeInfo.name(qualid) != names.asterisk)
+            return false;
+
+        return TreeInfo.fullName(((JCFieldAccess) qualid).selected) == name;
+    }
+
+    private Symbol lookupInvisibleSymbol(Env<AttrContext> env,
+                                         Name name,
+                                         BiFunction<ModuleSymbol, Name, Symbol> get,
+                                         BiFunction<ModuleSymbol, Name, Symbol> load,
+                                         Predicate<Symbol> validate,
+                                         boolean suppressError,
+                                         Symbol defaultResult) {
+        //even if a class/package cannot be found in the current module and among packages in modules
+        //it depends on that are exported for any or this module, the class/package may exist internally
+        //in some of these modules, or may exist in a module on which this module does not depend.
+        //Provide better diagnostic in such cases by looking for the class in any module:
+        Set<ModuleSymbol> recoverableModules = new HashSet<>(syms.getAllModules());
+
+        recoverableModules.remove(env.toplevel.modle);
+
+        for (ModuleSymbol ms : recoverableModules) {
+            Symbol sym = get.apply(ms, name);
+
+            //avoid overly eager completing classes from source-based modules, as those
+            //may not be completable with the current compiler settings:
+            if (sym == null && (ms.sourceLocation == null)) {
+                if (ms.classLocation == null) {
+                    ms = moduleFinder.findModule(ms);
+                }
+
+                if (ms.kind != ERR) {
+                    sym = load.apply(ms, name);
+                }
+            }
+
+            if (sym == null)
+                continue;
+
+            if (validate.test(sym)) {
+                return new InvisibleSymbolError(env, suppressError, sym);
+            }
+        }
+
+        return defaultResult;
+    }
+
     /**
      * Find a type declared in a scope (not inherited).  Return null
      * if none is found.
@@ -2211,7 +2300,7 @@
         }
 
         if (kind.contains(KindSelector.PCK))
-            return syms.lookupPackage(env.toplevel.modle, name);
+            return lookupPackage(env, name);
         else return bestSoFar;
     }
 
@@ -2225,11 +2314,6 @@
                               Name name, KindSelector kind) {
         Name fullname = TypeSymbol.formFullName(name, pck);
         Symbol bestSoFar = typeNotFound;
-        PackageSymbol pack = null;
-        if (kind.contains(KindSelector.PCK)) {
-            pack = syms.lookupPackage(env.toplevel.modle, fullname);
-            if (pack.exists()) return pack;
-        }
         if (kind.contains(KindSelector.TYP)) {
             Symbol sym = loadClass(env, fullname);
             if (sym.exists()) {
@@ -2238,7 +2322,10 @@
             }
             else bestSoFar = bestOf(bestSoFar, sym);
         }
-        return (pack != null) ? pack : bestSoFar;
+        if (kind.contains(KindSelector.PCK)) {
+            return lookupPackage(env, fullname);
+        }
+        return bestSoFar;
     }
 
     /** Find an identifier among the members of a given type `site'.
@@ -3947,10 +4034,6 @@
         private Env<AttrContext> env;
         private Type site;
 
-        AccessError(Symbol sym) {
-            this(null, null, sym);
-        }
-
         AccessError(Env<AttrContext> env, Type site, Symbol sym) {
             super(HIDDEN, sym, "access error");
             this.env = env;
@@ -3983,7 +4066,14 @@
                 if (sym.owner.kind == PCK) {
                     return diags.create(dkind, log.currentSource(),
                             pos, "not.def.access.package.cant.access",
-                        sym, sym.location());
+                        sym, sym.location(), inaccessiblePackageReason(env, sym.packge()));
+                } else if (   sym.packge() != syms.rootPackage
+                           && sym.packge().modle != env.toplevel.modle
+                           && !isAccessible(env, sym.outermostClass())) {
+                    return diags.create(dkind, log.currentSource(),
+                            pos, "not.def.access.class.intf.cant.access.reason",
+                            sym, sym.location(), sym.location().packge(),
+                            inaccessiblePackageReason(env, sym.packge()));
                 } else {
                     return diags.create(dkind, log.currentSource(),
                             pos, "not.def.access.class.intf.cant.access",
@@ -4015,6 +4105,90 @@
         }
     }
 
+    class InvisibleSymbolError extends InvalidSymbolError {
+
+        private final Env<AttrContext> env;
+        private final boolean suppressError;
+
+        InvisibleSymbolError(Env<AttrContext> env, boolean suppressError, Symbol sym) {
+            super(HIDDEN, sym, "invisible class error");
+            this.env = env;
+            this.suppressError = suppressError;
+            this.name = sym.name;
+        }
+
+        @Override
+        JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
+                DiagnosticPosition pos,
+                Symbol location,
+                Type site,
+                Name name,
+                List<Type> argtypes,
+                List<Type> typeargtypes) {
+            if (suppressError)
+                return null;
+
+            if (sym.kind == PCK) {
+                JCDiagnostic details = inaccessiblePackageReason(env, sym.packge());
+                return diags.create(dkind, log.currentSource(),
+                        pos, "package.not.visible", sym, details);
+            }
+
+            JCDiagnostic details = inaccessiblePackageReason(env, sym.packge());
+
+            if (pos.getTree() != null && pos.getTree().hasTag(SELECT) && sym.owner.kind == PCK) {
+                pos = ((JCFieldAccess) pos.getTree()).selected.pos();
+
+                return diags.create(dkind, log.currentSource(),
+                        pos, "package.not.visible", sym.packge(), details);
+            }
+
+            return diags.create(dkind, log.currentSource(),
+                    pos, "not.def.access.package.cant.access", sym, sym.packge(), details);
+        }
+    }
+
+    JCDiagnostic inaccessiblePackageReason(Env<AttrContext> env, PackageSymbol sym) {
+        //no dependency:
+        if (!env.toplevel.modle.readModules.contains(sym.modle)) {
+            //does not read:
+            if (sym.modle != syms.unnamedModule) {
+                if (env.toplevel.modle != syms.unnamedModule) {
+                    return diags.fragment(Fragments.NotDefAccessDoesNotRead(env.toplevel.modle,
+                                                                            sym,
+                                                                            sym.modle));
+                } else {
+                    return diags.fragment(Fragments.NotDefAccessDoesNotReadFromUnnamed(sym,
+                                                                                       sym.modle));
+                }
+            } else {
+                return diags.fragment(Fragments.NotDefAccessDoesNotReadUnnamed(sym,
+                                                                               env.toplevel.modle));
+            }
+        } else {
+            if (sym.packge().modle.exports.stream().anyMatch(e -> e.packge == sym)) {
+                //not exported to this module:
+                if (env.toplevel.modle != syms.unnamedModule) {
+                    return diags.fragment(Fragments.NotDefAccessNotExportedToModule(sym,
+                                                                                    sym.modle,
+                                                                                    env.toplevel.modle));
+                } else {
+                    return diags.fragment(Fragments.NotDefAccessNotExportedToModuleFromUnnamed(sym,
+                                                                                               sym.modle));
+                }
+            } else {
+                //not exported:
+                if (env.toplevel.modle != syms.unnamedModule) {
+                    return diags.fragment(Fragments.NotDefAccessNotExported(sym,
+                                                                            sym.modle));
+                } else {
+                    return diags.fragment(Fragments.NotDefAccessNotExportedFromUnnamed(sym,
+                                                                                       sym.modle));
+                }
+            }
+        }
+    }
+
     /**
      * InvalidSymbolError error class indicating that an instance member
      * has erroneously been accessed from a static context.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -410,7 +410,9 @@
                     importNamedStatic(tree, p, name, localEnv);
                     chk.checkCanonical(imp.selected);
                 } else {
-                    TypeSymbol c = attribImportType(imp, localEnv).tsym;
+                    Type importedType = attribImportType(imp, localEnv);
+                    Type originalType = importedType.getOriginalType();
+                    TypeSymbol c = originalType.hasTag(CLASS) ? originalType.tsym : importedType.tsym;
                     chk.checkCanonical(imp);
                     importNamed(tree.pos(), c, env, tree);
                 }
@@ -938,6 +940,7 @@
          */
         void finishClass(JCClassDecl tree, Env<AttrContext> env) {
             if ((tree.mods.flags & Flags.ENUM) != 0 &&
+                !tree.sym.type.hasTag(ERROR) &&
                 (types.supertype(tree.sym.type).tsym.flags() & Flags.ENUM) == 0) {
                 addEnumMembers(tree, env);
             }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -818,13 +818,17 @@
             return List.nil();
 
         String checkPackages = options.get(Option.XDOCLINT_PACKAGE);
-
         if (checkPackages != null) {
             for (String s : checkPackages.split("\\s+")) {
                 doclintOpts.add(DocLint.XCHECK_PACKAGE + s);
             }
         }
 
+        String format = options.get(Option.DOCLINT_FORMAT);
+        if (format != null) {
+            doclintOpts.add(DocLint.XHTML_VERSION_PREFIX + format);
+        }
+
         // standard doclet normally generates H1, H2,
         // so for now, allow user comments to assume that
         doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Jan 24 00:30:25 2017 +0100
@@ -681,7 +681,7 @@
         if (sep == -1) {
             msym = modules.getDefaultModule();
             typeName = name;
-        } else if (source.allowModules() && !options.isSet("noModules")) {
+        } else if (source.allowModules()) {
             Name modName = names.fromString(name.substring(0, sep));
 
             msym = moduleFinder.findModule(modName);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -154,6 +154,8 @@
         }
     },
 
+    DOCLINT_FORMAT("--doclint-format", "opt.doclint.format", EXTENDED, BASIC, ONEOF, "html4", "html5"),
+
     // -nowarn is retained for command-line backward compatibility
     NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) {
         @Override
@@ -1216,10 +1218,12 @@
         sb.append(name);
         if (argsNameKey == null) {
             if (choices != null) {
+                if (!name.endsWith(":"))
+                    sb.append(" ");
                 String sep = "{";
                 for (String choice : choices) {
                     sb.append(sep);
-                    sb.append(choices);
+                    sb.append(choice);
                     sep = ",";
                 }
                 sb.append("}");
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,11 @@
 
 package com.sun.tools.javac.model;
 
+import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import javax.lang.model.AnnotatedConstruct;
 import javax.lang.model.SourceVersion;
@@ -67,6 +69,7 @@
 import com.sun.tools.javac.comp.Modules;
 import com.sun.tools.javac.comp.Resolve;
 import com.sun.tools.javac.comp.Resolve.RecoveryLoadClass;
+import com.sun.tools.javac.resources.CompilerProperties.Notes;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /**
@@ -87,6 +90,8 @@
     private final Enter enter;
     private final Resolve resolve;
     private final JavacTaskImpl javacTaskImpl;
+    private final Log log;
+    private final boolean allowModules;
 
     public static JavacElements instance(Context context) {
         JavacElements instance = context.get(JavacElements.class);
@@ -106,6 +111,9 @@
         resolve = Resolve.instance(context);
         JavacTask t = context.get(JavacTask.class);
         javacTaskImpl = t instanceof JavacTaskImpl ? (JavacTaskImpl) t : null;
+        log = Log.instance(context);
+        Source source = Source.instance(context);
+        allowModules = source.allowModules();
     }
 
     @Override @DefinedBy(Api.LANGUAGE_MODEL)
@@ -134,7 +142,7 @@
         ensureEntered("getPackageElement");
         if (name.length() == 0)
             return syms.unnamedModule.unnamedPackage;
-        return doGetElement(module, name, PackageSymbol.class);
+        return doGetElement(module, "getPackageElement", name, PackageSymbol.class);
     }
 
     @Override @DefinedBy(Api.LANGUAGE_MODEL)
@@ -151,22 +159,27 @@
 
     private ClassSymbol doGetTypeElement(ModuleElement module, CharSequence name) {
         ensureEntered("getTypeElement");
-        return doGetElement(module, name, ClassSymbol.class);
+        return doGetElement(module, "getTypeElement", name, ClassSymbol.class);
     }
 
-    private <S extends Symbol> S doGetElement(ModuleElement module, CharSequence name, Class<S> clazz) {
+    private <S extends Symbol> S doGetElement(ModuleElement module, String methodName,
+                                              CharSequence name, Class<S> clazz) {
         String strName = name.toString();
         if (!SourceVersion.isName(strName)) {
             return null;
         }
         if (module == null) {
-            return unboundNameToSymbol(strName, clazz);
+            return unboundNameToSymbol(methodName, strName, clazz);
         } else {
             return nameToSymbol((ModuleSymbol) module, strName, clazz);
         }
     }
 
-    private <S extends Symbol> S unboundNameToSymbol(String nameStr, Class<S> clazz) {
+    private final Set<String> alreadyWarnedDuplicates = new HashSet<>();
+
+    private <S extends Symbol> S unboundNameToSymbol(String methodName,
+                                                     String nameStr,
+                                                     Class<S> clazz) {
         if (modules.getDefaultModule() == syms.noModule) { //not a modular mode:
             return nameToSymbol(syms.noModule, nameStr, clazz);
         }
@@ -179,12 +192,25 @@
                 S sym = nameToSymbol(msym, nameStr, clazz);
 
                 if (sym != null) {
-                    found.add(sym);
+                    if (!allowModules || clazz == ClassSymbol.class || !sym.members().isEmpty()) {
+                        //do not add packages without members:
+                        found.add(sym);
+                    }
                 }
             }
 
             if (found.size() == 1) {
                 return found.iterator().next();
+            } else if (found.size() > 1) {
+                //more than one element found, produce a note:
+                if (alreadyWarnedDuplicates.add(methodName + ":" + nameStr)) {
+                    String moduleNames = found.stream()
+                                              .map(s -> s.packge().modle)
+                                              .map(m -> m.toString())
+                                              .collect(Collectors.joining(", "));
+                    log.note(Notes.MultipleElements(methodName, nameStr, moduleNames));
+                }
+                return null;
             } else {
                 //not found, or more than one element found:
                 return null;
@@ -222,41 +248,6 @@
         }
     }
 
-    public JavacSourcePosition getSourcePosition(Element e) {
-        Pair<JCTree, JCCompilationUnit> treeTop = getTreeAndTopLevel(e);
-        if (treeTop == null)
-            return null;
-        JCTree tree = treeTop.fst;
-        JCCompilationUnit toplevel = treeTop.snd;
-        JavaFileObject sourcefile = toplevel.sourcefile;
-        if (sourcefile == null)
-            return null;
-        return new JavacSourcePosition(sourcefile, tree.pos, toplevel.lineMap);
-    }
-
-    public JavacSourcePosition getSourcePosition(Element e, AnnotationMirror a) {
-        Pair<JCTree, JCCompilationUnit> treeTop = getTreeAndTopLevel(e);
-        if (treeTop == null)
-            return null;
-        JCTree tree = treeTop.fst;
-        JCCompilationUnit toplevel = treeTop.snd;
-        JavaFileObject sourcefile = toplevel.sourcefile;
-        if (sourcefile == null)
-            return null;
-
-        JCTree annoTree = matchAnnoToTree(a, e, tree);
-        if (annoTree == null)
-            return null;
-        return new JavacSourcePosition(sourcefile, annoTree.pos,
-                                       toplevel.lineMap);
-    }
-
-    public JavacSourcePosition getSourcePosition(Element e, AnnotationMirror a,
-                                            AnnotationValue v) {
-        // TODO: better accuracy in getSourcePosition(... AnnotationValue)
-        return getSourcePosition(e, a);
-    }
-
     /**
      * Returns the tree for an annotation given the annotated element
      * and the element's own tree.  Returns null if the tree cannot be found.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacSourcePosition.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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 com.sun.tools.javac.model;
-
-import javax.tools.JavaFileObject;
-import com.sun.tools.javac.util.Position;
-
-/**
- * Implementation of model API SourcePosition based on javac internal state.
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own
- * risk.  This code and its internal interfaces are subject to change
- * or deletion without notice.</b></p>
- */
-class JavacSourcePosition {
-
-    final JavaFileObject sourcefile;
-    final int pos;
-    final Position.LineMap lineMap;
-
-    JavacSourcePosition(JavaFileObject sourcefile,
-                        int pos,
-                        Position.LineMap lineMap) {
-        this.sourcefile = sourcefile;
-        this.pos = pos;
-        this.lineMap = (pos != Position.NOPOS) ? lineMap : null;
-    }
-
-    public JavaFileObject getFile() {
-        return sourcefile;
-    }
-
-    public int getOffset() {
-        return pos;     // makes use of fact that Position.NOPOS == -1
-    }
-
-    public int getLine() {
-        return (lineMap != null) ? lineMap.getLineNumber(pos) : -1;
-    }
-
-    public int getColumn() {
-        return (lineMap != null) ? lineMap.getColumnNumber(pos) : -1;
-    }
-
-    public String toString() {
-        int line = getLine();
-        return (line > 0)
-              ? sourcefile + ":" + line
-              : sourcefile.toString();
-    }
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Tue Jan 24 00:30:25 2017 +0100
@@ -230,7 +230,7 @@
         chk = Check.instance(context);
         initProcessorLoader();
 
-        allowModules = source.allowModules() && options.isUnset("noModules");
+        allowModules = source.allowModules();
     }
 
     public void setProcessors(Iterable<? extends Processor> processors) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -823,17 +823,87 @@
 compiler.err.not.annotation.type=\
     {0} is not an annotation type
 
-# 0: symbol, 1: symbol
+# 0: symbol, 1: symbol, 2: message segment
 compiler.err.not.def.access.package.cant.access=\
-    {0} is not visible because package {1} is not visible
+    {0} is not visible\n\
+    ({2})
+
+# 0: symbol, 1: symbol, 2: message segment
+compiler.misc.not.def.access.package.cant.access=\
+    {0} is not visible\n\
+    ({2})
+
+# 0: symbol, 1: message segment
+compiler.err.package.not.visible=\
+    package {0} is not visible\n\
+    ({1})
+
+# 0: symbol, 1: message segment
+compiler.misc.package.not.visible=\
+    package {0} is not visible\n\
+    ({1})
+
+# {0} - current module
+# {1} - package in which the invisible class is declared
+# {2} - module in which {1} is declared
+# 0: symbol, 1: symbol, 2: symbol
+compiler.misc.not.def.access.does.not.read=\
+    package {1} is declared in module {2}, but module {0} does not read it
+
+# {0} - package in which the invisible class is declared
+# {1} - module in which {0} is declared
+# 0: symbol, 1: symbol
+compiler.misc.not.def.access.does.not.read.from.unnamed=\
+    package {0} is declared in module {1}, which is not in the module graph
+
+# {0} - package in which the invisible class is declared
+# {1} - current module
+# 0: symbol, 1: symbol
+compiler.misc.not.def.access.does.not.read.unnamed=\
+    package {0} is declared in the unnamed module, but module {0} does not read it
+
+# {0} - package in which the invisible class is declared
+# {1} - module in which {0} is declared
+# 0: symbol, 1: symbol
+compiler.misc.not.def.access.not.exported=\
+    package {0} is declared in module {1}, which does not export it
+
+# {0} - package in which the invisible class is declared
+# {1} - module in which {0} is declared
+# 0: symbol, 1: symbol
+compiler.misc.not.def.access.not.exported.from.unnamed=\
+    package {0} is declared in module {1}, which does not export it
+
+# {0} - package in which the invisible class is declared
+# {1} - module in which {0} is declared
+# {2} - current module
+# 0: symbol, 1: symbol, 2: symbol
+compiler.misc.not.def.access.not.exported.to.module=\
+    package {0} is declared in module {1}, which does not export it to module {2}
+
+# {0} - package in which the invisible class is declared
+# {1} - module in which {0} is declared
+# 0: symbol, 1: symbol
+compiler.misc.not.def.access.not.exported.to.module.from.unnamed=\
+    package {0} is declared in module {1}, which does not export it to the unnamed module
 
 # 0: symbol, 1: symbol
 compiler.err.not.def.access.class.intf.cant.access=\
-    {0} in {1} is defined in an inaccessible class or interface
+    {1}.{0} is defined in an inaccessible class or interface
 
 # 0: symbol, 1: symbol
 compiler.misc.not.def.access.class.intf.cant.access=\
-    {0} in {1} is defined in an inaccessible class or interface
+    {1}.{0} is defined in an inaccessible class or interface
+
+# 0: symbol, 1: symbol, 2: symbol, 3: message segment
+compiler.err.not.def.access.class.intf.cant.access.reason=\
+    {1}.{0} in package {2} is not accessible\n\
+    ({3})
+
+# 0: symbol, 1: symbol, 2: symbol, 3: message segment
+compiler.misc.not.def.access.class.intf.cant.access.reason=\
+    {1}.{0} in package {2} is not accessible\n\
+    ({3})
 
 # 0: symbol, 1: list of type, 2: type
 compiler.misc.cant.access.inner.cls.constr=\
@@ -1366,6 +1436,10 @@
 compiler.note.proc.messager=\
     {0}
 
+# 0: string, 1: string, 2: string
+compiler.note.multiple.elements=\
+    Multiple elements named '{1}' in modules '{2}' were found by javax.lang.model.util.Elements.{0}.
+
 #####
 
 # 0: number
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -263,6 +263,9 @@
     expands to all sub-packages of the given package. Each <package> can be prefixed\n\
     with '-' to disable checks for the specified package or packages.
 
+javac.opt.doclint.format=\
+    Specify the format for documentation comments
+
 javac.opt.Xstdout=\
     Redirect standard output
 javac.opt.X=\
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -68,6 +68,11 @@
      */
     public static final int DBG_EVNT = 0b0010000;
 
+    /**
+     * Event debugging.
+     */
+    public static final int DBG_WRAP = 0b0100000;
+
     private static Map<JShell, Integer> debugMap = null;
 
     /**
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Tue Jan 24 00:30:25 2017 +0100
@@ -119,6 +119,7 @@
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_EVNT;
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_FMGR;
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN;
+import static jdk.internal.jshell.debug.InternalDebugControl.DBG_WRAP;
 import static jdk.internal.jshell.tool.ContinuousCompletionProvider.STARTSWITH_MATCHER;
 
 /**
@@ -217,7 +218,7 @@
 
     static final String DEFAULT_STARTUP_NAME = "DEFAULT";
     static final Pattern BUILTIN_FILE_PATTERN = Pattern.compile("\\w+");
-    static final String BUILTIN_FILE_PATH_FORMAT = "jrt:/jdk.jshell/jdk/jshell/tool/resources/%s.jsh";
+    static final String BUILTIN_FILE_PATH_FORMAT = "/jdk/jshell/tool/resources/%s.jsh";
 
     // match anything followed by whitespace
     private static final Pattern OPTION_PRE_PATTERN =
@@ -1919,9 +1920,13 @@
                         flags |= DBG_EVNT;
                         fluff("Event debugging on");
                         break;
+                    case 'w':
+                        flags |= DBG_WRAP;
+                        fluff("Wrap debugging on");
+                        break;
                     default:
                         hard("Unknown debugging option: %c", ch);
-                        fluff("Use: 0 r g f c d");
+                        fluff("Use: 0 r g f c d e w");
                         return false;
                 }
             }
@@ -2421,9 +2426,11 @@
     String readResource(String name) throws IOException {
         // Attempt to find the file as a resource
         String spec = String.format(BUILTIN_FILE_PATH_FORMAT, name);
-        URL url = new URL(spec);
-        BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
-        return reader.lines().collect(Collectors.joining("\n"));
+
+        try (InputStream in = JShellTool.class.getResourceAsStream(spec);
+             BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
+            return reader.lines().collect(Collectors.joining("\n"));
+        }
     }
 
     // retrieve the default startup string
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java	Tue Jan 24 00:30:25 2017 +0100
@@ -66,7 +66,7 @@
                     if ((read = input.read()) == (-1)) {
                         break;
                     }
-                    if (read == 3 && currentState == State.BUFFER) {
+                    if (read == 3 && getState() == State.BUFFER) {
                         stop.run();
                     } else {
                         write(read);
@@ -141,6 +141,10 @@
         }
     }
 
+    private synchronized State getState() {
+        return state;
+    }
+
     private synchronized State waitInputNeeded() {
         while (state == State.WAIT) {
             try {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java	Tue Jan 24 00:30:25 2017 +0100
@@ -49,6 +49,7 @@
 import java.io.Writer;
 import java.util.LinkedHashSet;
 import java.util.Set;
+import jdk.jshell.ExpressionToTypeInfo.ExpressionInfo;
 import jdk.jshell.Key.ErroneousKey;
 import jdk.jshell.Key.MethodKey;
 import jdk.jshell.Key.TypeDeclKey;
@@ -58,7 +59,6 @@
 import jdk.jshell.TaskFactory.BaseTask;
 import jdk.jshell.TaskFactory.CompileTask;
 import jdk.jshell.TaskFactory.ParseTask;
-import jdk.jshell.TreeDissector.ExpressionInfo;
 import jdk.jshell.Wrap.Range;
 import jdk.jshell.Snippet.Status;
 import jdk.jshell.spi.ExecutionControl.ClassBytecodes;
@@ -296,7 +296,7 @@
 
     private List<Snippet> processExpression(String userSource, String compileSource) {
         String name = null;
-        ExpressionInfo ei = typeOfExpression(compileSource);
+        ExpressionInfo ei = ExpressionToTypeInfo.expressionInfo(compileSource, state);
         ExpressionTree assignVar;
         Wrap guts;
         Snippet snip;
@@ -499,16 +499,6 @@
         return singletonList(snip);
     }
 
-    private ExpressionInfo typeOfExpression(String expression) {
-        Wrap guts = Wrap.methodReturnWrap(expression);
-        TaskFactory.AnalyzeTask at = trialCompile(guts);
-        if (!at.hasErrors() && at.firstCuTree() != null) {
-            return TreeDissector.createByFirstClass(at)
-                    .typeOfReturnStatement(at, state);
-        }
-        return null;
-    }
-
     /**
      * Should a temp var wrap the expression. TODO make this user configurable.
      *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExpressionToTypeInfo.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,216 @@
+/*
+ * 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 jdk.jshell;
+
+import com.sun.source.tree.ReturnTree;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.ConditionalExpressionTree;
+import com.sun.source.tree.ExpressionTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Types;
+import jdk.jshell.TaskFactory.AnalyzeTask;
+
+/**
+ * Compute information about an expression string, particularly its type name.
+ */
+class ExpressionToTypeInfo {
+
+    private static final String OBJECT_TYPE_NAME = "Object";
+
+    final AnalyzeTask at;
+    final CompilationUnitTree cu;
+    final JShell state;
+    final Symtab syms;
+    final Types types;
+
+    private ExpressionToTypeInfo(AnalyzeTask at, CompilationUnitTree cu, JShell state) {
+        this.at = at;
+        this.cu = cu;
+        this.state = state;
+        this.syms = Symtab.instance(at.context);
+        this.types = Types.instance(at.context);
+    }
+
+    public static class ExpressionInfo {
+        ExpressionTree tree;
+        String typeName;
+        boolean isNonVoid;
+    }
+
+    // return mechanism and other general structure from TreePath.getPath()
+    private static class Result extends Error {
+
+        static final long serialVersionUID = -5942088234594905629L;
+        final TreePath expressionPath;
+
+        Result(TreePath path) {
+            this.expressionPath = path;
+        }
+    }
+
+    private static class PathFinder extends TreePathScanner<TreePath, Boolean> {
+
+        // Optimize out imports etc
+        @Override
+        public TreePath visitCompilationUnit(CompilationUnitTree node, Boolean isTargetContext) {
+            return scan(node.getTypeDecls(), isTargetContext);
+        }
+
+        // Only care about members
+        @Override
+        public TreePath visitClass(ClassTree node, Boolean isTargetContext) {
+            return scan(node.getMembers(), isTargetContext);
+        }
+
+        // Only want the doit method where the code is
+        @Override
+        public TreePath visitMethod(MethodTree node, Boolean isTargetContext) {
+            if (Util.isDoIt(node.getName())) {
+                return scan(node.getBody(), true);
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public TreePath visitReturn(ReturnTree node, Boolean isTargetContext) {
+            ExpressionTree tree = node.getExpression();
+            TreePath tp = new TreePath(getCurrentPath(), tree);
+            if (isTargetContext) {
+                throw new Result(tp);
+            } else {
+                return null;
+            }
+        }
+    }
+
+    private Type pathToType(TreePath tp) {
+        return (Type) at.trees().getTypeMirror(tp);
+    }
+
+    private Type pathToType(TreePath tp, Tree tree) {
+        if (tree instanceof ConditionalExpressionTree) {
+            // Conditionals always wind up as Object -- this corrects
+            ConditionalExpressionTree cet = (ConditionalExpressionTree) tree;
+            Type tmt = pathToType(new TreePath(tp, cet.getTrueExpression()));
+            Type tmf = pathToType(new TreePath(tp, cet.getFalseExpression()));
+            if (!tmt.isPrimitive() && !tmf.isPrimitive()) {
+                Type lub = types.lub(tmt, tmf);
+                // System.err.printf("cond ? %s : %s  --  lub = %s\n",
+                //             varTypeName(tmt), varTypeName(tmf), varTypeName(lub));
+                return lub;
+            }
+        }
+        return pathToType(tp);
+    }
+
+    /**
+     * Entry method: get expression info
+     * @param code the expression as a string
+     * @param state a JShell instance
+     * @return type information
+     */
+    public static ExpressionInfo expressionInfo(String code, JShell state) {
+        if (code == null || code.isEmpty()) {
+            return null;
+        }
+        try {
+            OuterWrap codeWrap = state.outerMap.wrapInTrialClass(Wrap.methodReturnWrap(code));
+            AnalyzeTask at = state.taskFactory.new AnalyzeTask(codeWrap);
+            CompilationUnitTree cu = at.firstCuTree();
+            if (at.hasErrors() || cu == null) {
+                return null;
+            }
+            return new ExpressionToTypeInfo(at, cu, state).typeOfExpression();
+        } catch (Exception ex) {
+            return null;
+        }
+    }
+
+    private ExpressionInfo typeOfExpression() {
+        return treeToInfo(findExpressionPath());
+    }
+
+    private TreePath findExpressionPath() {
+        try {
+            new PathFinder().scan(new TreePath(cu), false);
+        } catch (Result result) {
+            return result.expressionPath;
+        }
+        return null;
+    }
+
+    private ExpressionInfo treeToInfo(TreePath tp) {
+        if (tp != null) {
+            Tree tree = tp.getLeaf();
+            if (tree instanceof ExpressionTree) {
+                ExpressionInfo ei = new ExpressionInfo();
+                ei.tree = (ExpressionTree) tree;
+                Type type = pathToType(tp, tree);
+                if (type != null) {
+                    switch (type.getKind()) {
+                        case VOID:
+                        case NONE:
+                        case ERROR:
+                        case OTHER:
+                            break;
+                        case NULL:
+                            ei.isNonVoid = true;
+                            ei.typeName = OBJECT_TYPE_NAME;
+                            break;
+                        default: {
+                            ei.isNonVoid = true;
+                            ei.typeName = varTypeName(type);
+                            if (ei.typeName == null) {
+                                ei.typeName = OBJECT_TYPE_NAME;
+                            }
+                            break;
+                        }
+                    }
+                }
+                return ei;
+            }
+        }
+        return null;
+    }
+
+    private String varTypeName(Type type) {
+        try {
+            TypePrinter tp = new VarTypePrinter(at.messages(),
+                    state.maps::fullClassNameAndPackageToClass, syms, types);
+            return tp.toString(type);
+        } catch (Exception ex) {
+            return null;
+        }
+    }
+
+}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -105,7 +105,6 @@
 import java.util.stream.Collectors;
 
 import static java.util.stream.Collectors.collectingAndThen;
-import static java.util.stream.Collectors.joining;
 import static java.util.stream.Collectors.toCollection;
 import static java.util.stream.Collectors.toList;
 import static java.util.stream.Collectors.toSet;
@@ -128,6 +127,7 @@
 import javax.tools.JavaFileManager.Location;
 import javax.tools.StandardLocation;
 
+import jdk.jshell.ExpressionToTypeInfo.ExpressionInfo;
 import static jdk.jshell.Util.REPL_DOESNOTMATTER_CLASS_NAME;
 import static jdk.jshell.SourceCodeAnalysis.Completeness.DEFINITELY_INCOMPLETE;
 import static jdk.jshell.TreeDissector.printType;
@@ -1430,47 +1430,17 @@
 
     @Override
     public String analyzeType(String code, int cursor) {
-        code = code.substring(0, cursor);
-        CompletionInfo completionInfo = analyzeCompletion(code);
-        if (!completionInfo.completeness().isComplete())
-            return null;
-        if (completionInfo.completeness() == Completeness.COMPLETE_WITH_SEMI) {
-            code += ";";
-        }
-
-        OuterWrap codeWrap;
         switch (guessKind(code)) {
             case IMPORT: case METHOD: case CLASS: case ENUM:
             case INTERFACE: case ANNOTATION_TYPE: case VARIABLE:
                 return null;
             default:
-                codeWrap = proc.outerMap.wrapInTrialClass(Wrap.methodWrap(code));
                 break;
         }
-        AnalyzeTask at = proc.taskFactory.new AnalyzeTask(codeWrap);
-        SourcePositions sp = at.trees().getSourcePositions();
-        CompilationUnitTree topLevel = at.firstCuTree();
-        int pos = codeWrap.snippetIndexToWrapIndex(code.length());
-        TreePath tp = pathFor(topLevel, sp, pos);
-        while (ExpressionTree.class.isAssignableFrom(tp.getParentPath().getLeaf().getKind().asInterface()) &&
-               tp.getParentPath().getLeaf().getKind() != Kind.ERRONEOUS &&
-               tp.getParentPath().getParentPath() != null)
-            tp = tp.getParentPath();
-        TypeMirror type = at.trees().getTypeMirror(tp);
-
-        if (type == null)
-            return null;
-
-        switch (type.getKind()) {
-            case ERROR: case NONE: case OTHER:
-            case PACKAGE: case VOID:
-                return null; //not usable
-            case NULL:
-                type = at.getElements().getTypeElement("java.lang.Object").asType();
-                break;
-        }
-
-        return TreeDissector.printType(at, proc, type);
+        ExpressionInfo ei = ExpressionToTypeInfo.expressionInfo(code, proc);
+        return (ei == null || !ei.isNonVoid)
+                ? null
+                : ei.typeName;
     }
 
     @Override
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java	Tue Jan 24 00:30:25 2017 +0100
@@ -321,7 +321,7 @@
         final JavacTaskImpl task;
         private DiagList diags = null;
         private final SourceHandler<?> sourceHandler;
-        private final Context context = new Context();
+        final Context context = new Context();
         private Types types;
         private JavacMessages messages;
         private Trees trees;
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDissector.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDissector.java	Tue Jan 24 00:30:25 2017 +0100
@@ -28,14 +28,11 @@
 
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.ExpressionTree;
 import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.ReturnTree;
 import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreePath;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.MethodType;
@@ -47,7 +44,6 @@
 import jdk.jshell.Wrap.Range;
 
 import java.util.List;
-import java.util.Locale;
 
 import java.util.function.Predicate;
 import java.util.stream.Stream;
@@ -61,16 +57,6 @@
 
 class TreeDissector {
 
-    private static final String OBJECT_TYPE = "Object";
-
-    static class ExpressionInfo {
-
-        boolean isNonVoid;
-        String typeName;
-        ExpressionTree tree;
-        String signature;
-    }
-
     private final TaskFactory.BaseTask bt;
     private final ClassTree targetClass;
     private final CompilationUnitTree targetCompilationUnit;
@@ -219,41 +205,6 @@
         return null;
     }
 
-
-    ExpressionInfo typeOfReturnStatement(AnalyzeTask at, JShell state) {
-        ExpressionInfo ei = new ExpressionInfo();
-        Tree unitTree = firstStatement();
-        if (unitTree instanceof ReturnTree) {
-            ei.tree = ((ReturnTree) unitTree).getExpression();
-            if (ei.tree != null) {
-                TreePath viPath = trees().getPath(targetCompilationUnit, ei.tree);
-                if (viPath != null) {
-                    TypeMirror tm = trees().getTypeMirror(viPath);
-                    if (tm != null) {
-                        ei.typeName = printType(at, state, tm);
-                        switch (tm.getKind()) {
-                            case VOID:
-                            case NONE:
-                            case ERROR:
-                            case OTHER:
-                                break;
-                            case NULL:
-                                ei.isNonVoid = true;
-                                ei.typeName = OBJECT_TYPE;
-                                break;
-                            default: {
-                                ei.isNonVoid = true;
-                                break;
-
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return ei;
-    }
-
     String typeOfMethod(MethodSnippet msn) {
         Tree unitTree = method(msn);
         if (unitTree instanceof JCMethodDecl) {
@@ -274,8 +225,13 @@
 
     public static String printType(AnalyzeTask at, JShell state, TypeMirror type) {
         Type typeImpl = (Type) type;
-        TypePrinter tp = new TypePrinter(at.messages(), state.maps::fullClassNameAndPackageToClass, typeImpl);
-        return tp.visit(typeImpl, Locale.getDefault());
+        try {
+            TypePrinter tp = new TypePrinter(at.messages(),
+                    state.maps::fullClassNameAndPackageToClass);
+            return tp.toString(typeImpl);
+        } catch (Exception ex) {
+            return null;
+        }
     }
 
     /**
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TypePrinter.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TypePrinter.java	Tue Jan 24 00:30:25 2017 +0100
@@ -22,7 +22,6 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package jdk.jshell;
 
 import static com.sun.tools.javac.code.Flags.COMPOUND;
@@ -41,17 +40,21 @@
  * Print types in source form.
  */
 class TypePrinter extends Printer {
+
     private static final String OBJECT = "Object";
 
     private final JavacMessages messages;
     private final BinaryOperator<String> fullClassNameAndPackageToClass;
-    private boolean useWildCard = false;
 
-    TypePrinter(JavacMessages messages, BinaryOperator<String> fullClassNameAndPackageToClass, Type typeToPrint) {
+    TypePrinter(JavacMessages messages, BinaryOperator<String> fullClassNameAndPackageToClass) {
         this.messages = messages;
         this.fullClassNameAndPackageToClass = fullClassNameAndPackageToClass;
     }
 
+    String toString(Type t) {
+        return visit(t, Locale.getDefault());
+    }
+
     @Override
     protected String localize(Locale locale, String key, Object... args) {
         return messages.getLocalizedString(locale, key, args);
@@ -68,18 +71,6 @@
     }
 
     @Override
-    public String visitWildcardType(Type.WildcardType wt, Locale locale) {
-        if (useWildCard) { // at TypeArgument(ex: List<? extends T>)
-            return super.visitWildcardType(wt, locale);
-        } else { // at TopLevelType(ex: ? extends List<T>, ? extends Number[][])
-            Type extendsBound = wt.getExtendsBound();
-            return extendsBound == null
-                    ? OBJECT
-                    : visit(extendsBound, locale);
-        }
-    }
-
-    @Override
     public String visitType(Type t, Locale locale) {
         String s = (t.tsym == null || t.tsym.name == null)
                 ? OBJECT // none
@@ -87,20 +78,9 @@
         return s;
     }
 
-    @Override
-    public String visitClassType(ClassType ct, Locale locale) {
-        boolean prevUseWildCard = useWildCard;
-        try {
-            useWildCard = true;
-            return super.visitClassType(ct, locale);
-        } finally {
-            useWildCard = prevUseWildCard;
-        }
-    }
-
     /**
-     * Converts a class name into a (possibly localized) string. Anonymous
-     * inner classes get converted into a localized string.
+     * Converts a class name into a (possibly localized) string. Anonymous inner
+     * classes get converted into a localized string.
      *
      * @param t the type of the class whose name is to be rendered
      * @param longform if set, the class' fullname is displayed - if unset the
@@ -112,21 +92,13 @@
     protected String className(ClassType t, boolean longform, Locale locale) {
         Symbol sym = t.tsym;
         if (sym.name.length() == 0 && (sym.flags() & COMPOUND) != 0) {
-            /***
-            StringBuilder s = new StringBuilder(visit(t.supertype_field, locale));
-            for (List<Type> is = t.interfaces_field; is.nonEmpty(); is = is.tail) {
-                s.append('&');
-                s.append(visit(is.head, locale));
-            }
-            return s.toString();
-            ***/
             return OBJECT;
         } else if (sym.name.length() == 0) {
             // Anonymous
             String s;
             ClassType norm = (ClassType) t.tsym.type;
             if (norm == null) {
-                s = "object";
+                s = OBJECT;
             } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
                 s = visit(norm.interfaces_field.head, locale);
             } else {
@@ -160,7 +132,7 @@
     @Override
     public String visitPackageSymbol(PackageSymbol s, Locale locale) {
         return s.isUnnamed()
-                ? ""   // Unnamed package
+                ? "" // Unnamed package
                 : s.fullname.toString();
     }
 
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java	Tue Jan 24 00:30:25 2017 +0100
@@ -46,6 +46,7 @@
 import static java.util.stream.Collectors.toSet;
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_EVNT;
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN;
+import static jdk.internal.jshell.debug.InternalDebugControl.DBG_WRAP;
 import static jdk.jshell.Snippet.Status.OVERWRITTEN;
 import static jdk.jshell.Snippet.Status.RECOVERABLE_DEFINED;
 import static jdk.jshell.Snippet.Status.RECOVERABLE_NOT_DEFINED;
@@ -180,6 +181,8 @@
                     .collect(toList());
             // Set the outer wrap for this snippet
             si.setOuterWrap(state.outerMap.wrapInClass(except, plus, snippets, wraps));
+            state.debug(DBG_WRAP, "++setWrap() %s\n%s\n",
+                    si, si.outerWrap().wrapped());
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,265 @@
+/*
+ * 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 jdk.jshell;
+
+import java.util.HashSet;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.ClassType;
+import com.sun.tools.javac.util.JavacMessages;
+import java.util.Locale;
+import java.util.Set;
+import java.util.function.BinaryOperator;
+import com.sun.tools.javac.code.BoundKind;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.code.Type.CapturedType;
+import com.sun.tools.javac.code.Type.TypeMapping;
+import com.sun.tools.javac.code.Type.TypeVar;
+import com.sun.tools.javac.code.Type.WildcardType;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.code.Types.SimpleVisitor;
+import com.sun.tools.javac.util.List;
+import static com.sun.tools.javac.code.BoundKind.EXTENDS;
+import static com.sun.tools.javac.code.BoundKind.SUPER;
+import static com.sun.tools.javac.code.BoundKind.UNBOUND;
+import static com.sun.tools.javac.code.Type.ArrayType;
+import static com.sun.tools.javac.code.TypeTag.BOT;
+import static com.sun.tools.javac.code.TypeTag.WILDCARD;
+
+/**
+ * Print variable types in source form.
+ * TypeProjection and CaptureScanner are copied from Types in the JEP-286
+ * Sandbox by Maurizio.  The checks for Non-Denotable in TypePrinter are
+ * cribbed from denotableChecker of the same source.
+ *
+ * @author Maurizio Cimadamore
+ * @author Robert Field
+ */
+class VarTypePrinter extends TypePrinter {
+    private static final String WILD = "?";
+
+    private final Symtab syms;
+    private final Types types;
+
+    VarTypePrinter(JavacMessages messages, BinaryOperator<String> fullClassNameAndPackageToClass,
+            Symtab syms, Types types) {
+        super(messages, fullClassNameAndPackageToClass);
+        this.syms = syms;
+        this.types = types;
+    }
+
+    @Override
+    String toString(Type t) {
+        return super.toString(upward(t));
+    }
+
+    @Override
+    public String visitTypeVar(TypeVar t, Locale locale) {
+        /* Any type variable mentioned in the inferred type must have been declared as a type parameter
+                  (i.e cannot have been produced by inference (18.4))
+         */
+        // and beyond that, there are no global type vars, so if there are any
+        // type variables left, they need to be eliminated
+        return WILD; // Non-denotable
+    }
+
+    @Override
+    public String visitCapturedType(CapturedType t, Locale locale) {
+        /* Any type variable mentioned in the inferred type must have been declared as a type parameter
+                  (i.e cannot have been produced by capture conversion (5.1.10))
+         */
+        return WILD; // Non-denotable
+    }
+
+    public Type upward(Type t) {
+        List<Type> captures = captures(t);
+        return upward(t, captures);
+    }
+
+    /************* Following from JEP-286 Types.java ***********/
+
+    public Type upward(Type t, List<Type> vars) {
+        return t.map(new TypeProjection(vars), true);
+    }
+
+    public List<Type> captures(Type t) {
+        CaptureScanner cs = new CaptureScanner();
+        Set<Type> captures = new HashSet<>();
+        cs.visit(t, captures);
+        return List.from(captures);
+    }
+
+    class CaptureScanner extends SimpleVisitor<Void, Set<Type>> {
+
+        @Override
+        public Void visitType(Type t, Set<Type> types) {
+            return null;
+        }
+
+        @Override
+        public Void visitClassType(ClassType t, Set<Type> seen) {
+            if (t.isCompound()) {
+                types.directSupertypes(t).forEach(s -> visit(s, seen));
+            } else {
+                t.allparams().forEach(ta -> visit(ta, seen));
+            }
+            return null;
+        }
+
+        @Override
+        public Void visitArrayType(ArrayType t, Set<Type> seen) {
+            return visit(t.elemtype, seen);
+        }
+
+        @Override
+        public Void visitWildcardType(WildcardType t, Set<Type> seen) {
+            visit(t.type, seen);
+            return null;
+        }
+
+        @Override
+        public Void visitTypeVar(TypeVar t, Set<Type> seen) {
+            if ((t.tsym.flags() & Flags.SYNTHETIC) != 0 && seen.add(t)) {
+                visit(t.getUpperBound(), seen);
+            }
+            return null;
+        }
+
+        @Override
+        public Void visitCapturedType(CapturedType t, Set<Type> seen) {
+            if (seen.add(t)) {
+                visit(t.getUpperBound(), seen);
+                visit(t.getLowerBound(), seen);
+            }
+            return null;
+        }
+    }
+
+    class TypeProjection extends TypeMapping<Boolean> {
+
+        List<Type> vars;
+        Set<Type> seen = new HashSet<>();
+
+        public TypeProjection(List<Type> vars) {
+            this.vars = vars;
+        }
+
+        @Override
+        public Type visitClassType(ClassType t, Boolean upward) {
+            if (upward && !t.isCompound() && t.tsym.name.isEmpty()) {
+                //lift anonymous class type to first supertype (class or interface)
+                return types.directSupertypes(t).last();
+            } else if (t.isCompound()) {
+                List<Type> components = types.directSupertypes(t);
+                List<Type> components1 = components.map(c -> c.map(this, upward));
+                if (components == components1) return t;
+                else return types.makeIntersectionType(components1);
+            } else {
+                Type outer = t.getEnclosingType();
+                Type outer1 = visit(outer, upward);
+                List<Type> typarams = t.getTypeArguments();
+                List<Type> typarams1 = typarams.map(ta -> mapTypeArgument(ta, upward));
+                if (typarams1.stream().anyMatch(ta -> ta.hasTag(BOT))) {
+                    //not defined
+                    return syms.botType;
+                }
+                if (outer1 == outer && typarams1 == typarams) return t;
+                else return new ClassType(outer1, typarams1, t.tsym, t.getMetadata()) {
+                    @Override
+                    protected boolean needsStripping() {
+                        return true;
+                    }
+                };
+            }
+        }
+
+        protected Type makeWildcard(Type upper, Type lower) {
+            BoundKind bk;
+            Type bound;
+            if (upper.hasTag(BOT)) {
+                upper = syms.objectType;
+            }
+            boolean isUpperObject = types.isSameType(upper, syms.objectType);
+            if (!lower.hasTag(BOT) && isUpperObject) {
+                bound = lower;
+                bk = SUPER;
+            } else {
+                bound = upper;
+                bk = isUpperObject ? UNBOUND : EXTENDS;
+            }
+            return new WildcardType(bound, bk, syms.boundClass);
+        }
+
+        @Override
+        public Type visitTypeVar(TypeVar t, Boolean upward) {
+            if (vars.contains(t)) {
+                try {
+                    if (seen.add(t)) {
+                        return (upward ?
+                                t.getUpperBound() :
+                                (t.getLowerBound() == null) ?
+                                        syms.botType :
+                                        t.getLowerBound())
+                                    .map(this, upward);
+                    } else {
+                        //cycle
+                        return syms.objectType;
+                    }
+                } finally {
+                    seen.remove(t);
+                }
+            } else {
+                return t;
+            }
+        }
+
+        @Override
+        public Type visitWildcardType(WildcardType wt, Boolean upward) {
+            if (upward) {
+                return wt.isExtendsBound() ?
+                        wt.type.map(this, upward) :
+                        syms.objectType;
+            } else {
+                return wt.isSuperBound() ?
+                        wt.type.map(this, upward) :
+                        syms.botType;
+            }
+        }
+
+        private Type mapTypeArgument(Type t, boolean upward) {
+            if (!t.containsAny(vars)) {
+                return t;
+            } else if (!t.hasTag(WILDCARD) && !upward) {
+                //not defined
+                return syms.botType;
+            } else {
+                Type upper = t.map(this, upward);
+                Type lower = t.map(this, !upward);
+                return makeWildcard(upper, lower);
+            }
+        }
+    }
+}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java	Tue Jan 24 00:30:25 2017 +0100
@@ -115,12 +115,6 @@
     }
 
     @Override
-    public void setClasspath(String path)
-            throws EngineTerminationException, InternalException {
-        throw new NotImplementedException("setClasspath: Not supported yet.");
-    }
-
-    @Override
     public Class<?> findClass(String name) throws ClassNotFoundException {
         Class<?> klass = klasses.get(name);
         if (klass == null) {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DirectExecutionControl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DirectExecutionControl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -131,12 +131,6 @@
         loaderDelegate.addToClasspath(cp);
     }
 
-    @Override
-    public void setClasspath(String path)
-            throws EngineTerminationException, InternalException {
-        loaderDelegate.setClasspath(path);
-    }
-
     /**
      * {@inheritDoc}
      * <p>
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/ExecutionControlForwarder.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/ExecutionControlForwarder.java	Tue Jan 24 00:30:25 2017 +0100
@@ -147,12 +147,6 @@
                     ec.addToClasspath(cp);
                     return writeSuccess();
                 }
-                case CMD_SET_CLASSPATH: {
-                    // Set the claspath
-                    String cp = in.readUTF();
-                    ec.setClasspath(cp);
-                    return writeSuccess();
-                }
                 case CMD_STOP: {
                     // Stop the current execution
                     try {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LoaderDelegate.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LoaderDelegate.java	Tue Jan 24 00:30:25 2017 +0100
@@ -60,16 +60,6 @@
             throws EngineTerminationException, InternalException;
 
     /**
-     * Sets the execution class path to the specified path.
-     *
-     * @param path the path to add
-     * @throws EngineTerminationException the execution engine has terminated
-     * @throws InternalException an internal problem occurred
-     */
-    void setClasspath(String path)
-            throws EngineTerminationException, InternalException;
-
-    /**
      * Finds the class with the specified binary name.
      *
      * @param name the binary name of the class
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteCodes.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteCodes.java	Tue Jan 24 00:30:25 2017 +0100
@@ -66,10 +66,6 @@
      */
     static final String CMD_ADD_CLASSPATH  = "CMD_ADD_CLASSPATH";
     /**
-     * Set the class-path.
-     */
-    static final String CMD_SET_CLASSPATH  = "CMD_SET_CLASSPATH";
-    /**
      * Stop an invoke.
      */
     static final String CMD_STOP           = "CMD_STOP";
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/StreamingExecutionControl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/StreamingExecutionControl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -137,21 +137,6 @@
     }
 
     @Override
-    public void setClasspath(String path)
-            throws EngineTerminationException, InternalException {
-        try {
-            // Send the classpath addition command to the remote agent.
-            writeCommand(CMD_SET_CLASSPATH);
-            out.writeUTF(path);
-            out.flush();
-            // Retrieve and report results from the remote agent.
-            readAndReportClassSimpleResult();
-        } catch (IOException ex) {
-            throw new EngineTerminationException("Exception writing remote set classpath: " + ex);
-        }
-    }
-
-    @Override
     public void stop()
             throws EngineTerminationException, InternalException {
         try {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -118,16 +118,6 @@
             throws EngineTerminationException, InternalException;
 
     /**
-     * Sets the execution class path to the specified path.
-     *
-     * @param path the path to add
-     * @throws EngineTerminationException the execution engine has terminated
-     * @throws InternalException an internal problem occurred
-     */
-    void setClasspath(String path)
-            throws EngineTerminationException, InternalException;
-
-    /**
      * Interrupts a running invoke.
      *
      * @throws EngineTerminationException the execution engine has terminated
--- a/langtools/test/jdk/jshell/CompletionSuggestionTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/jdk/jshell/CompletionSuggestionTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -673,6 +673,7 @@
         keepParameterNames.set(getAnalysis(), new String[0]);
     }
 
+    @Test(enabled = false) //TODO 8171829
     public void testBrokenClassFile2() throws IOException {
         Path broken = outDir.resolve("broken");
         compiler.compile(broken,
--- a/langtools/test/jdk/jshell/KullaTesting.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/jdk/jshell/KullaTesting.java	Tue Jan 24 00:30:25 2017 +0100
@@ -99,7 +99,6 @@
 
     private Map<String, Snippet> idToSnippet = new LinkedHashMap<>();
     private Set<Snippet> allSnippets = new LinkedHashSet<>();
-    private List<String> classpath;
 
     static {
         JShell js = JShell.create();
@@ -159,7 +158,6 @@
     }
 
     public void addToClasspath(String path) {
-        classpath.add(path);
         getState().addToClasspath(path);
     }
 
@@ -200,7 +198,6 @@
         state = builder.build();
         allSnippets = new LinkedHashSet<>();
         idToSnippet = new LinkedHashMap<>();
-        classpath = new ArrayList<>();
     }
 
     @AfterMethod
@@ -210,7 +207,6 @@
         analysis = null;
         allSnippets = null;
         idToSnippet = null;
-        classpath = null;
     }
 
     public ClassLoader createAndRunFromModule(String moduleName, Path modPath) {
--- a/langtools/test/jdk/jshell/StopExecutionTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/jdk/jshell/StopExecutionTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8171385
  * @summary Test JShell#stop
  * @modules jdk.jshell/jdk.internal.jshell.tool
  * @build KullaTesting TestingInputStream
@@ -30,9 +31,13 @@
  */
 
 import java.io.IOException;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.Consumer;
 
 import jdk.internal.jshell.tool.StopDetectingInputStream;
 import jdk.internal.jshell.tool.StopDetectingInputStream.State;
@@ -128,4 +133,31 @@
         }
     }
 
+    public void testStopDetectingInputBufferWaitStop() throws Exception {
+        Runnable shouldNotHappenRun =
+                () -> { throw new AssertionError("Should not happen."); };
+        Consumer<Exception> shouldNotHappenExc =
+                exc -> { throw new AssertionError("Should not happen.", exc); };
+        StopDetectingInputStream sd = new StopDetectingInputStream(shouldNotHappenRun, shouldNotHappenExc);
+        CountDownLatch reading = new CountDownLatch(1);
+        PipedInputStream is = new PipedInputStream() {
+            @Override
+            public int read() throws IOException {
+                reading.countDown();
+                return super.read();
+            }
+        };
+        PipedOutputStream os = new PipedOutputStream(is);
+
+        sd.setInputStream(is);
+        sd.setState(State.BUFFER);
+        reading.await();
+        sd.setState(State.WAIT);
+        os.write(3);
+        int value = sd.read();
+
+        if (value != 3) {
+            throw new AssertionError();
+        }
+    }
 }
--- a/langtools/test/jdk/jshell/TypeNameTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/jdk/jshell/TypeNameTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -23,81 +23,229 @@
 
 /*
  * @test
- * @bug 8144903
+ * @bug 8144903 8171981
  * @summary Tests for determining the type from the expression
  * @build KullaTesting TestingInputStream
  * @run testng TypeNameTest
  */
 
-import jdk.jshell.Snippet;
-import jdk.jshell.VarSnippet;
 import org.testng.annotations.Test;
 
-import static jdk.jshell.Snippet.Status.VALID;
 import static org.testng.Assert.assertEquals;
 
 @Test
 public class TypeNameTest extends KullaTesting {
 
-    public void testReplClassName() {
-        assertEval("class C {}");
-        VarSnippet sn = (VarSnippet) varKey(assertEval("new C();"));
-        assertEquals(sn.typeName(), "C");
+
+    private void assertType(String expr, String type) {
+        assertEquals(varKey(assertEval(expr)).typeName(), type);
+        assertInferredType(expr, type);
+    }
+
+    public void testTypeInference() {
+        assertEval("import java.util.List;");
+        assertEval("import java.util.ArrayList;");
+        assertEval("import java.util.Arrays;");
+
+        assertType("new Object().getClass().getSuperclass() ", "Class<?>");
+        assertType("new ArrayList().getClass().getSuperclass()", "Class<?>");
+        assertType("new ArrayList().getClass()", "Class<? extends ArrayList>");
+        assertType("ArrayList.class", "Class<ArrayList>");
+        assertType("ArrayList.class.getSuperclass()", "Class<? super ArrayList>");
+
+        assertEval("class D<T extends CharSequence> { D<? super T> getS() { return null; } }");
+        assertEval("D<?> d = new D<String>();");
+        assertType("d.getS()", "D<? extends CharSequence>");
+        assertType("null", "Object");
+        assertType("Class.forName( \"java.util.ArrayList\" )", "Class<?>");
+        assertType("new ArrayList<Boolean>() {}", "ArrayList<Boolean>");
+        assertType("new ArrayList<String>().stream()", "java.util.stream.Stream<String>");
+        assertType("Arrays.asList( 1, 2, 3)", "List<Integer>");
+        assertType("new ArrayList().getClass().getClass()", "Class<? extends Class>");
+
+        assertEval("interface A {}");
+        assertEval("interface I {}");
+        assertEval("interface J extends A, I {}");
+        assertEval("interface K extends A, I {}");
+        assertEval("class P<T extends A & I> {}");
+        assertType("(P<?>) null", "P<? extends Object>");
+    }
+
+    public void testConditionals() {
+        assertEval("import java.util.List;");
+        assertEval("import java.util.ArrayList;");
+        assertEval("import java.util.Arrays;");
+
+        assertEval("CharSequence cs = \"hi\";");
+        assertEval("String st = \"low\";");
+        assertEval("boolean b;");
+        assertType("b? cs : st", "CharSequence");
+
+        assertEval("List<String> l1 = Arrays.asList(\"hi\");");
+        assertEval("List<? extends String> l2 = Arrays.asList(\"po\");");
+        assertType("b? l1.get(0) : l2.get(0)", "String");
+
+        assertEval("class X {}");
+        assertEval("class B extends X {}");
+        assertEval("class C extends X {}");
+        assertType("b? new B() : new C()", "X");
+    }
+
+    public void testJEP286NonDenotable() {
+        assertEval("import java.util.List;");
+        assertEval("import java.util.Arrays;");
+        assertEval("import java.util.Iterator;");
+
+        assertEval("List<? extends String> extString() { return Arrays.asList( \"hi\", \"low\" ); }");
+        assertEval("List<? super String> supString() { return Arrays.asList( \"hi\", \"low\" ); }");
+        assertEval("List<?> unbString() { return Arrays.asList( \"hi\", \"low\" ); }");
+        assertEval("List<? extends String>[] extStringArr() {" +
+                " @SuppressWarnings(\"unchecked\") " +
+                "List<? extends String>[] a = new List[1]; a[0] = Arrays.asList(\"hi\"); return a; }");
+        assertEval("List<? super String>[] supStringArr() {" +
+                " @SuppressWarnings(\"unchecked\") " +
+                "List<? super String>[] a = new List[1]; a[0] = Arrays.asList(\"hi\"); return a; }");
+        assertEval("List<?>[] unbStringArr() {" +
+                " @SuppressWarnings(\"unchecked\") " +
+                "List<?>[] a = new List[1]; a[0] = Arrays.asList(\"hi\"); return a; }");
+        assertEval("Iterable<? extends List<? extends String>> extStringIter() {" +
+                "return Arrays.asList( Arrays.asList( \"hi\" ) ); }");
+        assertEval("Iterable<? extends List<? super String>> supStringIter() {" +
+                "return Arrays.asList( Arrays.asList( \"hi\" ) ); }");
+        assertEval("Iterable<? extends List<?>> unbStringIter() {" +
+                "return Arrays.asList( Arrays.asList( \"hi\" ) ); }");
+        assertType("extString()", "List<? extends String>");
+        assertType("extString().get(0)", "String");
+        assertType("supString()", "List<? super String>");
+        assertType("supString().get(0)", "Object");
+        assertType("unbString()", "List<?>");
+        assertType("unbString().get(0)", "Object");
+        assertType("supStringArr()", "List<? super String>[]");
+        assertType("supStringArr()[0]", "List<? super String>");
+        assertType("supStringArr()[0].get(0)", "Object");
+        assertType("unbStringArr()", "List<?>[]");
+        assertType("unbStringArr()[0]", "List<?>");
+        assertType("unbStringArr()[0].get(0)", "Object");
+        assertType("extStringIter()", "Iterable<? extends List<? extends String>>");
+        assertType("extStringIter().iterator()", "Iterator<? extends List<? extends String>>");
+        assertType("extStringIter().iterator().next()", "List<? extends String>");
+        assertType("extStringIter().iterator().next().get(0)", "String");
+        assertType("supStringIter()", "Iterable<? extends List<? super String>>");
+        assertType("supStringIter().iterator()", "Iterator<? extends List<? super String>>");
+        assertType("supStringIter().iterator().next()", "List<? super String>");
+        assertType("supStringIter().iterator().next().get(0)", "Object");
+        assertType("unbStringIter()", "Iterable<? extends List<?>>");
+        assertType("unbStringIter().iterator()", "Iterator<? extends List<?>>");
+        assertType("unbStringIter().iterator().next()", "List<?>");
+        assertType("unbStringIter().iterator().next().get(0)", "Object");
+    }
+
+    public void testJEP286NonDenotable2() {
+        assertEval("import java.util.List;");
+        assertEval("import java.util.Arrays;");
+        assertEval("import java.lang.reflect.Array;");
+
+        assertEval("<Z extends Comparable<Z>> List<? extends Z> extFbound() {" +
+                "return Arrays.asList( (Z)null ); }");
+        assertEval("<Z extends Comparable<Z>> List<? super Z> supFbound() {" +
+                "return Arrays.asList( (Z)null ); }");
+        assertEval("<Z extends Comparable<Z>> List<? extends Z>[] extFboundArr() {" +
+                "@SuppressWarnings(\"unchecked\")" +
+                "List<? extends Z>[] a = new List[1]; a[0] = Arrays.asList( (Z)null ); return a; }");
+        assertEval("<Z extends Comparable<Z>> List<? super Z>[] supFboundArr() {" +
+                "@SuppressWarnings(\"unchecked\")" +
+                "List<? super Z>[] a = new List[1]; a[0] = Arrays.asList( (Z)null ); return a; }");
+        assertEval("<Z extends Comparable<Z>> Iterable<? extends List<? extends Z>> extFboundIter() {" +
+                "return Arrays.asList( Arrays.asList( (Z)null ) ); }");
+        assertEval("<Z extends Comparable<Z>> Iterable<? extends List<? super Z>> supFboundIter() {" +
+                "return Arrays.asList( Arrays.asList( (Z)null ) ); }");
+        assertEval("<Z> List<Z> listOf(Z z) { return Arrays.asList( z ); }");
+        assertEval("<Z> Z[] arrayOf(Z z) {" +
+                "@SuppressWarnings(\"unchecked\")" +
+                "final Z[] a = (Z[]) Array.newInstance(z.getClass(), 1); a[0] = z; return a; }");
+        assertType("extFbound()", "List<? extends Comparable<?>>");
+        assertType("extFbound().get(0)", "Comparable<?>");
+        assertType("supFbound()", "List<?>");
+        assertType("supFbound().get(0)", "Object");
+        assertType("extFboundArr()", "List<? extends Comparable<?>>[]");
+        assertType("extFboundArr()[0]", "List<? extends Comparable<?>>");
+        assertType("extFboundArr()[0].get(0)", "Comparable<?>");
+        assertType("supFboundArr()", "List<?>[]");
+        assertType("supFboundArr()[0]", "List<?>");
+        assertType("supFboundArr()[0].get(0)", "Object");
+        assertType("extFboundIter()", "Iterable<? extends List<? extends Comparable<?>>>");
+        assertType("extFboundIter().iterator()", "java.util.Iterator<? extends List<? extends Comparable<?>>>");
+        assertType("extFboundIter().iterator().next()", "List<? extends Comparable<?>>");
+        assertType("extFboundIter().iterator().next().get(0)", "Comparable<?>");
+        assertType("supFboundIter()", "Iterable<? extends List<?>>");
+        assertType("supFboundIter().iterator()", "java.util.Iterator<? extends List<?>>");
+        assertType("supFboundIter().iterator().next()", "List<?>");
+        assertType("supFboundIter().iterator().next().get(0)", "Object");
+        assertType("listOf(23)", "List<Integer>");
+        assertType("listOf(true)", "List<Boolean>");
+        assertType("listOf(true).get(0)", "Boolean");
+        assertType("arrayOf(99)", "Integer[]");
+        assertType("arrayOf(99)[0]", "Integer");
+
+        assertEval("<Z> Z choose(Z z1, Z z2) { return z1; }");
+        assertType("choose(1, 1L);", "Object");
+    }
+
+    public void testVariableTypeName() {
+        assertType("\"x\"", "String");
+
+        assertType("java.util.regex.Pattern.compile(\"x\")", "java.util.regex.Pattern");
+        assertEval("import java.util.regex.*;");
+        assertType("java.util.regex.Pattern.compile(\"x\")", "Pattern");
+
+        assertType("new java.util.ArrayList()", "java.util.ArrayList");
+        assertEval("import java.util.ArrayList;");
+        assertType("new java.util.ArrayList()", "ArrayList");
+
+        assertType("java.util.Locale.Category.FORMAT", "java.util.Locale.Category");
+        assertEval("import static java.util.Locale.Category;");
+        assertType("java.util.Locale.Category.FORMAT", "Category");
     }
 
     public void testReplNestedClassName() {
         assertEval("class D { static class E {} }");
-        VarSnippet sn = (VarSnippet) varKey(assertEval("new D.E();"));
-        assertEquals(sn.typeName(), "D.E");
+        assertType("new D.E();", "D.E");
     }
 
     public void testAnonymousClassName() {
         assertEval("class C {}");
-        VarSnippet sn = (VarSnippet) varKey(assertEval("new C() { int x; };"));
-        assertEquals(sn.typeName(), "C");
+        assertType("new C();", "C");
+        assertType("new C() { int x; };", "C");
     }
 
     public void testCapturedTypeName() {
-        VarSnippet sn = (VarSnippet) varKey(assertEval("\"\".getClass();"));
-        assertEquals(sn.typeName(), "Class<? extends String>");
-    }
-
-    public void testArrayTypeOfCapturedTypeName() {
-        VarSnippet sn = (VarSnippet) varKey(assertEval("\"\".getClass().getEnumConstants();"));
-        assertEquals(sn.typeName(), "String[]");
+        assertType("\"\".getClass();", "Class<? extends String>");
+        assertType("\"\".getClass().getEnumConstants();", "String[]");
     }
 
     public void testJavaLang() {
-        VarSnippet sn = (VarSnippet) varKey(assertEval("\"\";"));
-        assertEquals(sn.typeName(), "String");
+        assertType("\"\";", "String");
     }
 
     public void testNotOverEagerPackageEating() {
-        VarSnippet sn = (VarSnippet) varKey(assertEval("\"\".getClass().getDeclaredMethod(\"hashCode\");"));
-        assertEquals(sn.typeName(), "java.lang.reflect.Method");
+        assertType("\"\".getClass().getDeclaredMethod(\"hashCode\");", "java.lang.reflect.Method");
     }
 
     public void testBounds() {
         assertEval("java.util.List<? extends String> list1 = java.util.Arrays.asList(\"\");");
-        VarSnippet sn1 = (VarSnippet) varKey(assertEval("list1.iterator().next()"));
-        assertEquals(sn1.typeName(), "String");
+        assertType("list1.iterator().next()", "String");
         assertEval("java.util.List<? super String> list2 = java.util.Arrays.asList(\"\");");
-        VarSnippet sn2 = (VarSnippet) varKey(assertEval("list2.iterator().next()"));
-        assertEquals(sn2.typeName(), "Object");
+        assertType("list2.iterator().next()", "Object");
         assertEval("java.util.List<?> list3 = java.util.Arrays.asList(\"\");");
-        VarSnippet sn3 = (VarSnippet) varKey(assertEval("list3.iterator().next()"));
-        assertEquals(sn3.typeName(), "Object");
+        assertType("list3.iterator().next()", "Object");
         assertEval("class Test1<X extends CharSequence> { public X get() { return null; } }");
-        Snippet x = varKey(assertEval("Test1<?> test1 = new Test1<>();"));
-        VarSnippet sn4 = (VarSnippet) varKey(assertEval("test1.get()"));
-        assertEquals(sn4.typeName(), "Object");
+        assertEval("Test1<?> test1 = new Test1<>();");
+        assertType("test1.get()", "CharSequence");
         assertEval("class Test2<X extends Number & CharSequence> { public X get() { return null; } }");
         assertEval("Test2<?> test2 = new Test2<>();");
-        VarSnippet sn5 = (VarSnippet) varKey(assertEval("test2.get()"));
-        assertEquals(sn5.typeName(), "Object");
-        assertEval("class Test3<T> { T[][] get() { return null; } }", added(VALID));
+        assertType("test2.get()", "Object");
+        assertEval("class Test3<T> { T[][] get() { return null; } }");
         assertEval("Test3<? extends String> test3 = new Test3<>();");
-        VarSnippet sn6 = (VarSnippet) varKey(assertEval("test3.get()"));
-        assertEquals(sn6.typeName(), "String[][]");
+        assertType("test3.get()", "String[][]");
     }
 }
--- a/langtools/test/jdk/jshell/VariablesTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/jdk/jshell/VariablesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -337,20 +337,4 @@
         assertEquals(unr.get(0), "class undefined");
         assertVariables(variable("undefined", "d"));
     }
-
-    public void variableTypeName() {
-        assertEquals(varKey(assertEval("\"x\"")).typeName(), "String");
-
-        assertEquals(varKey(assertEval("java.util.regex.Pattern.compile(\"x\")")).typeName(), "java.util.regex.Pattern");
-        assertEval("import java.util.regex.*;", added(VALID));
-        assertEquals(varKey(assertEval("java.util.regex.Pattern.compile(\"x\")")).typeName(), "Pattern");
-
-        assertEquals(varKey(assertEval("new java.util.ArrayList()")).typeName(), "java.util.ArrayList");
-        assertEval("import java.util.ArrayList;", added(VALID));
-        assertEquals(varKey(assertEval("new java.util.ArrayList()")).typeName(), "ArrayList");
-
-        assertEquals(varKey(assertEval("java.util.Locale.Category.FORMAT")).typeName(), "java.util.Locale.Category");
-        assertEval("import static java.util.Locale.Category;", added(VALID));
-        assertEquals(varKey(assertEval("java.util.Locale.Category.FORMAT")).typeName(), "Category");
-    }
 }
--- a/langtools/test/tools/javac/T5003235/T5003235a.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/T5003235/T5003235a.java	Tue Jan 24 00:30:25 2017 +0100
@@ -3,7 +3,7 @@
  * @bug     5003235
  * @summary Private inner class accessible from subclasses
  * @author  Peter von der Ah\u00e9
- * @compile/fail/ref=T5003235a.out --diags:layout=%b:%l:%_%m T5003235a.java
+ * @compile/fail/ref=T5003235a.out -XDrawDiagnostics T5003235a.java
  */
 
 class Super {
--- a/langtools/test/tools/javac/T5003235/T5003235a.out	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/T5003235/T5003235a.out	Tue Jan 24 00:30:25 2017 +0100
@@ -1,13 +1,5 @@
-T5003235a.java:21: defaultM() in Super.Inner is defined in an inaccessible class or interface
-        i.defaultM();
-         ^
-T5003235a.java:22: protectedM() in Super.Inner is defined in an inaccessible class or interface
-        i.protectedM();
-         ^
-T5003235a.java:23: publicM() in Super.Inner is defined in an inaccessible class or interface
-        i.publicM();
-         ^
-T5003235a.java:24: privateM() in Super.Inner is defined in an inaccessible class or interface
-        i.privateM();
-         ^
+T5003235a.java:21:10: compiler.err.not.def.access.class.intf.cant.access: defaultM(), Super.Inner
+T5003235a.java:22:10: compiler.err.not.def.access.class.intf.cant.access: protectedM(), Super.Inner
+T5003235a.java:23:10: compiler.err.not.def.access.class.intf.cant.access: publicM(), Super.Inner
+T5003235a.java:24:10: compiler.err.not.def.access.class.intf.cant.access: privateM(), Super.Inner
 4 errors
--- a/langtools/test/tools/javac/T5003235/T5003235b.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/T5003235/T5003235b.java	Tue Jan 24 00:30:25 2017 +0100
@@ -3,7 +3,7 @@
  * @bug     5003235
  * @summary Accessibility of private inner class
  * @author  Peter von der Ah\u00e9
- * @compile/fail/ref=T5003235b.out --diags:layout=%b:%l:%_%m T5003235b.java
+ * @compile/fail/ref=T5003235b.out -XDrawDiagnostics T5003235b.java
  */
 
 class Outer {
--- a/langtools/test/tools/javac/T5003235/T5003235b.out	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/T5003235/T5003235b.out	Tue Jan 24 00:30:25 2017 +0100
@@ -1,13 +1,5 @@
-T5003235b.java:28: k in Outer.Inner is defined in an inaccessible class or interface
-        System.out.println("Value of k: " + outer.inner.k);
-                                                       ^
-T5003235b.java:29: l in Outer.Inner is defined in an inaccessible class or interface
-        System.out.println("Value of l: " + outer.inner.l);
-                                                       ^
-T5003235b.java:30: m in Outer.Inner is defined in an inaccessible class or interface
-        System.out.println("Value of m: " + outer.inner.m);
-                                                       ^
-T5003235b.java:31: n in Outer.Inner is defined in an inaccessible class or interface
-        System.out.println("Value of n: " + outer.inner.n);
-                                                       ^
+T5003235b.java:28:56: compiler.err.not.def.access.class.intf.cant.access: k, Outer.Inner
+T5003235b.java:29:56: compiler.err.not.def.access.class.intf.cant.access: l, Outer.Inner
+T5003235b.java:30:56: compiler.err.not.def.access.class.intf.cant.access: m, Outer.Inner
+T5003235b.java:31:56: compiler.err.not.def.access.class.intf.cant.access: n, Outer.Inner
 4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,21 @@
+/*
+ * @test  /nodynamiccopyright/
+ * @bug 8171325
+ * @summary NPE in Check.clearLocalClassNameIndexes
+ * @compile/fail/ref=NPEClearingLocalClassNameIndexesTest.out -XDrawDiagnostics NPEClearingLocalClassNameIndexesTest.java
+ */
+
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+public class NPEClearingLocalClassNameIndexesTest {
+    <A> void f(List<A> t) {}
+    <B, C> C g(C u, Function<B, C> v) { return null; }
+    <D> D g(Supplier<D> w) { return null; }
+
+    public void test() {
+        f(g((String) null, task -> g(new NoSuch() {})));
+        f(g((String) null, task -> g(new NoSuch<int>() {})));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.out	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,6 @@
+NPEClearingLocalClassNameIndexesTest.java:18:9: compiler.err.cant.apply.symbol: kindname.method, f, java.util.List<A>, java.lang.String, kindname.class, NPEClearingLocalClassNameIndexesTest, (compiler.misc.incompatible.upper.lower.bounds: C, java.lang.Object,java.util.List<A>, java.lang.String)
+NPEClearingLocalClassNameIndexesTest.java:18:42: compiler.err.cant.resolve.location: kindname.class, NoSuch, , , (compiler.misc.location: kindname.class, NPEClearingLocalClassNameIndexesTest, null)
+NPEClearingLocalClassNameIndexesTest.java:19:9: compiler.err.cant.apply.symbol: kindname.method, f, java.util.List<A>, java.lang.String, kindname.class, NPEClearingLocalClassNameIndexesTest, (compiler.misc.incompatible.upper.lower.bounds: C, java.lang.Object,java.util.List<A>, java.lang.String)
+NPEClearingLocalClassNameIndexesTest.java:19:42: compiler.err.cant.resolve.location: kindname.class, NoSuch, , , (compiler.misc.location: kindname.class, NPEClearingLocalClassNameIndexesTest, null)
+NPEClearingLocalClassNameIndexesTest.java:19:49: compiler.err.type.found.req: int, (compiler.misc.type.req.ref)
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8171332/Buggy.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+@Deprecated enum Buggy implements Buggy {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8171332/Processor.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,21 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 8171332
+ * @summary 8171332: NPE in MembersPhase.finishClass
+ * @modules java.compiler
+ *          jdk.compiler
+ * @build Processor
+ * @compile/fail/ref=Processor.out -XDrawDiagnostics -processor Processor Buggy.java
+ */
+
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.element.TypeElement;
+
+@SupportedAnnotationTypes("*")
+public class Processor extends AbstractProcessor {
+    @Override
+    public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) {
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8171332/Processor.out	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,3 @@
+Buggy.java:24:35: compiler.err.intf.expected.here
+Buggy.java:24:13: compiler.err.cyclic.inheritance: Buggy
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,6 @@
+/*
+ * @test  /nodynamiccopyright/
+ * @bug 8171528
+ * @summary Crash in Annotate with duplicate package-info declarations
+ * @compile/fail/ref=DuplicatedAnnotatedPackagesTest.out -XDrawDiagnostics pkg1/package-info.java pkg2/package-info.java
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.out	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,4 @@
+package-info.java:2:9: compiler.warn.pkg-info.already.seen: test
+package-info.java:1:1: compiler.err.already.annotated: kindname.package, test
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8171528/pkg1/package-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,2 @@
+@Deprecated
+package test;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8171528/pkg2/package-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,2 @@
+@Deprecated
+package test;
--- a/langtools/test/tools/javac/diags/Example.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/diags/Example.java	Tue Jan 24 00:30:25 2017 +0100
@@ -61,9 +61,10 @@
         declaredKeys = new TreeSet<String>();
         srcFiles = new ArrayList<File>();
         procFiles = new ArrayList<File>();
-        supportFiles = new ArrayList<File>();
         srcPathFiles = new ArrayList<File>();
         moduleSourcePathFiles = new ArrayList<File>();
+        modulePathFiles = new ArrayList<File>();
+        classPathFiles = new ArrayList<File>();
         additionalFiles = new ArrayList<File>();
 
         findFiles(file, srcFiles);
@@ -89,10 +90,13 @@
                 } else if (files == srcFiles && c.getName().equals("additional")) {
                     additionalFilesDir = c;
                     findFiles(c, additionalFiles);
-                } else if (files == srcFiles && c.getName().equals("support"))
-                    findFiles(c, supportFiles);
-                else
+                } else if (files == srcFiles && c.getName().equals("modulepath")) {
+                    findFiles(c, modulePathFiles);
+                } else if (files == srcFiles && c.getName().equals("classpath")) {
+                    findFiles(c, classPathFiles);
+                } else {
                     findFiles(c, files);
+                }
             }
         } else if (f.isFile()) {
                 if (f.getName().endsWith(".java")) {
@@ -194,23 +198,32 @@
      */
     private void run(PrintWriter out, Set<String> keys, boolean raw, boolean verbose)
             throws IOException {
-        ClassLoader loader = getClass().getClassLoader();
-        if (supportFiles.size() > 0) {
-            File supportDir = new File(tempDir, "support");
-            supportDir.mkdirs();
-            clean(supportDir);
-            List<String> sOpts = Arrays.asList("-d", supportDir.getPath());
-            new Jsr199Compiler(verbose).run(null, null, false, sOpts, procFiles);
-            URLClassLoader ucl =
-                    new URLClassLoader(new URL[] { supportDir.toURI().toURL() }, loader);
-            loader = ucl;
+        List<String> opts = new ArrayList<String>();
+        if (!modulePathFiles.isEmpty()) {
+            File modulepathDir = new File(tempDir, "modulepath");
+            modulepathDir.mkdirs();
+            clean(modulepathDir);
+            List<String> sOpts = Arrays.asList("-d", modulepathDir.getPath(),
+                                               "--module-source-path", new File(file, "modulepath").getAbsolutePath());
+            new Jsr199Compiler(verbose).run(null, null, false, sOpts, modulePathFiles);
+            opts.add("--module-path");
+            opts.add(modulepathDir.getAbsolutePath());
+        }
+
+        if (!classPathFiles.isEmpty()) {
+            File classpathDir = new File(tempDir, "classpath");
+            classpathDir.mkdirs();
+            clean(classpathDir);
+            List<String> sOpts = Arrays.asList("-d", classpathDir.getPath());
+            new Jsr199Compiler(verbose).run(null, null, false, sOpts, classPathFiles);
+            opts.add("--class-path");
+            opts.add(classpathDir.getAbsolutePath());
         }
 
         File classesDir = new File(tempDir, "classes");
         classesDir.mkdirs();
         clean(classesDir);
 
-        List<String> opts = new ArrayList<String>();
         opts.add("-d");
         opts.add(classesDir.getPath());
         if (options != null)
@@ -327,8 +340,9 @@
     File additionalFilesDir;
     List<File> srcPathFiles;
     List<File> moduleSourcePathFiles;
+    List<File> modulePathFiles;
+    List<File> classPathFiles;
     List<File> additionalFiles;
-    List<File> supportFiles;
     File infoFile;
     private List<String> runOpts;
     private List<String> options;
--- a/langtools/test/tools/javac/diags/RunExamples.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/diags/RunExamples.java	Tue Jan 24 00:30:25 2017 +0100
@@ -239,8 +239,10 @@
                     srcFiles.remove(e.infoFile);
                     showFiles(e, srcFiles);
                     showFiles(e, e.srcPathFiles);
+                    showFiles(e, e.moduleSourcePathFiles);
+                    showFiles(e, e.modulePathFiles);
+                    showFiles(e, e.classPathFiles);
                     showFiles(e, e.procFiles);
-                    showFiles(e, e.supportFiles);
                 }
                 run(e);
             }
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Tue Jan 24 00:30:25 2017 +0100
@@ -20,11 +20,13 @@
 compiler.err.limit.stack                                # Code
 compiler.err.limit.string                               # Gen
 compiler.err.limit.string.overflow                      # JavaCompiler
+compiler.err.module.non.zero.opens                      # bad class file
 compiler.err.name.reserved.for.internal.use             # UNUSED
 compiler.err.no.annotation.member
 compiler.err.no.encl.instance.of.type.in.scope          # cannot occur; always followed by assert false;
 compiler.err.no.match.entry                             # UNUSED?
 compiler.err.not.annotation.type                        # cannot occur given preceding checkType
+compiler.err.not.def.access.package.cant.access
 compiler.err.proc.bad.config.file                       # JavacProcessingEnvironment
 compiler.err.proc.cant.access                           # completion failure
 compiler.err.proc.cant.access.1                         # completion failure, no stack trace
@@ -69,10 +71,11 @@
 compiler.misc.kindname.value
 compiler.misc.incompatible.eq.lower.bounds              # cannot happen?
 compiler.misc.module.name.mismatch
+compiler.misc.module.non.zero.opens                     # bad class file
 compiler.misc.no.unique.minimal.instance.exists
 compiler.misc.no.unique.maximal.instance.exists         # cannot happen?
-compiler.err.module.non.zero.opens                      # bad class file
-compiler.misc.module.non.zero.opens                     # bad class file
+compiler.misc.not.def.access.package.cant.access
+compiler.misc.package.not.visible
 compiler.misc.resume.abort                              # prompt for a response
 compiler.misc.source.unavailable                        # DiagnosticSource
 compiler.misc.token.bad-symbol
@@ -117,6 +120,7 @@
 compiler.misc.bad.const.pool.entry                      # constant pool entry has wrong type
 compiler.warn.access.to.member.from.serializable.lambda # in order to generate it we need to modify a restricted package
 compiler.warn.invalid.path                              # this warning is generated only in Windows systems
+compiler.note.multiple.elements                         # needs user code
 
 # The following module-related messages will have to stay on the not-yet list for various reasons:
 compiler.warn.locn.unknown.file.on.module.path                # Never issued ATM (short circuited with an if (false))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/NotDefAccessClassIntfCantAccessReason.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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.
+ */
+
+//key: compiler.err.not.def.access.class.intf.cant.access.reason
+//key: compiler.misc.not.def.access.does.not.read
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/api1/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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 api1;
+
+public class Api {
+    public static void test() {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 apia {
+    exports api1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/api2/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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 api2;
+
+public class Api {
+    public static api1.Api get() { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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 apib {
+    requires apia;
+    exports api2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/impl/Impl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,30 @@
+/*
+ * 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 impl;
+
+public class Impl {
+    void test() {
+        api2.Api.get().test();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 impl {
+    requires apib;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/NotDefAccessClassIntfCantAccessReason.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.prob.found.req
+// key: compiler.misc.invalid.mref
+// key: compiler.misc.not.def.access.class.intf.cant.access.reason
+// key: compiler.misc.not.def.access.does.not.read
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/api1/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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 api1;
+
+public class Api {
+    public static void test() {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 apia {
+    exports api1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/api2/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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 api2;
+
+public class Api {
+    public static api1.Api get() { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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 apib {
+    requires apia;
+    exports api2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/impl/Impl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,30 @@
+/*
+ * 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 impl;
+
+public class Impl {
+    void test(api2.Api a2) {
+        Runnable r = a2.get() :: test;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 impl {
+    requires apib;
+}
--- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/NotDefAccessClassPackageCantAccess.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +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.
- */
-
-// key: compiler.err.not.def.access.package.cant.access
--- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +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.
- */
-
-module m1x {}
--- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/p1/C1.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p1;
-
-public class C1 {}
--- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/module-info.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +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.
- */
-
-module m2x {}
--- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/p2/C2.java	Wed Jan 25 15:31:01 2017 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p2;
-
-public class C2 {
-    p1.C1 c1;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/NotDefAccessDoesNotRead.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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.
+ */
+
+//key: compiler.err.package.not.visible
+//key: compiler.misc.not.def.access.does.not.read
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/api/api/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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 api;
+
+public class Api {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/api/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 api {
+    exports api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/impl/Impl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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 impl;
+
+public class Impl {
+    api.Api api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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 impl {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/NotDefAccessDoesNotReadFromUnnamed.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+//key: compiler.err.package.not.visible
+//key: compiler.misc.not.def.access.does.not.read.from.unnamed
+
+public class NotDefAccessDoesNotReadFromUnnamed {
+     api.Api api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/api/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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 api;
+
+public class Api {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 api {
+    exports api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/NotDefAccessDoesNotReadUnnamed.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+//key: compiler.err.not.def.access.class.intf.cant.access.reason
+//key: compiler.misc.not.def.access.does.not.read.unnamed
+//options: --add-reads=auxiliary=ALL-UNNAMED
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/classpath/api/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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 api;
+
+public class Api {
+    public void test() {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/auxiliary/Auxiliary.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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 auxiliary;
+
+public class Auxiliary {
+    public static api.Api get() { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 auxiliary {
+    exports auxiliary;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/impl/Impl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,30 @@
+/*
+ * 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 impl;
+
+public class Impl {
+    {
+        auxiliary.Auxiliary.get().test();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 impl {
+    requires auxiliary;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/NotDefAccessNotExported.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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.
+ */
+
+//key: compiler.err.package.not.visible
+//key: compiler.misc.not.def.access.not.exported
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/api/api/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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 api;
+
+public class Api {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/api/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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 api {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/impl/Impl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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 impl;
+
+public class Impl {
+    api.Api api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 impl {
+    requires api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/NotDefAccessNotExportedFromUnnamed.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+//key: compiler.err.package.not.visible
+//key: compiler.misc.not.def.access.not.exported.from.unnamed
+//options: --add-modules api
+
+public class NotDefAccessNotExportedFromUnnamed {
+     api.Api api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/modulepath/api/api/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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 api;
+
+public class Api {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/modulepath/api/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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 api {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/NotDefAccessNotExportedToModule.java	Tue Jan 24 00:30:25 2017 +0100
@@ -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.
+ */
+
+//key: compiler.err.package.not.visible
+//key: compiler.misc.not.def.access.not.exported.to.module
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/api/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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 api;
+
+public class Api {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 api {
+    exports api to other;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/impl/Impl.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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 impl;
+
+public class Impl {
+    api.Api api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 impl {
+    requires api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/other/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 other {
+     requires api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/NotDefAccessNotExportedToModuleFromUnnamed.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+//key: compiler.err.package.not.visible
+//key: compiler.misc.not.def.access.not.exported.to.module.from.unnamed
+//options: --add-modules api
+
+public class NotDefAccessNotExportedToModuleFromUnnamed {
+     api.Api api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/api/Api.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,27 @@
+/*
+ * 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 api;
+
+public class Api {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 api {
+    exports api to other;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/other/module-info.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,26 @@
+/*
+ * 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 other {
+     requires api;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doclint/DocLintFormatTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8172474
+ * @summary javac should enable doclint checking for HTML 5
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask
+ * @run main DocLintFormatTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class DocLintFormatTest {
+    public static void main(String... args) throws Exception {
+        new DocLintFormatTest().run();
+    }
+
+    private ToolBox tb = new ToolBox();
+    private Path src = Paths.get("src");
+    private Path classes = Paths.get("classes");
+
+    void run() throws Exception {
+        Files.createDirectories(classes);
+
+        tb.writeJavaFiles(src,
+            //        1         2
+            //2345678901234567890
+            "/** This is an <tt>HTML 4</tt> comment. */ public class Test4 { }",
+            "/** This is an <mark>HTML 5</mark> comment. */ public class Test5 { }"
+        );
+
+        test(src.resolve("Test4.java"), "html4");
+        test(src.resolve("Test4.java"), "html5",
+                "Test4.java:1:16: compiler.err.proc.messager: tag not supported in the generated HTML version: tt");
+        test(src.resolve("Test5.java"), "html4",
+                "Test5.java:1:16: compiler.err.proc.messager: tag not supported in the generated HTML version: mark");
+        test(src.resolve("Test5.java"), "html5");
+
+        if (errors > 0) {
+            throw new Exception(errors + " errors occurred");
+        }
+    }
+
+    void test(Path file, String format, String... expect) {
+        System.err.println("Test: " + format + " " + file);
+        List<String> output = new JavacTask(tb)
+                  .outdir(classes)
+                  .options("-XDrawDiagnostics", "-Xdoclint", "--doclint-format", format)
+                  .files(file)
+                  .run(expect.length == 0 ? Task.Expect.SUCCESS : Task.Expect.FAIL)
+                  .writeAll()
+                  .getOutputLines(Task.OutputKind.DIRECT);
+
+        if (expect.length == 0) {
+            if (!(output.size() == 1 && output.get(0).isEmpty())) {
+                error("All output unexpected.");
+            }
+        } else {
+            for (String e : expect) {
+                if (!output.contains(e)) {
+                    error("expected output not found: " + e);
+                }
+            }
+        }
+    }
+
+    void error(String message) {
+        System.err.println("Error: " + message);
+        errors++;
+    }
+
+    private int errors = 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReferenceVarargsTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8171993
+ * @summary AssertionError when compiling method reference with generic code and varargs.
+ * @compile MethodReferenceVarargsTest.java
+ */
+
+public class MethodReferenceVarargsTest<T> {
+    public T invoke(Object... args) {
+        return null;
+    }
+    public static <T extends String> void test() { // works with <T> alone.
+        MethodReferenceVarargsTest<T> bug = new MethodReferenceVarargsTest<>();
+        java.util.function.Function<String, T> b = bug::invoke;
+        java.util.function.Function<String, T> f = (args) -> bug.invoke(args);
+    }
+}
\ No newline at end of file
--- a/langtools/test/tools/javac/modules/AddLimitMods.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java	Tue Jan 24 00:30:25 2017 +0100
@@ -217,8 +217,8 @@
 
     private static final List<Entry<String[], String>> variants = Arrays.asList(
             new SimpleEntry<String[], String>(new String[] {},
-                                              "Test.java:2:18: compiler.err.doesnt.exist: javax.annotation\n"
-                                            + "Test.java:5:19: compiler.err.doesnt.exist: javax.xml.bind\n"
+                                              "Test.java:2:7: compiler.err.package.not.visible: javax.annotation, (compiler.misc.not.def.access.does.not.read.from.unnamed: javax.annotation, java.annotations.common)\n"
+                                            + "Test.java:5:14: compiler.err.package.not.visible: javax.xml.bind, (compiler.misc.not.def.access.does.not.read.from.unnamed: javax.xml.bind, java.xml.bind)\n"
                                             + "2 errors\n"),
             new SimpleEntry<String[], String>(new String[] {"--add-modules", "java.annotations.common,java.xml.bind"},
                                               null),
--- a/langtools/test/tools/javac/modules/AddReadsTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/AddReadsTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -81,7 +81,7 @@
                 .getOutput(Task.OutputKind.DIRECT);
 
         checkOutputContains(log,
-            "Test.java:1:44: compiler.err.not.def.access.package.cant.access: api.Api, api");
+            "Test.java:1:41: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m2x, api, m1x)");
 
         //test add dependencies:
         new JavacTask(tb)
--- a/langtools/test/tools/javac/modules/AnnotationProcessing.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/AnnotationProcessing.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 8133884 8162711 8133896 8172158
+ * @bug 8133884 8162711 8133896 8172158 8172262
  * @summary Verify that annotation processing works.
  * @library /tools/lib
  * @modules
@@ -50,6 +50,7 @@
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.function.Function;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 import javax.annotation.processing.AbstractProcessor;
@@ -1067,24 +1068,43 @@
                           "package impl1; public class Impl { }",
                           "package impl.conflict.module; class Impl { }",
                           "package impl.conflict.clazz; public class pkg { public static class I { } }",
-                          "package impl.conflict.src; public class Impl { }");
+                          "package impl.conflict.src; public class Impl { }",
+                          "package nested.pack.pack; public class Impl { }",
+                          "package unique.nested; public class Impl { }");
 
         tb.writeJavaFiles(m2,
                           "module m2x { }",
                           "package impl2; public class Impl { }",
                           "package impl.conflict.module; class Impl { }",
-                          "package impl.conflict; public class clazz { public static class pkg { } }");
+                          "package impl.conflict; public class clazz { public static class pkg { } }",
+                          "package nested.pack; public class Impl { }");
 
         //from source:
-        new JavacTask(tb)
+        String log = new JavacTask(tb)
             .options("--module-source-path", moduleSrc.toString(),
                      "--source-path", src.toString(),
                      "-processorpath", System.getProperty("test.class.path"),
-                     "-processor", UnboundLookup.class.getName())
+                     "-processor", UnboundLookup.class.getName(),
+                     "-XDrawDiagnostics")
             .outdir(classes)
             .files(findJavaFiles(moduleSrc))
             .run()
-            .writeAll();
+            .writeAll()
+            .getOutput(OutputKind.DIRECT);
+
+        String moduleImplConflictString =
+                "- compiler.note.multiple.elements: getTypeElement, impl.conflict.module.Impl, m2x, m1x";
+        String srcConflictString =
+                "- compiler.note.multiple.elements: getTypeElement, impl.conflict.src.Impl, m1x, unnamed module";
+
+        if (!log.contains(moduleImplConflictString) ||
+            !log.contains(srcConflictString)) {
+            throw new AssertionError("Expected output not found: " + log);
+        }
+
+        if (log.split(Pattern.quote(moduleImplConflictString)).length > 2) {
+            throw new AssertionError("Too many warnings in: " + log);
+        }
 
         new JavacTask(tb)
             .options("--source-path", src.toString())
@@ -1130,11 +1150,17 @@
             assertTypeElementExists("impl.conflict.clazz", "m2x");
             assertPackageElementExists("impl.conflict.clazz", "m1x");
             assertPackageElementExists("impl2", "m2x");
+            assertPackageElementExists("nested.pack.pack", "m1x");
+            assertPackageElementExists("nested.pack", "m2x");
+            assertTypeElementExists("unique.nested.Impl", "m1x");
             assertTypeElementNotFound("impl.conflict.module.Impl");
+            assertTypeElementNotFound("impl.conflict.module.Impl"); //check that the warning/note is produced only once
             assertPackageElementNotFound("impl.conflict.module");
             assertTypeElementNotFound("impl.conflict.src.Impl");
             assertPackageElementNotFound("impl.conflict.src");
             assertTypeElementNotFound("impl.conflict.clazz.pkg");
+            assertPackageElementNotFound("unique"); //do not return packages without members in module mode
+            assertTypeElementNotFound("nested"); //cannot distinguish between m1x and m2x
 
             return false;
         }
--- a/langtools/test/tools/javac/modules/AutomaticModules.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/AutomaticModules.java	Tue Jan 24 00:30:25 2017 +0100
@@ -283,7 +283,7 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        List<String> expected = Arrays.asList("Impl.java:1:62: compiler.err.not.def.access.package.cant.access: m2x.M2, m2x",
+        List<String> expected = Arrays.asList("Impl.java:1:59: compiler.err.package.not.visible: m2x, (compiler.misc.not.def.access.does.not.read: m1x, m2x, m2x)",
                                               "1 error");
 
         if (!expected.equals(log)) {
@@ -300,8 +300,8 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        expected = Arrays.asList("Impl.java:1:51: compiler.err.doesnt.exist: apiB",
-                                 "Impl.java:1:62: compiler.err.not.def.access.package.cant.access: m2x.M2, m2x",
+        expected = Arrays.asList("Impl.java:1:47: compiler.err.package.not.visible: apiB, (compiler.misc.not.def.access.does.not.read: m1x, apiB, automaticB)",
+                                 "Impl.java:1:59: compiler.err.package.not.visible: m2x, (compiler.misc.not.def.access.does.not.read: m1x, m2x, m2x)",
                                  "2 errors");
 
         if (!expected.equals(log)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,596 @@
+/*
+ * 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 8169197 8172668
+ * @summary Check convenient errors are produced for inaccessible classes.
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase
+ * @run main ConvenientAccessErrorsTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+
+import toolbox.JarTask;
+import toolbox.JavacTask;
+import toolbox.Task;
+
+public class ConvenientAccessErrorsTest extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        new ConvenientAccessErrorsTest().runTests();
+    }
+
+    @Test
+    public void testNoDep(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { exports api; }",
+                          "package api; public class Api { public void call() { } }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { }",
+                          "package test; public class Test { api.Api api; }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m2x, api, m1x)",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
+    public void testNotExported(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { exports api; }",
+                          "package api; public class Api { }",
+                          "package impl; public class Impl { }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { requires m1x; }",
+                          "package test; public class Test { impl.Impl api; }");
+        Path src_m3 = src.resolve("m3x");
+        tb.writeJavaFiles(src_m3,
+                          "module m3x { requires m1x; }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:35: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.not.exported: impl, m1x)",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { exports api; exports impl to m3x;}");
+
+        log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList(
+                "Test.java:1:35: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.not.exported.to.module: impl, m1x, m2x)",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
+    public void testInaccessibleInExported(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { exports api; }",
+                          "package api; class Api { }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { requires m1x; }",
+                          "package test; public class Test { api.Api api; }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:38: compiler.err.not.def.public.cant.access: api.Api, api",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+//    @Test
+    public void testInaccessibleUnnamedModule(Path base) throws Exception {
+        Path jar = prepareTestJar(base, "package api; class Api { public static class Foo {} }");
+
+        Path moduleSrc = base.resolve("module-src");
+        Path m1x = moduleSrc.resolve("m1x");
+
+        Path classes = base.resolve("classes");
+
+        Files.createDirectories(classes);
+
+        tb.writeJavaFiles(m1x,
+                          "module m1x { }",
+                          "package test; public class Test { api.Api api; api.Api.Foo api; }");
+
+        List<String> log = new JavacTask(tb)
+                .options("-classpath", jar.toString(),
+                         "-XDrawDiagnostics")
+                .outdir(classes)
+                .files(findJavaFiles(moduleSrc))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:38: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)",
+                "Test.java:1:51: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)",
+                "2 errors");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
+    public void testIndirectReferenceToUnnamedModule(Path base) throws Exception {
+        Path jar = prepareTestJar(base, "package api; public class Api { public void test() {} }");
+
+        Path moduleSrc = base.resolve("module-src");
+        Path m1x = moduleSrc.resolve("m1x");
+        Path auxiliary = moduleSrc.resolve("auxiliary");
+
+        Path classes = base.resolve("classes");
+
+        Files.createDirectories(classes);
+
+        tb.writeJavaFiles(m1x,
+                          "module m1x { requires auxiliary; }",
+                          "package test; public class Test { { auxiliary.Auxiliary.get().test(); } }");
+
+        tb.writeJavaFiles(auxiliary,
+                          "module auxiliary { exports auxiliary; }",
+                          "package auxiliary; public class Auxiliary { public static api.Api get() { return null; } }");
+
+        List<String> log = new JavacTask(tb)
+                .options("-classpath", jar.toString(),
+                         "-XDrawDiagnostics",
+                         "--add-reads", "auxiliary=ALL-UNNAMED",
+                         "--module-source-path", moduleSrc.toString())
+                .outdir(classes)
+                .files(findJavaFiles(moduleSrc))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:62: compiler.err.not.def.access.class.intf.cant.access.reason: test(), api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    private Path prepareTestJar(Path base, String code) throws Exception {
+        Path legacySrc = base.resolve("legacy-src");
+        tb.writeJavaFiles(legacySrc, code);
+        Path legacyClasses = base.resolve("legacy-classes");
+        Files.createDirectories(legacyClasses);
+
+        String log = new JavacTask(tb)
+                .options()
+                .outdir(legacyClasses)
+                .files(findJavaFiles(legacySrc))
+                .run()
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.isEmpty()) {
+            throw new Exception("unexpected output: " + log);
+        }
+
+        Path lib = base.resolve("lib");
+
+        Files.createDirectories(lib);
+
+        Path jar = lib.resolve("test-api-1.0.jar");
+
+        new JarTask(tb, jar)
+          .baseDir(legacyClasses)
+          .files("api/Api.class")
+          .run();
+
+        return jar;
+    }
+
+    @Test
+    public void testUnnamedModuleAccess(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { exports api to m2x; }",
+                          "package api; class Api { }",
+                          "package impl; class Impl { }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { requires m1x; }");
+        Path modulepath = base.resolve("modulepath");
+        tb.createDirectories(modulepath);
+
+        new JavacTask(tb)
+                .options("--module-source-path", src.toString())
+                .outdir(modulepath)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll();
+
+        Path unnamedSrc = base.resolve("unnamedSrc");
+        tb.writeJavaFiles(unnamedSrc,
+                          "public class Test { api.Api api; impl.Impl impl; }");
+        Path unnamedClasses = base.resolve("unnamed-classes");
+        Files.createDirectories(unnamedClasses);
+
+        List<String> log = new JavacTask(tb)
+                .options("--module-path", modulepath.toString(),
+                         "-XDrawDiagnostics")
+                .outdir(unnamedClasses)
+                .files(findJavaFiles(unnamedSrc))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:21: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, m1x)",
+                "Test.java:1:34: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.does.not.read.from.unnamed: impl, m1x)",
+                "2 errors"
+        );
+
+        if (!expected.equals(log)) {
+            throw new Exception("unexpected output: " + log);
+        }
+
+        log = new JavacTask(tb)
+                .options("--module-path", modulepath.toString(),
+                         "--add-modules", "m1x",
+                         "-XDrawDiagnostics")
+                .outdir(unnamedClasses)
+                .files(findJavaFiles(unnamedSrc))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        expected = Arrays.asList(
+                "Test.java:1:21: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported.to.module.from.unnamed: api, m1x)",
+                "Test.java:1:34: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.not.exported.from.unnamed: impl, m1x)",
+                "2 errors"
+        );
+
+        if (!expected.equals(log)) {
+            throw new Exception("unexpected output: " + log);
+        }
+    }
+
+    @Test
+    public void testInImport(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { }",
+                          "package api; public class Api { public String test() { return null; } }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { requires m1x; }",
+                          "package test; import api.Api; public class Test { Api api; { api.test().length(); } }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
+    public void testInImportOnDemand(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { }",
+                          "package api; public class Api { public String test() { return null; } }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { requires m1x; }",
+                          "package test; import api.*; public class Test { Api api; { api.test().length(); } }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)",
+                "Test.java:1:49: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.not.exported: api, m1x)",
+                "2 errors");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
+    public void testUnusedImportOnDemand1(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                          "package test; import javax.annotation.*; public class Test { }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--add-modules", "java.compiler")
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList("");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
+    public void testUnusedImportOnDemand2(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { }",
+                          "package api; public class Api { }");
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { requires m1x; }",
+                          "package test; import api.*; public class Test { }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
+    public void testClassPackageConflict(Path base) throws Exception {
+        Path libSrc = base.resolve("libSrc");
+        tb.writeJavaFiles(libSrc,
+                          "package test.desktop; public class Any { }");
+        Path libClasses = base.resolve("libClasses");
+        tb.createDirectories(libClasses);
+
+        new JavacTask(tb)
+                .outdir(libClasses)
+                .files(findJavaFiles(libSrc))
+                .run()
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                          "package test; public class desktop { public static class Action { } }",
+                          "package use; import test.desktop.*; public class Use { test.desktop.Action a; }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        new JavacTask(tb)
+                .options("-XDrawDiagnostics")
+                .classpath(libClasses)
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testClassPackageConflictInUnnamed(Path base) throws Exception {
+        Path libSrc = base.resolve("libSrc");
+        tb.writeJavaFiles(libSrc,
+                          "package desktop; public class Any { }");
+        Path libClasses = base.resolve("libClasses");
+        tb.createDirectories(libClasses);
+
+        new JavacTask(tb)
+                .outdir(libClasses)
+                .files(findJavaFiles(libSrc))
+                .run()
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                          "public class desktop { public static class Action { } }",
+                          "import desktop.*; public class Use { desktop.Action a; }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        new JavacTask(tb)
+                .options("-XDrawDiagnostics")
+                .classpath(libClasses)
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testUnresolvableInImport(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { }",
+                          "package api; import can.not.resolve; public class Api { }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-source-path", src.toString())
+                .outdir(classes)
+                .files(findJavaFiles(src))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Api.java:1:28: compiler.err.doesnt.exist: can.not",
+                "1 error");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+    @Test
+    public void testMissingKnownClass(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_m1 = src.resolve("m1x");
+        tb.writeJavaFiles(src_m1,
+                          "module m1x { exports api; }",
+                          "package api; public class Base { }",
+                          "package api; public class Sub extends Base { }");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+        Path m1xClasses = classes.resolve("m1x");
+        tb.createDirectories(m1xClasses);
+
+        new JavacTask(tb)
+                .options("-XDrawDiagnostics")
+                .outdir(m1xClasses)
+                .files(findJavaFiles(src_m1))
+                .run(Task.Expect.SUCCESS)
+                .writeAll();
+
+        Files.delete(m1xClasses.resolve("api").resolve("Base.class"));
+
+        Path src_m2 = src.resolve("m2x");
+        tb.writeJavaFiles(src_m2,
+                          "module m2x { requires m1x; }",
+                          "package test;\n" +
+                          "import api.Sub;\n" +
+                          "import api.Base;\n" +
+                          "public class Test {\n" +
+                          "    Sub a2;\n" +
+                          "    Base a;\n" +
+                          "}\n");
+        Path m2xClasses = classes.resolve("m2x");
+        tb.createDirectories(m2xClasses);
+        List<String> log = new JavacTask(tb)
+                .options("-XDrawDiagnostics",
+                         "--module-path", classes.toString(),
+                         "-XDdev")
+                .outdir(m2xClasses)
+                .files(findJavaFiles(src_m2))
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "Test.java:3:11: compiler.err.cant.resolve.location: kindname.class, Base, , , (compiler.misc.location: kindname.package, api, null)",
+                "Test.java:6:5: compiler.err.cant.resolve.location: kindname.class, Base, , , (compiler.misc.location: kindname.class, test.Test, null)",
+                "2 errors");
+
+        if (!expected.equals(log))
+            throw new Exception("expected output not found; actual: " + log);
+    }
+
+}
--- a/langtools/test/tools/javac/modules/EdgeCases.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/EdgeCases.java	Tue Jan 24 00:30:25 2017 +0100
@@ -178,7 +178,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("Test.java:1:52: compiler.err.not.def.access.class.intf.cant.access: call(), api1.Api1") ||
+        if (!log.contains("Test.java:1:52: compiler.err.not.def.access.class.intf.cant.access.reason: call(), api1.Api1, api1, (compiler.misc.not.def.access.does.not.read: m3x, api1, m1x)") ||
             !log.contains("Test.java:1:76: compiler.err.not.def.access.class.intf.cant.access: toString(), java.lang.Object"))
             throw new Exception("expected output not found");
     }
--- a/langtools/test/tools/javac/modules/GraphsTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/GraphsTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -134,9 +134,9 @@
                 .getOutputLines(Task.OutputKind.DIRECT);
 
         List<String> expected = Arrays.asList(
-                "Negative.java:1:43: compiler.err.doesnt.exist: closedO",
-                "Negative.java:1:56: compiler.err.doesnt.exist: closedN",
-                "Negative.java:1:69: compiler.err.doesnt.exist: closedL");
+                "Negative.java:1:36: compiler.err.package.not.visible: closedO, (compiler.misc.not.def.access.not.exported: closedO, O)",
+                "Negative.java:1:49: compiler.err.package.not.visible: closedN, (compiler.misc.not.def.access.not.exported: closedN, N)",
+                "Negative.java:1:62: compiler.err.package.not.visible: closedL, (compiler.misc.not.def.access.not.exported: closedL, L)");
         if (!log.containsAll(expected)) {
             throw new Exception("Expected output not found");
         }
@@ -153,9 +153,9 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
         expected = Arrays.asList(
-                "Negative.java:1:43: compiler.err.not.def.access.package.cant.access: closedO.O, closedO",
-                "Negative.java:1:56: compiler.err.not.def.access.package.cant.access: closedN.N, closedN",
-                "Negative.java:1:69: compiler.err.not.def.access.package.cant.access: closedL.L, closedL");
+                "Negative.java:1:36: compiler.err.package.not.visible: closedO, (compiler.misc.not.def.access.not.exported: closedO, O)",
+                "Negative.java:1:49: compiler.err.package.not.visible: closedN, (compiler.misc.not.def.access.not.exported: closedN, N)",
+                "Negative.java:1:62: compiler.err.package.not.visible: closedL, (compiler.misc.not.def.access.not.exported: closedL, L)");
         if (!out.containsAll(expected)) {
             throw new Exception("Expected output not found");
         }
@@ -201,7 +201,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        String expected = "A.java:1:35: compiler.err.not.def.access.package.cant.access: pack.Clazz, pack";
+        String expected = "A.java:1:31: compiler.err.package.not.visible: pack, (compiler.misc.not.def.access.not.exported.to.module: pack, N, L)";
         if (!log.contains(expected)) {
             throw new Exception("Expected output not found");
         }
--- a/langtools/test/tools/javac/modules/LimitModulesTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/LimitModulesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -180,7 +180,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("C.java:1:41: compiler.err.doesnt.exist: com.sun.tools.javac"))
+        if (!log.contains("C.java:1:35: compiler.err.package.not.visible: com.sun.tools.javac, (compiler.misc.not.def.access.does.not.read.from.unnamed: com.sun.tools.javac, jdk.compiler)"))
             throw new Exception("expected output not found");
     }
 }
--- a/langtools/test/tools/javac/modules/OpenModulesTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/OpenModulesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -117,7 +117,7 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        List<String> expected2 = Arrays.asList("Test.java:1:53: compiler.err.doesnt.exist: api2",
+        List<String> expected2 = Arrays.asList("Test.java:1:49: compiler.err.package.not.visible: api2, (compiler.misc.not.def.access.not.exported: api2, m1x)",
                                                "1 error");
         if (!Objects.equals(log2, expected2))
             throw new Exception("expected output not found: " + log2);
@@ -180,7 +180,7 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        List<String> expected2 = Arrays.asList("Test.java:1:53: compiler.err.doesnt.exist: api2",
+        List<String> expected2 = Arrays.asList("Test.java:1:49: compiler.err.package.not.visible: api2, (compiler.misc.not.def.access.not.exported: api2, m1x)",
                                                "1 error");
         if (!Objects.equals(log2, expected2))
             throw new Exception("expected output not found: " + log2);
--- a/langtools/test/tools/javac/modules/PackageMultipleModules.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/PackageMultipleModules.java	Tue Jan 24 00:30:25 2017 +0100
@@ -70,8 +70,8 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        List<String> expected = Arrays.asList("A.java:1:26: compiler.err.not.def.access.package.cant.access: test.B, test",
-                                              "B.java:1:26: compiler.err.not.def.access.package.cant.access: test.A, test",
+        List<String> expected = Arrays.asList("A.java:1:22: compiler.err.package.not.visible: test, (compiler.misc.not.def.access.does.not.read: m1x, test, m2x)",
+                                              "B.java:1:22: compiler.err.package.not.visible: test, (compiler.misc.not.def.access.does.not.read: m2x, test, m1x)",
                                               "2 errors");
         if (!log.equals(expected))
             throw new Exception("expected output not found");
--- a/langtools/test/tools/javac/modules/RequiresStaticTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/RequiresStaticTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -88,7 +88,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("Test.java:1:27: compiler.err.doesnt.exist: com.sun.source.tree"))
+        if (!log.contains("Test.java:1:22: compiler.err.package.not.visible: com.sun.source.tree, (compiler.misc.not.def.access.does.not.read: m, com.sun.source.tree, jdk.compiler)"))
             throw new Exception("expected output not found");
     }
 
@@ -124,18 +124,10 @@
                 .getOutput(Task.OutputKind.DIRECT);
 
         String[] expect = {
-            "C1.java:5:10: compiler.err.not.def.access.package.cant.access: p5.C5, p5",
-            "C1.java:5:24: compiler.err.not.def.access.package.cant.access: p6.C6, p6",
-            "C1.java:5:38: compiler.err.not.def.access.package.cant.access: p7.C7, p7",
-            "C1.java:5:52: compiler.err.not.def.access.package.cant.access: p8.C8, p8",
-            "C1.java:8:1: compiler.err.cant.resolve.location: kindname.class, C5, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)",
-            "C1.java:8:8: compiler.err.cant.resolve.location: kindname.class, C6, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)",
-            "C1.java:8:15: compiler.err.cant.resolve.location: kindname.class, C7, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)",
-            "C1.java:8:22: compiler.err.cant.resolve.location: kindname.class, C8, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)"
+            "C1.java:5:8: compiler.err.package.not.visible: p5, (compiler.misc.not.def.access.does.not.read: m1x, p5, m5x)",
+            "C1.java:5:22: compiler.err.package.not.visible: p6, (compiler.misc.not.def.access.does.not.read: m1x, p6, m6x)",
+            "C1.java:5:36: compiler.err.package.not.visible: p7, (compiler.misc.not.def.access.does.not.read: m1x, p7, m7x)",
+            "C1.java:5:50: compiler.err.package.not.visible: p8, (compiler.misc.not.def.access.does.not.read: m1x, p8, m8x)"
         };
 
         for (String e: expect) {
--- a/langtools/test/tools/javac/modules/RequiresTransitiveTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/RequiresTransitiveTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -85,7 +85,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("Test.java:1:27: compiler.err.doesnt.exist: com.sun.source.tree"))
+        if (!log.contains("Test.java:1:22: compiler.err.package.not.visible: com.sun.source.tree, (compiler.misc.not.def.access.does.not.read: m, com.sun.source.tree, jdk.compiler)"))
             throw new Exception("expected output not found");
     }
 
@@ -121,15 +121,9 @@
                 .getOutput(Task.OutputKind.DIRECT);
 
         String[] expect = {
-            "C1.java:5:10: compiler.err.not.def.access.package.cant.access: p5.C5, p5",
-            "C1.java:5:24: compiler.err.not.def.access.package.cant.access: p6.C6, p6",
-            "C1.java:5:38: compiler.err.not.def.access.package.cant.access: p7.C7, p7",
-            "C1.java:8:1: compiler.err.cant.resolve.location: kindname.class, C5, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)",
-            "C1.java:8:8: compiler.err.cant.resolve.location: kindname.class, C6, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)",
-            "C1.java:8:15: compiler.err.cant.resolve.location: kindname.class, C7, , , "
-                + "(compiler.misc.location: kindname.class, p1.C1, null)"
+            "C1.java:5:8: compiler.err.package.not.visible: p5, (compiler.misc.not.def.access.does.not.read: m1x, p5, m5x)",
+            "C1.java:5:22: compiler.err.package.not.visible: p6, (compiler.misc.not.def.access.does.not.read: m1x, p6, m6x)",
+            "C1.java:5:36: compiler.err.package.not.visible: p7, (compiler.misc.not.def.access.does.not.read: m1x, p7, m7x)"
         };
 
         for (String e: expect) {
--- a/langtools/test/tools/javac/modules/ResolveTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/ResolveTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -99,7 +99,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("C2.java:1:33: compiler.err.not.def.access.package.cant.access: p1.C1, p1"))
+        if (!log.contains("C2.java:1:31: compiler.err.package.not.visible: p1, (compiler.misc.not.def.access.does.not.read: m2x, p1, m1x)"))
             throw new Exception("expected output not found");
     }
 
@@ -123,7 +123,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("C2.java:1:33: compiler.err.not.def.access.package.cant.access: p1.C1, p1"))
+        if (!log.contains("C2.java:1:31: compiler.err.package.not.visible: p1, (compiler.misc.not.def.access.not.exported: p1, m1x)"))
             throw new Exception("expected output not found");
     }
 
@@ -149,7 +149,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("C2.java:1:33: compiler.err.not.def.access.package.cant.access: p1.C1, p1"))
+        if (!log.contains("C2.java:1:31: compiler.err.package.not.visible: p1, (compiler.misc.not.def.access.not.exported.to.module: p1, m1x, m2x)"))
             throw new Exception("expected output not found");
     }
 
@@ -173,7 +173,7 @@
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("C2.java:1:33: compiler.err.not.def.access.package.cant.access: p1.C1, p1"))
+        if (!log.contains("C2.java:1:31: compiler.err.package.not.visible: p1, (compiler.misc.not.def.access.does.not.read: m2x, p1, m1x)"))
             throw new Exception("expected output not found");
     }
 
--- a/langtools/test/tools/javac/modules/UsesTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/UsesTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -262,7 +262,7 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        List<String> expected = Arrays.asList("module-info.java:1:34: compiler.err.not.def.access.package.cant.access: p.C, p",
+        List<String> expected = Arrays.asList("module-info.java:1:33: compiler.err.package.not.visible: p, (compiler.misc.not.def.access.not.exported: p, m1x)",
                 "1 error");
         if (!output.containsAll(expected)) {
             throw new Exception("Expected output not found");
@@ -286,7 +286,7 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        List<String> expected = Arrays.asList("module-info.java:1:34: compiler.err.not.def.access.package.cant.access: p.C, p",
+        List<String> expected = Arrays.asList("module-info.java:1:33: compiler.err.package.not.visible: p, (compiler.misc.not.def.access.not.exported: p, m1x)",
                 "1 error");
         if (!output.containsAll(expected)) {
             throw new Exception("Expected output not found");
--- a/langtools/test/tools/javac/modules/XModuleTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/langtools/test/tools/javac/modules/XModuleTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -288,7 +288,7 @@
                 .writeAll()
                 .getOutputLines(Task.OutputKind.DIRECT);
 
-        List<String> expected = Arrays.asList("A.java:1:36: compiler.err.doesnt.exist: pkg2",
+        List<String> expected = Arrays.asList("A.java:1:32: compiler.err.package.not.visible: pkg2, (compiler.misc.not.def.access.does.not.read: m1, pkg2, m2)",
                 "1 error");
 
         if (!expected.equals(log))
--- a/make/Bundles.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/make/Bundles.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -77,9 +77,8 @@
 	$$(call MakeDir, $$(@D))
         ifneq ($$($1_SPECIAL_INCLUDES), )
 	  $$(foreach i, $$($1_SPECIAL_INCLUDES), \
-	    $$(foreach d, $$d, \
-	      ($(CD) $$d && $(FIND) $$i \
-	          >> $(SUPPORT_OUTPUTDIR)/bundles/_$1_files ) ; ))
+	    $$(foreach d, $$($1_BASE_DIRS), \
+	      ($(CD) $$d && $(FIND) $$i >> $$($1_$$d_LIST_FILE)) ; ))
         endif
         ifeq ($$($1_SUBDIR)-$$($1_TYPE)-$$($1_UNZIP_DEBUGINFO), .-zip-false)
           # If no subdir is specified, zip can be done directly from BASE_DIRS.
@@ -152,6 +151,9 @@
   JRE_IMAGE_HOMEDIR := $(JRE_IMAGE_DIR)
   JDK_BUNDLE_SUBDIR := jdk-$(VERSION_NUMBER)
   JRE_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)
+  JRE_COMPACT1_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact1
+  JRE_COMPACT2_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact2
+  JRE_COMPACT3_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact3
   ifneq ($(DEBUG_LEVEL), release)
     JDK_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR)/$(DEBUG_LEVEL)
     JRE_BUNDLE_SUBDIR := $(JRE_BUNDLE_SUBDIR)/$(DEBUG_LEVEL)
@@ -281,6 +283,35 @@
 
 ################################################################################
 
+ifneq ($(filter profiles-bundles, $(MAKECMDGOALS)), )
+  ifeq ($(OPENJDK_TARGET_OS), macosx)
+    $(error Creating compact profiles bundles on macosx is unsupported)
+  endif
+
+  define GenerateCompactProfilesBundles
+    ALL_JRE_COMPACT$1_FILES := $$(call CacheFind, $$(JRE_COMPACT$1_IMAGE_DIR))
+
+    JRE_COMPACT$1_BUNDLE_FILES := $$(filter-out \
+        $$(SYMBOLS_EXCLUDE_PATTERN), \
+        $$(ALL_JRE_COMPACT$1_FILES))
+
+    $$(eval $$(call SetupBundleFile, BUILD_JRE_COMPACT$1_BUNDLE, \
+        BUNDLE_NAME := $$(JRE_COMPACT$1_BUNDLE_NAME), \
+        FILES := $$(JRE_COMPACT$1_BUNDLE_FILES), \
+        BASE_DIRS := $$(JRE_COMPACT$1_IMAGE_DIR), \
+        SUBDIR := $$(JRE_COMPACT$1_BUNDLE_SUBDIR), \
+    ))
+
+    PROFILES_TARGETS += $$(BUILD_JRE_COMPACT$1_BUNDLE)
+  endef
+
+  $(eval $(call GenerateCompactProfilesBundles,1))
+  $(eval $(call GenerateCompactProfilesBundles,2))
+  $(eval $(call GenerateCompactProfilesBundles,3))
+endif
+
+################################################################################
+
 ifneq ($(filter test-bundles, $(MAKECMDGOALS)), )
   TEST_BUNDLE_FILES := $(call CacheFind, $(TEST_IMAGE_DIR))
 
@@ -316,7 +347,8 @@
 ################################################################################
 
 product-bundles: $(PRODUCT_TARGETS)
+profiles-bundles: $(PROFILES_TARGETS)
 test-bundles: $(TEST_TARGETS)
 docs-bundles: $(DOCS_TARGETS)
 
-.PHONY: all default product-bundles test-bundles docs-bundles
+.PHONY: all default product-bundles profiles-bundles test-bundles docs-bundles
--- a/make/CompileJavaModules.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/make/CompileJavaModules.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -383,6 +383,10 @@
 
 ################################################################################
 
+jdk.jartool_ADD_JAVAC_FLAGS := -XDstringConcat=inline
+
+################################################################################
+
 jdk.rmic_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
 jdk.rmic_CLEAN := .properties
 
--- a/make/Images.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/make/Images.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -147,10 +147,6 @@
 	    --output $(JRE_IMAGE_DIR)
 	$(TOUCH) $@
 
-JRE_COMPACT1_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact1
-JRE_COMPACT2_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact2
-JRE_COMPACT3_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact3
-
 
 $(JRE_COMPACT1_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
     $(call DependOnVariable, JRE_COMPACT1_MODULES_LIST) $(BASE_RELEASE_FILE)
--- a/make/Javadoc.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/make/Javadoc.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -86,7 +86,7 @@
     DRAFT_WINDOW_TITLE_MARKER := $(SPACE)[build $(VERSION_BUILD)]
   endif
   EARLYACCESS_TOP := \
-      <div style="background-color: $$(HASH)EEEEEE"><div style="padding: 6px; \
+      <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 \
@@ -235,10 +235,6 @@
 
   $1_OPTIONS += --add-modules $$(call CommaList, $$($1_MODULES))
 
-  ifneq ($$(LOG_LEVEL), trace)
-    $1_OPTIONS += -quiet
-  endif
-
   ifneq ($$($1_DISABLED_DOCLINT), )
     # Create a string like ",-syntax,-html"
     $1_DOCLINT_EXCEPTIONS := ,$$(call CommaList, $$(addprefix -, $$($1_DISABLED_DOCLINT)))
@@ -292,6 +288,13 @@
   $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
        $$(SUPPORT_OUTPUTDIR)/docs/$1.vardeps)
 
+  # Do not store debug level options in VARDEPS.
+  ifneq ($$(LOG_LEVEL), trace)
+    $1_OPTIONS += -quiet
+  else
+    $1_OPTIONS += -verbose
+  endif
+
   $1_PACKAGE_DEPS := $$(call CacheFind, $$(wildcard $$(foreach p, \
       $$(subst .,/,$$(strip $$($1_PACKAGES))), \
       $$(addsuffix /$$p, $$(wildcard $$(JAVADOC_SOURCE_DIRS))))))
--- a/make/Main.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/make/Main.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -342,7 +342,7 @@
 symbols-image:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk symbols)
 
-profiles:
+profiles-image:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)
 
 mac-bundles-jdk:
@@ -356,7 +356,7 @@
 
 ALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \
     zip-source jrtfs-jar jdk-image jre-image \
-    symbols-image profiles mac-bundles-jdk \
+    symbols-image profiles-image mac-bundles-jdk \
     release-file exploded-image-optimize
 
 ################################################################################
@@ -510,13 +510,16 @@
 product-bundles:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles)
 
+profiles-bundles:
+	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk profiles-bundles)
+
 test-bundles:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles)
 
 docs-bundles:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles)
 
-ALL_TARGETS += product-bundles test-bundles docs-bundles
+ALL_TARGETS += product-bundles profiles-bundles test-bundles docs-bundles
 
 ################################################################################
 # Install targets
@@ -734,7 +737,7 @@
   jre-image: jmods release-file
   symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS)
 
-  profiles: jmods release-file
+  profiles-image: jmods release-file
 
   mac-bundles-jdk: jdk-image jre-image
 
@@ -793,6 +796,8 @@
 
   product-bundles: product-images
 
+  profiles-bundles: profiles-images
+
   test-bundles: test-image
 
   docs-bundles: docs-image
@@ -878,6 +883,9 @@
 # an image until this can be cleaned up properly.
 product-images: zip-security
 
+# Declare these for backwards compatiblity and convenience.
+profiles profiles-images: profiles-image
+
 # The module summary cannot be run when:
 # * Cross compiling and building a partial BUILDJDK for the build host
 # * An external buildjdk has been supplied since it may not match the
@@ -909,7 +917,9 @@
     copy java rmic libs launchers jmods \
     jdk.jdwp.agent-gensrc $(ALL_MODULES) demos samples \
     exploded-image-base exploded-image \
-    create-buildjdk mac-bundles product-images docs-image test-image all-images \
+    create-buildjdk mac-bundles product-images \
+    profiles profiles-images \
+    docs-image test-image all-images \
     all-bundles
 
 ################################################################################
--- a/make/common/MakeBase.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/make/common/MakeBase.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -435,7 +435,7 @@
       Too many named arguments to macro, please update MAX_PARAMS in MakeBase.gmk))
   # Iterate over 2 3 4... and evaluate the named parameters with $1_ as prefix
   $(foreach i,$(PARAM_SEQUENCE), $(if $(strip $($i)),\
-    $(strip $1)_$(strip $(call DoubleDollar, $($i))))$(NEWLINE))
+    $(strip $1)_$(strip $(call EscapeHash, $(call DoubleDollar, $($i))))$(NEWLINE)))
   # Debug print all named parameter names and values
   $(if $(findstring $(LOG_LEVEL),debug trace), \
     $(info $0 $(strip $1) $(foreach i,$(PARAM_SEQUENCE), \
--- a/make/common/NativeCompilation.gmk	Wed Jan 25 15:31:01 2017 +0530
+++ b/make/common/NativeCompilation.gmk	Tue Jan 24 00:30:25 2017 +0100
@@ -288,8 +288,7 @@
         $$($1_$(notdir $2)_OPTIMIZATION)), )
       $1_$2_VARDEPS := $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) \
           $$($1_$(notdir $2)_OPT_CFLAGS) $$($1_$(notdir $2)_OPT_CXXFLAGS)
-      $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \
-          $$(patsubst %$(OBJ_SUFFIX),%.vardeps,$$($1_$2_OBJ)))
+      $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, $$($1_$2_OBJ).vardeps)
     endif
 
     $$($1_$2_OBJ) : $2 $$($1_COMPILE_VARDEPS_FILE) $$($1_$2_VARDEPS_FILE) | $$($1_BUILD_INFO)
--- a/nashorn/.hgtags	Wed Jan 25 15:31:01 2017 +0530
+++ b/nashorn/.hgtags	Tue Jan 24 00:30:25 2017 +0100
@@ -385,3 +385,5 @@
 c281306d33d83c92e0d870ace385d5f99678d7e7 jdk-9+149
 ace1d994bca775d6545a4c874ae73d1dfc9ec18b jdk-9+150
 2a0437036a64853334e538044eb68d2df70075fa jdk-9+151
+ddc52e72757086a75a54371e8e7f56a3f89f1e55 jdk-9+152
+19aaaf2d02b7d6986538cd9a8c46901ecb50eebf jdk-9+153
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java	Tue Jan 24 00:30:25 2017 +0100
@@ -1032,7 +1032,7 @@
             }
 
             final Object key = property.getKey();
-            property = iter.next();
+            property = iter.hasNext() ? iter.next() : null;
             skipNotEnumerable();
 
             return key;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java	Tue Jan 24 00:30:25 2017 +0100
@@ -28,6 +28,8 @@
 import static jdk.nashorn.internal.lookup.Lookup.MH;
 
 import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
@@ -100,7 +102,7 @@
      * reparsed from source, or a soft reference to a {@code FunctionNode} for other functions (it is safe
      * to be cleared as they can be reparsed).
      */
-    private volatile Object cachedAst;
+    private volatile transient Object cachedAst;
 
     /** Token of this function within the source. */
     private final long token;
@@ -289,6 +291,9 @@
         if (this.source == null && this.installer == null) {
             this.source    = src;
             this.installer = inst;
+            for (final RecompilableScriptFunctionData nested : nestedFunctions.values()) {
+                nested.initTransients(src, inst);
+            }
         } else if (this.source != src || !this.installer.isCompatibleWith(inst)) {
             // Existing values must be same as those passed as parameters
             throw new IllegalArgumentException();
@@ -424,7 +429,7 @@
         } else if (lCachedAst instanceof SerializedAst) {
             final SerializedAst serializedAst = (SerializedAst)lCachedAst;
             // Even so, are we also softly caching the AST?
-            final FunctionNode cachedFn = serializedAst.cachedAst.get();
+            final FunctionNode cachedFn = serializedAst.cachedAst == null ? null : serializedAst.cachedAst.get();
             if (cachedFn != null) {
                 // Yes we are - this is fast
                 return cloneSymbols(cachedFn);
@@ -492,9 +497,11 @@
      * we're using this tuple instead to also keep a deserialized AST around in memory to cut down on
      * deserialization costs.
      */
-    private static class SerializedAst {
+    private static class SerializedAst implements Serializable {
         private final byte[] serializedAst;
-        private volatile Reference<FunctionNode> cachedAst;
+        private volatile transient Reference<FunctionNode> cachedAst;
+
+        private static final long serialVersionUID = 1L;
 
         SerializedAst(final FunctionNode fn, final Reference<FunctionNode> cachedAst) {
             this.serializedAst = AstSerializer.serialize(fn);
@@ -1038,8 +1045,20 @@
         return true;
     }
 
+    private void writeObject(final ObjectOutputStream out) throws IOException {
+        final Object localCachedAst = cachedAst;
+        out.defaultWriteObject();
+        // We need to persist SerializedAst for split functions as they can't reparse the source code.
+        if (localCachedAst instanceof SerializedAst) {
+            out.writeObject(localCachedAst);
+        } else {
+            out.writeObject(null);
+        }
+    }
+
     private void readObject(final java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
         in.defaultReadObject();
+        cachedAst = in.readObject();
         createLogger();
     }
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/base.js	Wed Jan 25 15:31:01 2017 +0530
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/base.js	Tue Jan 24 00:30:25 2017 +0100
@@ -108,7 +108,7 @@
         }
     });
 
-    Files.walkFileTree(rootDirectories[0], new JRTFSWalker());
+    Files.walkFileTree(rootDirectories.toArray()[0], new JRTFSWalker());
 })();
 
 LOAD_FX_CLASSES(this, "javafx.base");
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java	Wed Jan 25 15:31:01 2017 +0530
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -47,7 +47,7 @@
 @SuppressWarnings("javadoc")
 public class CodeStoreAndPathTest {
 
-    final String code1 = "var code1; var x = 'Hello Script'; var x1 = 'Hello Script'; "
+    final static String code1 = "var code1; var x = 'Hello Script'; var x1 = 'Hello Script'; "
                 + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
                 + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
                 + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
@@ -69,7 +69,7 @@
                 + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
                 + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
                 + "var x10 = 'Hello Script';}";
-    final String code2 = "var code2; var x = 'Hello Script'; var x1 = 'Hello Script'; "
+    final static String code2 = "var code2; var x = 'Hello Script'; var x1 = 'Hello Script'; "
                 + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
                 + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
                 + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
@@ -92,9 +92,306 @@
                 + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
                 + "var x10 = 'Hello Script';}";
     // Script size < Default minimum size for storing a compiled script class
-    final String code3 = "var code3; var x = 'Hello Script'; var x1 = 'Hello Script'; ";
-    final String codeCache = "build/nashorn_code_cache";
-    final String oldUserDir = System.getProperty("user.dir");
+    final static String code3 = "var code3; var x = 'Hello Script'; var x1 = 'Hello Script'; ";
+    final static String nestedFunctions = "\n" +
+            "(function outer() { \n" +
+            "    var map = null; \n" +
+            "    (function inner() { \n" +
+            "        var object; \n" +
+            "        if (map === null) { \n" +
+            "            map = (function() { \n" +
+            "                var HashMap = Java.type('java.util.HashMap'); \n" +
+            "                map = new HashMap(); \n" +
+            "                map.name          = 'name'; \n" +
+            "                map.id            = 1234;\n" +
+            "                map.basePath      = 'basePath'; \n" +
+            "                map.extensionPath = 'extension';\n" +
+            "                map.address       = 'address'; \n" +
+            "                map.name          = 'name'; \n" +
+            "                map.id            = 1234;\n" +
+            "                map.basePath      = 'basePath'; \n" +
+            "                map.extensionPath = 'extension';\n" +
+            "                map.address       = 'address';\n" +
+            "                map.name          = 'name'; \n" +
+            "                map.id            = 1234;\n" +
+            "                map.basePath      = 'basePath'; \n" +
+            "                map.extensionPath = 'extension';\n" +
+            "                map.address       = 'address'; \n" +
+            "                return map; \n" +
+            "            }()); \n" +
+            "        } \n" +
+            "        object = {}; \n" +
+            "        return object; \n" +
+            "    })(); \n" +
+            "}()); ";
+    final static String longNestedFunctions = "\n" +
+            "(function outer() { \n" +
+            "    var map = null; \n" +
+            "    (function inner() { \n" +
+            "        var object; \n" +
+            "        var HashMap = Java.type('java.util.HashMap'); \n" +
+            "        map = new HashMap(); \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address';\n" +
+            "        map.name          = 'name'; \n" +
+            "        map.id            = 1234;\n" +
+            "        map.basePath      = 'basePath'; \n" +
+            "        map.extensionPath = 'extension';\n" +
+            "        map.address       = 'address'; \n" +
+            "        object = {}; \n" +
+            "        return object; \n" +
+            "    })(); \n" +
+            "}()); ";
+    final static String codeCache = "build/nashorn_code_cache";
+    final static String oldUserDir = System.getProperty("user.dir");
 
     private static final String[] ENGINE_OPTIONS_OPT   = new String[]{"--persistent-code-cache", "--optimistic-types=true"};
     private static final String[] ENGINE_OPTIONS_NOOPT = new String[]{"--persistent-code-cache", "--optimistic-types=false"};
@@ -166,6 +463,28 @@
         checkCompiledScripts(stream, 4);
     }
 
+    @Test
+    public void testNestedFunctionStore() throws ScriptException, IOException {
+        System.setProperty("nashorn.persistent.code.cache", codeCache);
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(nestedFunctions);
+        factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(nestedFunctions);
+        factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(nestedFunctions);
+        factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(nestedFunctions);
+    }
+
+    @Test
+    public void testSplitFunctionStore() throws ScriptException, IOException {
+        System.setProperty("nashorn.persistent.code.cache", codeCache);
+        System.setProperty("nashorn.compiler.splitter.threshold", "500");
+        final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+        factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(longNestedFunctions);
+        factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(longNestedFunctions);
+        factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(longNestedFunctions);
+        factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(longNestedFunctions);
+        System.getProperties().remove("nashorn.compiler.splitter.threshold");
+    }
+
     private static Path getCodeCachePath(final boolean optimistic) {
         final String codeCache = System.getProperty("nashorn.persistent.code.cache");
         final Path codeCachePath = FileSystems.getDefault().getPath(codeCache).toAbsolutePath();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/PropertyMapTest.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,65 @@
+/*
+ * 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 jdk.nashorn.internal.runtime.test;
+
+import java.util.Iterator;
+import jdk.nashorn.internal.runtime.PropertyMap;
+import jdk.nashorn.internal.runtime.ScriptObject;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for PropertyMap functionality
+ *
+ * @test
+ * @modules jdk.scripting.nashorn/jdk.nashorn.internal.runtime
+ * @run testng jdk.nashorn.internal.runtime.test.PropertyMapTest
+ */
+@SuppressWarnings("javadoc")
+public class PropertyMapTest {
+
+    @Test
+    public void propertyMapIteratorTest() {
+        final ScriptObject scriptObject = new ScriptObject(PropertyMap.newMap()) {};
+        Assert.assertFalse(scriptObject.getMap().iterator().hasNext());
+
+        scriptObject.set("a", "a", 0);
+        scriptObject.set("b", 3, 0);
+        // 3 is a valid array key not stored in property map
+        scriptObject.set(3, 1, 0);
+        scriptObject.set(6.5, 1.3, 0);
+        final Iterator<Object> iterator = scriptObject.getMap().iterator();
+
+        Assert.assertTrue(iterator.hasNext());
+        Assert.assertEquals(iterator.next(), "a");
+        Assert.assertTrue(iterator.hasNext());
+        Assert.assertEquals(iterator.next(), "b");
+        Assert.assertTrue(iterator.hasNext());
+        Assert.assertEquals(iterator.next(), "6.5");
+        Assert.assertFalse(iterator.hasNext());
+    }
+
+}
--- a/test/failure_handler/src/share/conf/mac.properties	Wed Jan 25 15:31:01 2017 +0530
+++ b/test/failure_handler/src/share/conf/mac.properties	Tue Jan 24 00:30:25 2017 +0100
@@ -64,7 +64,7 @@
 native.core.app=bash
 native.core.delimiter=\0
 native.core.args=-c\0gcore -o ./core.%p %p || \
-  (DevToolsSecurity --status | grep -q enabled && lldb -o 'attach %p' -o 'process save-core core.%p' -o 'detach' -o 'quit')
+  (DevToolsSecurity --status | grep -q enabled && lldb --batch -o 'attach %p' -o 'process save-core core.%p' -o 'detach' -o 'quit')
 native.core.params.timeout=3600000
 ################################################################################
 # environment info to gather
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/SecurityTools.java	Tue Jan 24 00:30:25 2017 +0100
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class SecurityTools {
+
+    public static final String NO_ALIAS = null;
+
+    // keytool
+
+    public static OutputAnalyzer keytool(List<String> options)
+            throws Throwable {
+
+        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("keytool")
+                .addVMArg("-Duser.language=en")
+                .addVMArg("-Duser.country=US");
+        for (String option : options) {
+            if (option.startsWith("-J")) {
+                launcher.addVMArg(option.substring(2));
+            } else {
+                launcher.addToolArg(option);
+            }
+        }
+        return ProcessTools.executeCommand(launcher.getCommand());
+    }
+
+    public static OutputAnalyzer keytool(String options) throws Throwable {
+        return keytool(options.split("\\s+"));
+    }
+
+    public static OutputAnalyzer keytool(String... options) throws Throwable {
+        return keytool(List.of(options));
+    }
+
+    // jarsigner
+
+    public static OutputAnalyzer jarsigner(String jar, String alias,
+            List<String> options) throws Throwable {
+        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jarsigner")
+                .addVMArg("-Duser.language=en")
+                .addVMArg("-Duser.country=US");
+        for (String option : options) {
+            if (option.startsWith("-J")) {
+                launcher.addVMArg(option.substring(2));
+            } else {
+                launcher.addToolArg(option);
+            }
+        }
+        launcher.addToolArg(jar);
+        if (alias != null) {
+            launcher.addToolArg(alias);
+        }
+        return ProcessTools.executeCommand(launcher.getCommand());
+    }
+
+    public static OutputAnalyzer jarsigner(String jar, String alias,
+            String options) throws Throwable {
+
+        return jarsigner(jar, alias, options.split("\\s+"));
+    }
+
+    public static OutputAnalyzer jarsigner(String jar, String alias,
+            String... options) throws Throwable {
+
+        return jarsigner(jar, alias, List.of(options));
+    }
+
+    public static OutputAnalyzer sign(String jar, String alias, String... options)
+            throws Throwable {
+
+        return jarsigner(jar, alias,
+                mergeOptions("-J-Djava.security.egd=file:/dev/./urandom", options));
+    }
+
+    public static OutputAnalyzer verify(String jar, String... options)
+            throws Throwable {
+
+        return jarsigner(jar, NO_ALIAS, mergeOptions("-verify", options));
+    }
+
+    // helper methods
+
+    private static List<String> mergeOptions(
+            String firstOption, String... secondPart) {
+
+        return mergeOptions(List.of(firstOption), secondPart);
+    }
+
+    private static List<String> mergeOptions(
+            List<String> firstPart, String... secondPart) {
+
+        List<String> options = new ArrayList<>(firstPart);
+        Collections.addAll(options, secondPart);
+        return options;
+    }
+}
+